Dear all,
I have problems with the function findCirclesGrid(). I took pictures of a grid of points from various positions, but for some pictures, it doesn't find the grid (return false). I use a blob detector with custom parameters and the blobs are correctly detected (blue circles).
The code I use:
img = cv2.imread(fname)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
gray = ~gray
# Define blob detector
params = cv2.SimpleBlobDetector_Params()
params.filterByArea = True
params.filterByCircularity = True
params.filterByConvexity = False
params.filterByInertia = True
params.filterByColor = False
params.minArea = 200
params.maxArea = 8000
params.minCircularity = 0.3
params.minInertiaRatio = 0.01
params.minRepeatability = 6
params.minDistBetweenBlobs = 1
detector = cv2.SimpleBlobDetector_create(params)
keyPoints = detector.detect(gray)
for i in range(len(keyPoints)):
keypoint = keyPoints[i]
x = int(keypoint.pt[0])
y = int(keypoint.pt[1])
s = keypoint.size
r = int(math.floor(s / 2))
cv2.circle(img, (x, y), r, (256, 200, 0), 3)
ret, corners = cv2.findCirclesGrid(gray, (2, 7), flags=(cv2.CALIB_CB_ASYMMETRIC_GRID + cv2.CALIB_CB_CLUSTERING), blobDetector=detector)
Picture of the grid:
Same picture, with blobs detected but grid not found:
Another image, grid detected:
I use OpenCV 4.0
Any suggestions?
Thanks!