我已经遍及各种cv :: KeyPoint资源,并且遵循了许多提示,到目前为止无济于事。 cv :: KeyPoint类参考
// --- BLOB DETECTION --- // // Storage for blobs vector<KeyPoint> keypoints; // Set up detector with params Ptr<SimpleBlobDetector> detector = SimpleBlobDetector::create(params); // Detect blobs detector->detect( camThresh, keypoints); // Draw keypoints drawKeypoints( camRaw, keypoints, camBlobs, Scalar(0,0,255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS );我很高兴我到目前为止工作,但我真的需要获得这些关键点的XY和大小值。 我最接近工作的最接近的建议 (见下文)抛出一个段错误。
float x = keypoints[i].pt.x;和
Point2f p = keypoints[i].pt;引导我得出同样的结果。 建议链接中的某人提到了同样的问题。 任何人都有任何提示? 谢谢!
I've been over and over various cv::KeyPoint resources and followed many tips to no avail so far. cv::KeyPoint Class Reference
// --- BLOB DETECTION --- // // Storage for blobs vector<KeyPoint> keypoints; // Set up detector with params Ptr<SimpleBlobDetector> detector = SimpleBlobDetector::create(params); // Detect blobs detector->detect( camThresh, keypoints); // Draw keypoints drawKeypoints( camRaw, keypoints, camBlobs, Scalar(0,0,255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS );I;m very glad I got this to work up until this point, but I really need to get the XY and size values of those keypoints. The closest suggestion I'd almost gotten to work (see below) throws out a segment fault.
float x = keypoints[i].pt.x;and
Point2f p = keypoints[i].pt;Lead me to the same outcome. Someone in the suggestions linked about mentioned the same problem. Any one have any tips? Thanks!
最满意答案
我发现程序崩溃的原因。 我没有检查是否有任何活跃的关键点。 因此,如果程序在摄像机视图中没有任何内容启动,则会崩溃。 它完全有效,例如:
if(keypoints.size()>0) { if((char)keyboard == 'c') { float x0 = keypoints[0].pt.x; float y0 = keypoints[0].pt.y; cout << "Point0 Xpos = " << x0 << "\n"; cout << "Point0 Ypos = " << y0 << "\n"; } }只要在程序启动时跟踪某些对象。 一旦摄像机视图中没有任何内容,应用程序就会崩溃。
I found out why the program was crashing. I was not checking for whether there even were any active keypoints at all. So,if the program starts without anything in the camera's view it crashes. It's completely valid to use, for example :
if(keypoints.size()>0) { if((char)keyboard == 'c') { float x0 = keypoints[0].pt.x; float y0 = keypoints[0].pt.y; cout << "Point0 Xpos = " << x0 << "\n"; cout << "Point0 Ypos = " << y0 << "\n"; } }As long as there are some objects being tracked when the program starts. Once nothing is in the camera's view the application crashes.
更多推荐
发布评论