logo

如何将识别的坐标,逐个输出?

2022-05-31 10:21
K
_2nc3

如识别圆,将c.x的值单独赋给一个变量

2022-05-31 18:36
I
网红小智智 星瞳科技

https://book.openmv.cc/example/09-Feature-Detection/find-circles.html

打印c.x()

import sensor, image, time

sensor.reset()
sensor.set_pixformat(sensor.RGB565) # 灰度更快
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()

while(True):
    clock.tick()

    #lens_corr(1.8)畸变矫正
    img = sensor.snapshot().lens_corr(1.8)

    for c in img.find_circles(threshold = 3500, x_margin = 10, y_margin = 10, r_margin = 10,r_min = 2, r_max = 100, r_step = 2):
        img.draw_circle(c.x(), c.y(), c.r(), color = (255, 0, 0))
        print(c.x())

赋值c.x():

变量在哪里都可以,例子是全局变量。

import sensor, image, time

sensor.reset()
sensor.set_pixformat(sensor.RGB565) # 灰度更快
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()

圆 = 0

while(True):
    clock.tick()

    #lens_corr(1.8)畸变矫正
    img = sensor.snapshot().lens_corr(1.8)

    for c in img.find_circles(threshold = 3500, x_margin = 10, y_margin = 10, r_margin = 10,r_min = 2, r_max = 100, r_step = 2):
        img.draw_circle(c.x(), c.y(), c.r(), color = (255, 0, 0))
        圆 =c.x()
        print(圆)
2022-05-31 18:59
K
_2nc3

我的意思是将c.x内的坐标分别赋值给不同的变量,将x1,x2,x3等等单独列出来

2022-06-01 19:22
I
网红小智智 星瞳科技

`circles = img.find_circles(xxx)`

`circles` 就是一个数组

`circles[0].x()`

就是第一个圆的中心x。

`circles[1].x()`

就是第二个圆的中心x。

`circles[2].x()`

就是第三个圆的中心x。