Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

how to draw epipolar line

Hello all, I'm getting an error in drawing epipolar line from fundamental matrix. Snap of my code is: cv::Mat fundamental = cv::findFundamentalMat( cv::Mat(img_corners), // points in first image cv::Mat(prevImg_corners), // points in second image CV_FM_7POINT); // 7-point method

std::vector<cv::vec3f> lines1; cv::computeCorrespondEpilines( img_corners, // image points 1, // in image 1 (can also be 2) fundamental, // F matrix lines1); // vector of epipolar lines

// for all epipolar lines

for (vector<cv::vec3f>::const_iterator it= lines1.begin(); it!= lines1.end(); ++it) {

// draw the line between first and last column

     cv::line(img,
     cv::Point(0,(*it)[2]/(*it)[1]),
     cv::Point(img.cols,((*it)[2] + (*it)[0]*img.cols)/(*it)[1]),
     cv::Scalar(255,255,255));

}

cv::imshow("Right Image Epilines (FM_7POINT)", img);

And the error is program execution is stop working after first frame. Please suggest what I'm doing wrong. Thanks

click to hide/show revision 2
None

updated 2018-01-16 11:35:12 -0600

berak gravatar image

how to draw epipolar line

Hello all, I'm getting an error in drawing epipolar line from fundamental matrix. Snap of my code is: is:

cv::Mat fundamental = cv::findFundamentalMat(
cv::Mat(img_corners), // points in first image
cv::Mat(prevImg_corners), // points in second image
CV_FM_7POINT); // 7-point method

method

std::vector<cv::vec3f> std::vector<cv::Vec3f> lines1; cv::computeCorrespondEpilines( img_corners, // image points 1, // in image 1 (can also be 2) fundamental, // F matrix lines1); // vector of epipolar lines

lines

// for all epipolar lines

lines

for (vector<cv::vec3f>::const_iterator (vector<cv::Vec3f>::const_iterator it= lines1.begin(); it!= lines1.end(); ++it) {

{

// draw the line between first and last column

column
      cv::line(img,
      cv::Point(0,(*it)[2]/(*it)[1]),
      cv::Point(img.cols,((*it)[2] + (*it)[0]*img.cols)/(*it)[1]),
      cv::Scalar(255,255,255));
}

}

cv::imshow("Right Image Epilines (FM_7POINT)", img);

img);

And the error is program execution is stop working after first frame. Please suggest what I'm doing wrong. Thanks