平面对象识别
对象形变与位置变换
代码演示
对象形变与位置变换
1. findHomography – 发现两个平面的透视变换,生成变换矩阵
2. perspectiveTransform 透视变换
代码演示
#include <opencv2/opencv.hpp>
#include <opencv2/xfeatures2d.hpp>
#include <iostream>
#include <math.h>
using namespace cv;
using namespace std;
using namespace cv::xfeatures2d;
int main(int argc, char** argv) {
Mat img1 = imread("D:/vcprojects/images/box.png", IMREAD_GRAYSCALE);
Mat img2 = imread("D:/vcprojects/images/box_in_scene.png", IMREAD_GRAYSCALE);
if (!img1.data || !img2.data) {
return -1;
}
imshow("object image", img1);
imshow("object in scene", img2);
// surf featurs extraction
int minHessian = 400;
Ptr<SURF> detector = SURF::create(minHessian);
vector<KeyPoint> keypoints_obj;
vector<KeyPoint> keypoints_scene;
Mat descript