[英]Blob ID tagging for OpenCV python
I am currently making a python code for people headcounting with direction. 我目前正在制作一个python代码,供人们指导方向。 I have used 'moments'method to gather the coordinates and eventually when it crosses a certain line then the counter increments.But, this method is proving to be very inefficient. 我使用'moment'方法来收集坐标,最后当它越过某一条线时,计数器会递增。但是,这种方法被证明是非常低效的。 My question regarding the blob detection are: 我关于斑点检测的问题是:
Thanks in advance. 提前致谢。
For blob detection you can use SimpleBlobDetector from OpenCV: 对于blob检测,您可以使用OpenCV中的SimpleBlobDetector:
# Setup SimpleBlobDetector parameters.
params = cv2.SimpleBlobDetector_Params()
# Filter by Area.
params.filterByArea = True
params.minArea = 100
params.maxArea =100000
# Don't filter by Circularity
params.filterByCircularity = False
# Don't filter by Convexity
params.filterByConvexity = False
# Don't filter by Inertia
params.filterByInertia = False
# Create a detector with the parameters
detector = cv2.SimpleBlobDetector_create(params)
# Detect blobs.
keypoints = detector.detect(imthresh)
# Draw detected blobs as red circles.
# cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS ensures
# the size of the circle corresponds to the size of blob
im_with_keypoints = cv2.drawKeypoints(imthresh, keypoints, np.array([]), (0,0,255), cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
For labelling, using scipy.ndimage.label is usually a better idea: 对于标签,使用scipy.ndimage.label通常是一个更好的主意:
label_im, nb_labels = ndimage.label(mask)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.