Advertisement
jack06215

[OpenCV] draw epipolar line

Jul 8th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. void drawEpipolarLines(cv::Mat& image_out, // output image
  2.     cv::Mat& image1, // image 1
  3.     cv::Mat& image2, // image 2
  4.     std::vector<cv::Vec3f> lines1,
  5.     std::vector<cv::Point2f>& points1, // keypoints 1
  6.     std::vector<cv::Point2f>& points2) // keypoints 2)
  7. {
  8.     // for all epipolar lines
  9.     for (std::vector<cv::Vec3f>::const_iterator it = lines1.begin(); it != lines1.end(); ++it)
  10.     {
  11.         // Draw the line between first and last column
  12.         cv::line(image_out,
  13.             cv::Point(0, -(*it)[2] / (*it)[1]),
  14.             cv::Point(image2.cols, -((*it)[2] +
  15.             (*it)[0] * image2.cols) / (*it)[1]),
  16.             cv::Scalar(randomFrom(0, 255), randomFrom(0, 255), randomFrom(0, 255)));
  17.     }
  18.  
  19.     for (std::vector<cv::Point2f>::const_iterator it = points1.begin(); it != points1.end(); it++)
  20.     {
  21.         cv::circle(image1, (*it), 5, cv::Scalar(randomFrom(0, 255), randomFrom(0, 255), randomFrom(0, 255)), -1, 8, 0);
  22.     }
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement