reading here OpenCV: Camera Calibration and 3D Reconstruction
it says:
srcPoints | Coordinates of the points in the original plane, a matrix of the type CV_32FC2 or vector Point2f |
---|---|
dstPoints | Coordinates of the points in the target plane, a matrix of the type CV_32FC2 or a vector Point2f |
but when i use cv.CV_32FC2 versus cv.CV_32F as the third argument in cv.matFromArray the homography fails with an unhandled exception. there are still NaN’s in mat1
also:
…or it could be how I am forming the points1 and points2 arrays (see 2 different ways below). Neither works, but it leads me to believe I may not be formulating the points1 and points2 arrays correctly.
let points1 = [];
let points2 = [];
for (let i = 0; i < good_matches.size(); i++) {
//Option 1:
//points1.push(keypoints1.get(good_matches.get(i).queryIdx ).pt );
//points2.push(keypoints2.get(good_matches.get(i).trainIdx ).pt );
// This array elements look like this:
// {x: 190.8971710205078, y: 298.37286376953125}
//Option 2:
// This array elements look like this:
// Point {x: 190.8971710205078, y: 298.37286376953125}
points1.push( new cv.Point(keypoints1.get(good_matches.get(i).queryIdx).pt.x, keypoints1.get(good_matches.get(i).queryIdx).pt.y));
points2.push( new cv.Point(keypoints2.get(good_matches.get(i).trainIdx).pt.x, keypoints2.get(good_matches.get(i).trainIdx).pt.y));
}
//I've also tried 2 and 3 for the second argument to matFromArray() below
let mat1 = cv.matFromArray(points1.length, 2, cv.CV_32F, points1);
let mat2 = cv.matFromArray(points2.length, 2, cv.CV_32F, points2);
console.log("mat1: ", mat1, "mat2: ", mat2);
let h = cv.findHomography(mat1, mat2, cv.RANSAC);