Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

cv::triangulatePoints give strange results

$
0
0
Hi,
I have images from two cameras (left and right). First I calibrate cameras and I get cameras matrices, distortion coefficients and projection matrices.
On images I detect marker and save it positions on left and right image. Next I use cv::triangulatePoints but I get really strange result (I use other library that also allows to get that 3D coords and it shows more likely results). Here is my code: int size0 = m_history.getSize(0); int size1 = m_history.getSize(1); if(size0 != size1) { setInfo(tr("Cannot calculate triangulation: number of marker positions is different on left and right camera")); return false; } if(size0 <= 0) { setInfo(tr("No marker postion saved. Cannot calc triangulation.")); return false; } cv::Mat pointsMat1(2, 1, CV_64F); cv::Mat pointsMat2(2, 1, CV_64F); for(int i = 0; i < size0; i++) { cv::Point pt1 = m_history.getOriginalPoint(0, i); cv::Point pt2 = m_history.getOriginalPoint(1, i); pointsMat1.at(0,0) = pt1.y; pointsMat1.at(1,0) = pt1.y; pointsMat2.at(0,0) = pt2.x; pointsMat2.at(1,0) = pt2.y; cv::Mat pnts3D(4, 1, CV_32F); cv::triangulatePoints(m_projectionMat1, m_projectionMat2, pointsMat1, pointsMat2, pnts3D); CvPoint3D64f point3D; point3D.x = pnts3D.at(0, 0); point3D.y = pnts3D.at(1, 0); point3D.z = pnts3D.at(2, 0); point3D.x = point3D.x/pnts3D.at(3, 0); point3D.y = point3D.y/pnts3D.at(3, 0); point3D.z = point3D.z/pnts3D.at(3, 0); m_history.addTriangulatedPoint(point3D); } Where I do mistake? Results from triangulation: 3D_X 3D_Y 3D_Z -0.143595 -4.22246 -24.185 2.04136 -0.614643 -15.7484 3.16721 1.25578 -11.3336 3.8125 2.31469 -8.88105 4.22874 3.00726 -7.24257 3.98013 2.59997 -8.18345 3.43011 1.68647 -10.3386 2.53443 0.215475 -13.7499 0.805428 -2.65543 -20.5206 -0.187007 -5.49902 -31.4968 And from other library (it seems quite correct): 3D_X 3D_Y 3D_Z 8.33399 4.74962 62.6119 8.33243 -1.62743 60.8669 8.40008 -8.43666 59.5643 8.47287 -15.1735 58.3184 8.52143 -21.964 57.0896 8.4673 -17.6672 57.6249 8.31039 -10.9452 58.6376 8.39497 -4.27203 60.6766 8.37444 2.56077 62.3287 5.41351 4.73769 62.7424

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>