33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
import cv2
|
|
|
|
|
|
def find_corner_circles(im, area=(5000 / 4, 5000 * 4), color=None, convexity=0.9, circularity=0.7, inertia=None, thresholdstep=1):
|
|
assert color is None and inertia is None, "Inertia and color not implemented (easy to do though)"
|
|
params = cv2.SimpleBlobDetector_Params()
|
|
|
|
params.filterByArea = area is not None
|
|
if area is not None:
|
|
params.minArea, params.maxArea = area
|
|
|
|
params.filterByColor = color is not None
|
|
params.filterByInertia = inertia is not None
|
|
|
|
# This step should be lower than 10, preferrably as low as time allows, to avoud false negatives.
|
|
params.thresholdStep = thresholdstep
|
|
|
|
params.filterByCircularity = circularity is not None
|
|
if circularity is not None:
|
|
params.minCircularity = circularity
|
|
|
|
params.filterByConvexity = convexity is not None
|
|
if convexity is not None:
|
|
params.minConvexity = convexity
|
|
|
|
if int((cv2.__version__).split('.')[0]) < 3 :
|
|
detector = cv2.SimpleBlobDetector(params)
|
|
else:
|
|
detector = cv2.SimpleBlobDetector_create(params)
|
|
|
|
return detector.detect(im)
|
|
|