检测图像中的灯光

时间:2016-06-11 18:38:18

标签: python opencv

我需要检测此图片中的灯光并计算它们的数量,但Open CV中的简单minThresholdmaxThreshold不起作用。我怎么能发现这个?

enter image description here

此代码我尝试使用

import cv2
import numpy as np;

im = cv2.imread("test.png", cv2.IMREAD_GRAYSCALE)

params = cv2.SimpleBlobDetector_Params()

params.minThreshold = 0
params.maxThreshold = 255

params.filterByArea = True
params.minArea = 1
params.maxArea = 50

params.filterByCircularity = False

params.filterByConvexity = False

params.filterByInertia = False

detector = cv2.SimpleBlobDetector(params)

keypoints = detector.detect(im)

im_with_keypoints = cv2.drawKeypoints(im,keypoints, np.array([]), (0,0,255), cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)

cv2.imshow("Keypoints", im_with_keypoints)
cv2.waitKey(0)

但它的作用很奇怪enter image description here

0 个答案:

没有答案