hey guys, im trying to use opencv's cv.findChessboardCorners, cv.findHomography and cv.warpPerspective to find a chessboard in my video feed and display it with the original perspective. My problem is that the result is sometimes inverted. the chessboard is displayed correctly and the perspective is also correct, but the homography is upside down (you can see this in the 2. image, the color of the drawn keypoints are not correct) I think this is because the chessboard has no orientation, i.e its the same if i flip it.But i don't know how to fix that since it seems inherent for a chessboard. Is it possible to set the orientation of the warpedPerspective, so that its always "one way"? What can i do to make the homography always register in one direction?
Here is a part of the code i wrote:
# checkerboard is a uint8 array that i created, corner_count is the tuple with patternSize
_, self.cb_corners = cv.findChessboardCorners(checkerboard, corner_count)
found_board, corners = cv.findChessboardCorners(
image=frame,
patternSize=self.corner_count,
flags=cv.CALIB_CB_FAST_CHECK +
cv.CALIB_CB_NORMALIZE_IMAGE +
cv.CALIB_CB_ADAPTIVE_THRESH)
if found_board:
retval, mask = cv.findHomography(self.cb_corners, corners)
dst = cv.warpPerspective(frame, self.homography, (1920, 1080))
cv.imshow("dst", dst)