Ask Your Question
0

fixed points in findHomography

asked 2019-09-12 07:55:47 -0600

fogx gravatar image

updated 2019-09-12 08:35:30 -0600

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.

Why is this happening? 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? (i can assume that its never actually going to be upside down in the actual camera feed)

here the orientation is correct and the kp match here the kp are inverted

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)
edit retag flag offensive close merge delete

Comments

Add an Aruco marker somewhere, and use that to determine orientation, or use a Charuco claibration target (instead of the plain chessboard) so the orientation is baked in from the beginning.

swebb_denver gravatar imageswebb_denver ( 2019-09-12 11:14:07 -0600 )edit
1

You have to use an asymmetric chessboard pattern like this one.

Eduardo gravatar imageEduardo ( 2019-09-12 14:43:09 -0600 )edit

@swebb_denver thanks for your answer! how can i combine the aruco marker detection with the cv.findChessboardCorners method to pass them into findHomography together? Or do i do that separately and then detect the arcuro pose and flip my homography accordingly? If there's a good way to combine the two then that is probably the simplest method?

Otherwise the charcuco method looks very promising.

fogx gravatar imagefogx ( 2019-09-12 15:06:23 -0600 )edit

@Eduardo thanks for your reply! That would definitely be the simplest way to fix my problem! I read in the documentation that the border is necessary to segment the black squares properly though. Did you have any issues with this before? Will try this along with the aruco and charuco if there is no border and the background is dark, the outer black squares cannot be segmented properly

fogx gravatar imagefogx ( 2019-09-12 15:08:46 -0600 )edit

White borders is a must. The asymmetric chessboard is the simplest solution.

Witek gravatar imageWitek ( 2019-09-12 15:56:13 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-09-21 11:35:40 -0600

fogx gravatar image

I solved this issue by using a ChAruco board as recommended in the comments. By calling interpolate once some aruco markers are detected, it detects all the corners. Then calling interpolate on the "base" image gives the set of corners needed to calculate the homography

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-09-12 07:55:47 -0600

Seen: 859 times

Last updated: Sep 21 '19