我和Features2D +單應運行代碼找到一個已知對象的教程,和我得到這個
OpenCV Error: Assertion failed (npoints >= 0 && points2.checkVector(2) == npoint
s && points1.type() == points2.type()) in unknown function, file c:\Users\vp\wor
k\ocv\opencv\modules\calib3d\src\fundam.cpp, line 1062
運行錯誤。調試后,我發現程序崩潰在findHomography函數。
Unhandled exception at 0x760ab727 in OpenCVTemplateMatch.exe: Microsoft C++ exception: cv::Exception at memory location 0x0029eb3c..
在基於OpenCV的介紹,在“CV章說, 當前或未來的OpenCV外部可以與STL或其他庫沖突。在這種情況下,使用明確的規范來解決沖突: 我改變了我的代碼隨處可見明確的規范,但問題並沒有解決。如果可以的話 CodeGo.net,請在這個問題上,還是說這函數做的事情findHomography,並且不死機的程序。 這是我的代碼
1. 今天我碰到這個例子代碼中的問題。@數學咖啡是正確的沒有特征提取,OBJ和場景是空的。我更換了測試圖片和它的工作。從textures樣式圖像您不能提取SURF特征。 另一種方式是降低minHessianve.g。 `詮釋minHessian=20; FAST的特征檢測器通過改變幾行:
//-- Step 1: Detect the keypoints using SURF Detector
int minHessian = 15;
FastFeatureDetector detector( minHessian );
2. 我有問題,我也跟着解決了MMH。只是寫cv::Mat H = cv::findHomography( cv::Mat(obj), cv::Mat(scene), CV_RANSAC ); cv::perspectiveTransform( cv::Mat(obj_corners), cv::Mat(scene_corners), H);解決了這個問題。
3. 實際的答案是內
npoints >= 0 && points2.checkVector(2) == npoints && points1.type() == points2.type()
人類可讀的翻譯,你必須實現這些assertions: 您的輸入必須有點的正數(在實踐中findHomography需要4個或更多個點)。 你的“對象”和點“楊繼明'列表必須具有的點數。 你的“對象”和點“:楊繼明,名單必須點的類型。
4. 你將不得不轉換點,太你將它傳遞給findHomography()和perspectiveTransfor前
5. 更可能的是,問題就在這里:
if( matches[i].distance < 3*min_dist)
strict的不等式是不是你想要的。如果min_dist == 0 CodeGo.net,一個很不錯的,你會不顧一切零距離點。替換為:
if( matches[i].distance <= 3*min_dist)
你應該看到的匹配以及良好的圖像效果。 優雅地退出,我也想補充,例如:
if (good_matches.size() == 0)
{
std::cout<< " --(!) No good matches found " << std::endl; return -2;
}
