Ask Your Question

solvePnPRansac, getting inliers from the 2d and 3d points?

asked 2018-07-28 16:19:39 -0500

antithing gravatar image

I am running solvePnPRansac, and after it runs, i need to get the inlier points from the input matrices. The inlier Mat seems to be a list of ints, rather than the 0 or 1 values that i would expect. What is the best way to run this:

    cv::Mat points3D_t0; // Mat of 3d points
    std::vector<Point2f> points_left_t1; // vector of 2d features

cv::solvePnPRansac(points3D_t0, points_left_t1, intrinsic_matrix, distCoeffs, rvec, tvec,
    useExtrinsicGuess, iterationsCount, reprojectionError, confidence,
    inliers, flags);

and then fill a std::vector<Point2f> and a std::vector<Point3f> with the matched inlier points that were used in the PnP solve?

Thank you.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2018-07-29 12:08:39 -0500

antithing gravatar image

Ah, got it:

for (int i = 0; i < inliers.rows; i++)
        int index =<int>(i, 0);
        cv::Point3f inlier3d = points3D_t0[index];
        cv::Point2f inlier2d = points_left_t1[index];

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-07-28 16:19:39 -0500

Seen: 119 times

Last updated: Jul 29 '18