
我的问题:
我有一个螺丝头图像,需要找到螺丝的中心.所以我在考虑使用OpenCV相关性,这是一个好主意吗?
您可以在以下链接下找到示例图片:
http://imageshack.us/photo/my-images/685/screw1.png/
请在OpenCV中向我提供相关的代码示例.怎么用?相关函数的输出是什么?相关函数是否会提供螺钉位置?
解决方法 我想你正在寻找cv :: matchTemplate函数:cv::Mat image; // Your input imagecv::Mat templ; // Your template image of the screw cv::Mat result; // Result correlation will be placed here// Do template matching across whole imagecv::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);总结
以上是内存溢出为你收集整理的c – 如何使用OpenCV的规范化关联?全部内容,希望文章能够帮你解决c – 如何使用OpenCV的规范化关联?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)