Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

What is the correct way of using the cv2.correctMatches in Python

I am trying to pass the corresponding image coordinates to the function and throws an error.

cv2.error: D:\OpenCV_3\opencv_8-18-16\modules\calib3d\src\triangulate.cpp:202: error: (-209) The point-matrices must have one row, and an equal number of columns in function cvCorrectMatches

I am passing some SHI-TOMASI features (cv2.goodFeaturetoTrack) and matching them with the KLT tracker ( cv2.calcOpticalFlowPyrLK).

This is the code producing the exception.

p1, st, err = cv2.calcOpticalFlowPyrLK(old_gray, frame_gray, p0, None, **lk_params)

# Select good points
good_new = p1[st==1]
good_old = p0[st==1]

arrayF = cv2.findFundamentalMat(good_new, good_old, cv2.FM_RANSAC)
F = arrayF[0]
better_new, better_old = cv2.correctMatches(F, good_new, good_old)