Is triangulatePoints outputing rubish ?
Hi opencv-answers,
I'm trying to use the triangulatePoints functions. However I'm pretty sure it is outputing something wrong. I use some keypoints and triangulate with a method of my own and the opencv function.
Keypoints image 1 / keypoints image 2 / Triangulation own method / Triangulation opencv
351 38 / 365 38 / 7.59634 -20.9415 100.894 / 175.801 225.384 0.897723
347 39 / 362 39 / 6.47411 -18.8165 91.1208 / 210.412 1339.99 5.8723
494 41 / 509 42 / 20.8173 -18.7071 91.7764 / 72.3976 95.5555 0.373354
346 44 / 361 44 / 6.3747 -18.3255 91.0807 / 1920.27 11915.5 52.2264
315 45 / 329 45 / 3.73327 -20.1286 100.571 / 477.627 488.255 2.05914
348 47 / 363 47 / 6.56749 -18.0348 91.0758 / 34.7008 204.819 0.905707
439 47 / 454 47 / 15.5334 -18.2436 92.1344 / 124.85 147.942 0.645297
295 55 / 309 55 / 1.59797 -19.0309 100.404 / 240.789 1329.81 5.88098
482 55 / 496 55 / 22.0522 -19.5136 102.958 / 82.6816 117.328 0.448776
420 59 / 435 59 / 13.6233 -17.0046 91.7702 / 245.919 1327.96 5.88577
Opencv give me a reprojection error of 186467; while my own method gives me 0.13.
For some reason I still want to use the opencv function. Is it bugged, or is there a special way to handle it ? Here is how I call it :
Matx34d P1;
Matx34d P2;
vector<point2f> pts1;
vector<point2f> pts2;
Mat hpts(4, pts1.size(), CV_32F);
Mat pts(3, pts1.size(), CV_32F);
triangulatePoints (P1, P2, Mat(pts1).reshape(1, 2), Mat(pts2).reshape(1, 2), hpts);
I'm using opencv-trunk.
Best regards,
Guido
I think changing the input and output matrices to CV_64 should resolve the issue and make the output more sensible.
I do agree that this could be due to an overflow. However; changing point2f to point2d and CV_32F to CV_64F gives a lot of points at infinity and a reprojection error of NaN.
Has any one found the reason and/or a solution with opencv methods? I think i have a similar problem.