Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I wanted to recognize an object in an image and then replace it with another image.

i dou't think, your approach will work here (there is no "object" detection).

however, you can still warp another image (with the same size/channels !) into your scene using:

M, mask = cv2.findHomography(src_pts, dst_pts, cv2.RANSAC,5.0)
scene = cv.warpPerspective(small_img, M, (scene.shape[1], scene.shape[0]), scene)

I wanted to recognize an object in an image and then replace it with another image.

i dou't think, your approach will work here (there is no "object" detection).detection, and the matching here won't allow you to tell, if there is no such thing in the image).

however, you can still warp another image (with the same size/channels !) into your scene using:

M, mask = cv2.findHomography(src_pts, dst_pts, cv2.RANSAC,5.0)
scene = cv.warpPerspective(small_img, M, (scene.shape[1], scene.shape[0]), scene)