When using findCirclesGrid in python it seems that the ordering of the found circles is inverted. My found circles are currently ordered:
- row wise: bottom to top
- column wise: right to left
According to the documentation (at least how I interpret it) I expected it to be the other way around:
- row wise: top to bottom
- column wise: left to right
Several months ago I used this function in c++ and it seemed to behave in the manner as I expected (top to bottom, left to right).
Am I doing something wrong / interpreting the documentation incorrectly or is this a bug that should be reported?
Below a minimal working example which works on the attached bitmap.
edit: image did not get attached. Posted the image here http://imgur.com/a/ROVss
#!/usr/bin/python
import cv2
import numpy as np
img = cv2.imread('circ_min.bmp', 0)
shape = (5, 8)
blobPar = cv2.SimpleBlobDetector_Params()
blobPar.minArea = 1e4
blobPar.maxArea = 1e5
blobPar.minDistBetweenBlobs = 200
blobDet = cv2.SimpleBlobDetector_create(blobPar)
[found, cc] = cv2.findCirclesGrid(img, shape, None, flags=cv2.CALIB_CB_SYMMETRIC_GRID+cv2.CALIB_CB_CLUSTERING, blobDetector=blobDet)
cv2.namedWindow('src', cv2.WINDOW_NORMAL)
img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)
if found:
print(cc)
for i in cc:
cv2.circle(img, tuple(i[0]), 10, (0, 0, 255), -1)
cv2.imshow('src', img)
cv2.waitKey(0)