I made a stabilizer for videos and now I'm trying to compare my algorithm with others, so I wanted to implement the sift and pass the keypoints to the optical flow algorithm.
sift = cv2.xfeatures2d.SIFT_create()
then
frame.features = sift.detect(frame_img_gray,None)
new_features, _, _ = cv2.calcOpticalFlowPyrLK(prev_frame_img, frame_img, prev_frame.features, None, **lk_params)
new_features_for_validation, _, _ = cv2.calcOpticalFlowPyrLK(frame_img, prev_frame_img, new_features, None,**lk_params)
So I get this message from the compiler:
new_features, _, _ = cv2.calcOpticalFlowPyrLK(prev_frame_img, frame_img, prev_frame.features, None, **lk_params)
TypeError: prevPts is not a numpy array, neither a scalar
You can manually reshape SIFT output to be suitable for cv2.calcOpticalFlowPyrLK: