logo

识别圆心坐标不准确

2018-08-07 14:28
X
tg3m
# Untitled - By: xrj - 周一 8月 6 2018

import sensor, image, time,pyb

sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QVGA)
sensor.set_windowing((310,240))
sensor.skip_frames(time = 2000)

clock = time.clock()
while(True):
    clock.tick()
    img = sensor.snapshot()
    high_threshold = (160, 255)                        #二值化范围
    img.gaussian(1)                                    #模糊滤波
    img.binary([high_threshold])                       #二值化
    img.erode(3)
    for c in img.find_circles(threshold = 25000, x_margin = 10, y_margin = 10, r_margin = 70,r_min = 70, r_max =100, r_step = 2):
     img.draw_circle(c.x(), c.y(), c.r(), color = (255, 0, 0))
44865ecf-72ee-443f-8f78-65a69bfec261.png

可以看到图中运行结果里圆与实际希望的圆有一段差距,这个可以修正吗

I
网红小智智 星瞳科技

多算几次,取平均值。