opencv学习笔记6 角点检测

大城市里の小女人 提交于 2019-11-29 09:57:01

角点检测

1.harris焦点检测

void cornerHarris(InputArray src,OutputArray dst, int blockSize, int ksize, double k, intborderType=BORDER_DEFAULT )

 

1     Mat src = imread("E:/house.png", 0);
2     Mat harris,harris_bin;
3     cornerHarris(src, harris, 2, 3, 0.01);
4     threshold(harris, harris_bin, 0.00001, 255, THRESH_BINARY);
5     imshow("src", src);
6     imshow("角点检测后的二值效果图", harris_bin);
7     waitKey();

 

 

 

 2.阈值(用于生成二值图)

double threshold(InputArray src,OutputArray dst, double thresh, double maxval, int type)

 1 #include<opencv.hpp>
 2 #include<vector>
 3 using namespace std;
 4 using namespace cv;
 5 int main()
 6 {
 7     Mat src = imread("E:/test.jpg",0);
 8     imshow("src", src);
 9     Mat thresh_bin;
10     threshold(src, thresh_bin, 127, 255, THRESH_BINARY); //阈值127
11     imshow("thresh_bin", thresh_bin);
12     Mat thresh_bin_inv;
13     threshold(src, thresh_bin_inv, 127, 255, THRESH_BINARY_INV);
14     imshow("thresh_bin_inv", thresh_bin_inv);
15     waitKey();
16     return 0;
17 }

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!