如何使用OpenCV的规范化相关性?
How to use OpenCV's normalized correlation?
如何使用OpenCV的规范化相关性?任何人都可以提供代码示例吗?
我的问题:我有一个螺丝头图像,需要找到螺丝的中心。所以我正在考虑使用 OpenCV 关联,这是一个好主意吗?
您可以在以下链接下找到示例图像:
http://imageshack.us/photo/my-images/685/screw1.png/
请为我提供一个在 OpenCV 中进行关联的代码示例。如何使用?相关函数的输出是什么?相关函数会提供螺钉位置吗?
我认为您正在寻找cv::matchTemplate
函数:
cv::Mat image; // Your input image
cv::Mat templ; // Your template image of the screw
cv::Mat result; // Result correlation will be placed here
// Do template matching across whole image
cv::matchTemplate(image, templ, result, CV_TM_CCORR_NORMED);
// Find a best match:
double minVal, maxVal;
cv::Point minLoc, maxLoc;
cv::minMaxLoc(result, &minVal, &maxVal, &minLoc, &maxLoc);
// Regards to documentation the best match is in maxima location
// (http://opencv.willowgarage.com/documentation/cpp/object_detection.html)
// Move center of detected screw to the correct position:
cv::Point screwCenter = maxLoc + cv::Point(templ.cols/2, templ.rows/2);
相关文章:
- 来自colPivHouseholderQr().solve的拟合相关性
- 提升区域设置规范化带状字符,但不规范化重音
- 通过规范化 // 函数来调整数组
- 获取处理器相关性(linux)时出现问题
- 在线程退出之前,线程分配的内存块是否与线程本身具有相同的相关性?
- 在早期的 C 和 C++ 编译器中,手动位移位与乘法和除法的相关性如何?
- 如何有效地规范化向量C++
- Qt 与 QML 语言的相关性
- 尝试进行一些规范化并不断出现错误
- Visual MSVC C++ 17 获取词汇规范化路径
- 在 OpenCV 上设置线程相关性
- 无法捕获模板规范化方法引发的异常
- 在规范化 3d 向量时,在调用 sqrt 之前检查可以节省多少
- Opencv Sobel 算子是否计算相关性
- 无效指针的相关性
- 我如何表现出一个正常的双重双重,而不是科学规范化
- 与浮点转换之间的规范化整数
- 如何在 CImg 中更改显示规范化设置
- 模板化类的成员函数的规范化不起作用
- 如何使用OpenCV的规范化相关性?