http://inside.mines.edu/~whoff/courses/EENG512/lectures/HoughInOpenCV.pdf
您好,我正在浏览上面链接中的 pdf 教程。
我在幻灯片的第 6 页遇到问题。
正如我们所看到的,插入 canny 边缘检测器后代码的输出,它应该描绘出照片上的所有边缘。
我看不到第 6 页显示的内容。
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace std;
using namespace cv;
int main(int argc, char* argv[])
{
printf("Hello world\n");
// read an image
Mat imgInput = imread("a.png");
// create image window named "My Image"
namedWindow("My Image");
// Convert to gray if necessary
if (imgInput.channels() == 3)
cv::cvtColor(imgInput, imgInput, CV_BGR2GRAY);
// Apply Canny edge detector
Mat imgContours;
double thresh = 105; // try different values to see effect
Canny(imgInput, imgContours, 0.4*thresh, thresh); // low, high threshold
// show the image on window
imshow("My Image", imgInput);
// wait for xx ms (0 means wait until keypress)
waitKey(5000);
return 0;
}
还有一行 double thresh = xxx;//try different values
我应该输入什么值?这些值是什么意思?
谢谢
最佳答案
只需将 imshow
函数替换为 ,
imshow("我的图片", imgContours);
并且您可以使用大约 200
左右的 thresh
值。
更改阈值并查看它的效果,并根据它选择您的阈值。
关于c++ - 霍夫变换 OPENCV C++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31978804/