0

少年、助けが必要ですか!

検出されたキーポイントを反復処理して、各キーポイントの x、y、およびサイズ フィールドにアクセスする必要があります。私が使用しているコードは、ほとんどすべてチュートリアルからコピーされています。

これは、私が問題を抱えているコードのセクションです。

// 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);

そして私が得る出力。

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

私は12のキーポイントを取得します。imshow は正しいように見え、12 個のキーポイントが表示されます。しかし、最初のキーポイントの cout を見ると、x と y の値はソフト NAN です。最初のサイズが正しいです。次の 11 個の x、y、およびサイズの値はすべて正しいです。

最初のキーポイント x と y の値が NAN なのはなぜですか? おそらく間違ってアクセスしていますが、試したすべての結果が同じです。

助けてくれてありがとう。バリー。

4

0 に答える 0