AlgoManiac
AlgoManiac

Reputation: 89

Finding corners of grid and do homography mapping

enter image description here

Hi guys, I would want to find the corners of this calibration card, to enable scaling and geometric calibration. The image above is the grid I am referring to. Shown is the full image, and I want the corners detected for the black and white grid. enter image description here

However, when I try to run

gray = cv2.cvtColor(image_cal, cv2.COLOR_BGR2GRAY) #image_cal is the image to be calibrated
cv2_imshow(gray)
retval, corners = cv2.findChessboardCorners(gray, (3, 4))

The retval returns false, meaning no chessboard is detected. I have tried different pictures but it seems they all cannot be detected.

Then I turn to Harrison Corner Detection,

gray = np.float32(gray)

# bi = cv2.bilateralFilter(gray, 5, 75, 75)
# blurred = cv2.filter2D(gray,-1,kernel)

dst = cv2.cornerHarris(gray,2,3,0.04)
dst = cv2.dilate(dst, None)
image_cal[dst>0.01*dst.max()]=[0,0,255]
cv2_imshow(image_cal)

enter image description here

Which gives me many corners, but I cannot accurately just narrow down to only the black and white grid corners.

Also, there is no guarantee the next image to be fed will still have the black and white grid in the same position so I cannot use some location boundaries to limit the search.

Eventually I would want to know the coordinates of the corners and their corresponding mapped coordinates (such that the target coordinates are properly spaced in distance according to the grid e.g. adjacent vertical or horizontal corners are 1cm apart, without distortion), and feed into a findHomography function of opencv.

Appreciate any help!

Upvotes: 0

Views: 176

Answers (0)

Related Questions