c++ - 霍夫变换 OPENCV C++

标签 c++ opencv hough-transform

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/

相关文章:

c++ - 遍历字符串会导致段错误

C++ 变量参数错误

c++ - 从 PointCloud 到 Mat 的转换

ios - 如何使用opencv将相机坐标转换为经纬度

matlab - 霍夫变换 MATLAB - 自定义实现

python - 使用霍夫变换检测矩形图像的线条

image - 图像中的矩形检测

c++ - 将参数转发给模板成员函数

c++ - 在 Qt Creator 中链接外部静态库

python - 运行后如何获得对Docker容器的bash访问