C++ opencv关键点-1.IND
孩子,我需要帮助吗 我需要遍历检测到的关键点,访问每个关键点的x、y和size字段。我使用的代码几乎都是从教程中复制的 下面是我遇到问题的代码部分C++ opencv关键点-1.IND,c++,opencv,keypoint,C++,Opencv,Keypoint,孩子,我需要帮助吗 我需要遍历检测到的关键点,访问每个关键点的x、y和size字段。我使用的代码几乎都是从教程中复制的 下面是我遇到问题的代码部分 // Draw detected blobs as red circles. Mat im_with_keypoints; drawKeypoints( im, keypoints, im_with_keypoints, Scalar(0,0,255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS ); // Sh
// Draw detected blobs as red circles.
Mat im_with_keypoints;
drawKeypoints( im, keypoints, im_with_keypoints, Scalar(0,0,255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS );
// Show blobs
imshow("keypoints", im_with_keypoints );
vector<KeyPoint>::const_iterator it = keypoints.begin(), end = keypoints.end();
cout << "num keypts: " << keypoints.size() << "\n";
for( ; it != end; ++it ) {
cout << " kpt x " << it->pt.x << ", y " << it->pt.y << ", size " << it->size << "\n";
}
waitKey(0);
我有12个关键点。imshow看起来正确,显示了12个关键点。但是,看看第一个关键点的cout,x和y值是软NaN。第一个尺寸是正确的。接下来的11 x、y和size值都是正确的
为什么第一个关键点x和y值为NaN?我可能没有正确地访问它们,但我尝试过的所有方法都会得到相同的结果
谢谢你的帮助。
巴里。如果您试图在循环开始之前访问第一个关键点,那么您可能会发现问题所在。我正在使用SimpleBlobDetector。我正在设置param params.filterByArea=false。这导致了错误。我设置params.filterByArea=true;params.minArea=0.1,南部消失。
num keypts: 12
kpt x -1.#IND, y -1.#IND, size 2.20732
kpt x 1232.18, y 573.16, size 2.01719
kpt x 1469.27, y 569.461, size 2.77548
kpt x 1706.66, y 566.156, size 3.7563
kpt x 1946.15, y 561.098, size 3.2482
kpt x 2189.41, y 557.673, size 3.83277
kpt x 31.4306, y 372.063, size 3.01084
kpt x 982.995, y 359.899, size 3.33982
kpt x 1218.8, y 355.892, size 3.8553
kpt x 1699.99, y 348.004, size 3.38391
kpt x 1935.74, y 122.263, size 2.75298
kpt x 2181.73, y 117.866, size 4.08995