识别圆怎么不把不完整的圆带进来
-
img = sensor.snapshot().lens_corr(1.8) #获取图像img.binary([thresholds[color]]) #二值化
nMaxSize = 0 #最大尺寸
nCount = 0 #计数
imgSize = [0, 0]
circlePix = [0, 0, 0]
imgSize[0] = img.width()
imgSize[1] = img.height()
for cir in img.find_circles(threshold = 2500, x_margin = 10, y_margin = 10, r_margin = 10, r_min = 50, r_max = 100, r_step = 2):
if nCount == 0:
nMaxSize = cir.r()
circlePix[0] = cir.x()
circlePix[1] = cir.y()
circlePix[2] = cir.r()
nCount = nCount + 1
else :
nNowSize = cir.r()
if nMaxSize < nNowSize:
nMaxSize = nNowSize
nCount = nCount + 1
circlePix[0] = cir.x()
circlePix[1] = cir.y()
circlePix[2] = cir.r()
if nCount == -1:return False
else :
img.draw_circle(circlePix[0], circlePix[1], circlePix[2])
circlePixels[0] = circlePix[0]–imgSize[0]/2
circlePixels[1] = circlePix[1] - imgSize[1]/2
circlePixels[2] = circlePix[2]
代码是求最大圆,可是会把一些不是圆的识别进来
图上实际只是一根弯曲的线
-
可是会把一些不是圆的识别进来,怎么办?
-
另外有没有办法规定findcircle findrect等函数识别个数
-
https://docs.singtown.com/micropython/zh/latest/openmvcam/library/omv.image.html#image.find_circles
改一下threshold参数