Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何使用OpenCV';s归一化相关性?_C++_Opencv - Fatal编程技术网

C++ 如何使用OpenCV';s归一化相关性?

C++ 如何使用OpenCV';s归一化相关性?,c++,opencv,C++,Opencv,如何使用OpenCV的标准化相关性?有人能提供一个代码示例吗 我的问题: 我有一个螺钉头图像,需要找到螺钉的中心。所以我在考虑使用OpenCV相关性,这是个好主意吗 您可以在下面的链接下找到示例图像: 请为我提供一个OpenCV中的相关代码示例。它是如何使用的?相关函数的输出是什么?相关函数是否提供螺钉位置?我想您正在寻找cv::matchTemplate函数: cv::Mat image; // Your input image cv::Mat templ; // Your templa

如何使用OpenCV的标准化相关性?有人能提供一个代码示例吗

我的问题: 我有一个螺钉头图像,需要找到螺钉的中心。所以我在考虑使用OpenCV相关性,这是个好主意吗

您可以在下面的链接下找到示例图像:


请为我提供一个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);