I created a transform matrix using findHomography() and used warpImage() to make the change, so far so good.
But I found a point on the original image. I want to know the equivalent coordinate on the warped image. I thought it would be as simple as multiplying by the inverse transform matrix
[y2] = H**-1 * [[x1][y1]]
So I get the coords of the contour center in a matrix and then transform:
M = cv2.moments(cB)
coord = [[int(M[“m10”] / M[“m00”])],[int(M[“m01”] / M[“m00”])],]
warpedCoord = np.matmul(np.linalg.inv(h), coord)
warpedCoord = warpedCoord *(1/warpedCoord) #EDIT: this line was missing before
cv2.circle(oImg,(int(warpedCoord),int(warpedCoord)), 5, (255,0,0), -1)
However the results are off:
What am I doing wrong?