你如何获得cv :: keypoint的x和y坐标和大小?(How do you get x&y coordinates and size of a cv::keypoint? I keep gett

编程入门 行业动态 更新时间:2024-10-28 21:19:07
你如何获得cv :: keypoint的x和y坐标和大小?(How do you get x&y coordinates and size of a cv::keypoint? I keep getting a segfault)

我已经遍及各种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.

更多推荐

本文发布于:2023-07-14 23:50:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1108392.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:坐标   如何获得   大小   cv   segfault

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!