作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我已仔细阅读此网站以寻求解释,但无济于事...希望有人知道答案。
我正在使用 simpleBlobDetector 来跟踪一些 Blob 。我想通过检测方法指定一个 mask ,但由于某种原因, mask 似乎不起作用——我的关键点显示在整个图像上。以下是我的一些代码片段:
Mat currFrame;
Mat mask;
Mat roi;
cv::Ptr<cv::FeatureDetector> blob_detector = new cv::SimpleBlobDetector(params);//custom set of params I've left out for legibility
blob_detector->create("SimpleBlob");
vector<cv::KeyPoint> myblob;
while(true)
{
captured >> currFrame; // get a new frame from camera >> is grab and retrieve in one go, note grab does not allow frame to be modified but edges can be
// do nothing if frame is empty
if(currFrame.empty())
{
break;
}
/******************** make mask***********************/
mask = Mat::zeros(currFrame.size(),CV_8U);
roi = Mat(mask,Rect(400,400,400,400));
roi = 255;
/******************** image cleanup with some filters*/
GaussianBlur(currFrame,currFrame, Size(5,5), 1.5, 1.5);
cv::medianBlur(currFrame,currFrame,3);
blob_detector->detect(fgMaskMOG,myblob,mask);//fgMaskMOG is currFrame after some filtering and background subtraction
cv::drawKeypoints(fgMaskMOG,myblob,fgMaskMOG,Scalar::all(-1), DrawMatchesFlags::DRAW_RICH_KEYPOINTS );
imshow("mogForeground", fgMaskMOG);
imshow("original", currFrame);
imshow("mask",mask);
if(waitKey(1) != -1)
break;
}
事实是,我确认我的面具是通过使用此处描述的 SurfFeatureDetector 正确制作的 (OpenCV: howto use mask parameter for feature point detection (SURF)) 如果有人能看出我的面具有什么问题,我将非常感谢您的帮助。抱歉乱码!
最佳答案
我遇到了同样的问题,找不到解决办法,所以我自己检查掩码解决了:
blob_detector->detect(img, keypoints);
std::vector<cv::KeyPoint> keypoints_in_range;
for (cv::KeyPoint &kp : keypoints)
if (mask.at<char>(kp.pt) > 0)
keypoints_in_range.push_back(kp)
关于c++ - Opencv2.4.9 SimpleBlobDetector 掩码不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24357516/
我是一名优秀的程序员,十分优秀!