solvePnPRansac inlier array how to access

I am running solvePnPRansac fx in my program and I don’t know how to access inliers in the function:

Mat inliers;
	solvePnPRansac(model_points, image_points, K, distCoeffs, rvec, tvec, false, 100, 8, 100, inliers, SOLVEPNP_ITERATIVE);
	std::cout << inliers.rows;

Output:
4
Inliers[0;
1;
2;
3]
I understand that the row count = number of included points which would be correct in my case. Can the array outliers be individually accessed to find information on the inlier points by accessing array elements?

can it be, your question is slightly backwards ?

any point index NOT showing up in the inliers array is an outlier. ex:

points:  [0,1,2,3,4,5,6,7,8,9]
inliers: [1,3,5,7,9]
outliers:[0,2,4,6,8]
vector<int> orig(10);
iota(orig.begin(), orig.end(), 0);

vector<int> inliers {2,3,5,6};
vector<int> outliers;

for (int i : orig) {
  if ( find(inliers.begin(), inliers.end(), i) == inliers.end() )
    outliers.push_back(i);
}

for (int i : outliers) cout << i << " " ;
1 Like

Ok, these seem to be lists of indices of inliers and outliers. Is there any way to access which coordinate points belong to each list? Sorry if this is too basic of a question.

it’s an index into model_points and image_points

1 Like