什么是流动性挖矿?
就其核心而言,流动性挖矿是一个允许加密货币持有者锁定其持有量的过程,这反过来又为他们提供了奖励。更具体地说,这是一个让你通过在DeFi市场上投资加密货币来获得固定或可变利息的过程。
简单地说,流动性挖矿涉及通过以太坊网络借出加密货币。当通过银行使用法币进行贷款时,借出的金额会连本带利归还。对于流动性挖矿,其概念是相同的:本来在交易所或钱包里的加密货币,通过DeFi协议(或锁定在智能合约中,以太坊术语)借出,以获得回报。
流动性挖矿通常在以太坊上使用ERC-20代币进行,奖励是ERC-20代币的一种形式。虽然这在未来可能会改变,但目前几乎所有的流动性挖矿交易都是在以太坊生态系统中进行的。
测试LP流动池
- 新建VC 控制台空项目
- 修改平台为x64,这一步先做
- 源文件中加入main.cpp,测试代码:
#include "opencv2/opencv.hpp"
using namespace cv;
int main()
{
Mat img = imread("test.jpg");
imshow("lena", img);
waitKey(1000);
}
- 属性->VC 目录->包含目录中添加
- buildinclude
- buildincludeopencv
- buildincludeopencv2
- 在通用属性->VC 目录->库目录中添加
- opencvbuildx64vc14lib
- 在通用属性->链接器->输入->附加依赖项中添加
- opencv_world320d.lib
- opencv_world320.lib
- 将测试图放在main.cpp同一目录下,注意不是debug或release的目录
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/videoio.hpp>
#include <iostream>
#include "opencv2/features2d/features2d.hpp"
#include <vector>
#include <time.h>
using namespace cv;
using namespace std;
int main()
{
VideoCapture cap1;
VideoCapture cap2;
cap1.open(1);//白色摄像头
cap2.open(2);//黑色摄像头
if (!cap1.isOpened()||!cap2.isOpened())
{
return -1;
}
//将摄像头从640*480改成320*240,速度从200ms提升至50ms
cap1.set(CV_CAP_PROP_FRAME_WIDTH, 320);
cap1.set(CV_CAP_PROP_FRAME_HEIGHT, 240);
cap2.set(CV_CAP_PROP_FRAME_WIDTH, 320);
cap2.set(CV_CAP_PROP_FRAME_HEIGHT, 240);
//namedWindow("Video", 1);
//namedWindow("Video", 2);
//namedWindow("pts", 3);
//Mat frame;
Mat img_1;
Mat img_2;
while (1)
{
cap1 >> img_1;
cap2 >> img_2;
if (!img_1.data || !img_2.data)
{
cout << "error reading images " << endl;
return -1;
}
//初始化
clock_t startTime, endTime;
startTime = clock();
Ptr<ORB> orb = ORB::create(500, 1.2F, 8, 31, 0, 2, ORB::HARRIS_SCORE, 31, 20);//均为默认参数
vector<KeyPoint> keyPoints_1, keyPoints_2;
Mat descriptors_1, descriptors_2;
//orb检测角点
orb->detect(img_1, keyPoints_1);
orb->detect(img_2, keyPoints_2);
if (keyPoints_1.size() == 0 || keyPoints_2.size() == 0)
{
continue;
}
//计算描述子
orb->compute(img_1, keyPoints_1, descriptors_1);
orb->compute(img_2, keyPoints_2, descriptors_2);
//匹配特征点,Hamming距离
vector<DMatch> matches;
BFMatcher matcher(NORM_HAMMING);
matcher.match(descriptors_1, descriptors_2, matches);
//筛选匹配点
double min_dist = matches[0].distance, max_dist = matches[0].distance;
for (int i = 0; i < descriptors_1.rows; i )
{
double dist = matches[i].distance;
if (dist < min_dist)
min_dist = dist;
if (dist > max_dist)
max_dist = dist;
}
printf("max: %fn", max_dist);
printf("min: %fn", min_dist);
//当描述子之间的距离大于两倍的最小距离时,即认为匹配有误.但有时候最小距离会非常小,设置一个经验值30作为下限.
std::vector< DMatch > good_matches;
for (int i = 0; i < descriptors_1.rows; i )
{
if (matches[i].distance <= max(2 * min_dist, 30.0))
{
good_matches.push_back(matches[i]);
}
}
endTime = clock();
cout << "Totle Time : " << (double)(endTime - startTime) / CLOCKS_PER_SEC << "s" << endl;
printf("goodmatches number:%dn", good_matches.size());
//-- 第五步:绘制匹配结果
/*Mat img_match;
Mat img_goodmatch;
drawMatches(img_1, keyPoints_1, img_2, keyPoints_2, matches, img_match);
drawMatches(img_1, keyPoints_1, img_2, keyPoints_2, good_matches, img_goodmatch);
imshow("所有匹配点对", img_match);
imshow("优化后匹配点对", img_goodmatch);
waitKey(1);*/
}
cap1.release();
cap2.release();
return 0;
}