How to correctly use cv::triangulatePoints()

后端 未结 5 2114
清歌不尽
清歌不尽 2020-11-29 20:45

I am trying to triangulate some points with OpenCV and I found this cv::triangulatePoints() function. The problem is that there is almost no documentation or ex

5条回答
  •  甜味超标
    2020-11-29 21:17

    Thanks to Ander Biguri! His answer helped me a lot. But I always prefer the alternative with std::vector, I edited his solution to this:

    std::vector cam0pnts;
    std::vector cam1pnts;
    // You fill them, both with the same size...
    
    // You can pick any of the following 2 (your choice)
    // cv::Mat pnts3D(1,cam0pnts.size(),CV_64FC4);
    cv::Mat pnts3D(4,cam0pnts.size(),CV_64F);
    
    cv::triangulatePoints(cam0,cam1,cam0pnts,cam1pnts,pnts3D);
    

    So you just need to do emplace_back in the points. Main advantage: you do not need to know the size N before start filling them. Unfortunately, there is no cv::Point4f, so pnts3D must be a cv::Mat...

提交回复
热议问题