logo

有大佬能帮个忙编个程序吗?

2019-08-14 09:39
C
ryb3

,并同时输出所识别到的颜色且优先级为黑色优先?做个程序的目的是要能巡红色线,并且同时识别黑色字母和线条,我看教程里面有关于巡线的程序和多种颜色识别的程序,还有图形识别的程序,但是不太会整合,有大神能帮帮忙吗?

C
ryb3

THRESHOLD = (62, 13, 34, 80, -61, 81)

import sensor, image, time

from pyb import LED

from pid import PID

rho_pid = PID(p=0.4, i=0)

theta_pid = PID(p=0.001, i=0)

LED(1).on()

LED(2).on()

LED(3).on()

sensor.reset()

sensor.set_vflip(True)

sensor.set_hmirror(True)

sensor.set_pixformat(sensor.RGB565)

sensor.set_framesize(sensor.QQQVGA)

sensor.skip_frames(time = 2000)

clock = time.clock()

while(True):

clock.tick()

img = sensor.snapshot().binary([THRESHOLD])

line = img.get_regression([(100,100,0,0,0,0)], robust = True)

if (line):

rho_err = abs(line.rho())-img.width()/2

if line.theta()>90:

theta_err = line.theta()-180

else:

theta_err = line.theta()

img.draw_line(line.line(), color = 127)

print(rho_err,line.magnitude(),rho_err)

pass

C
ryb3

请各位大佬帮帮忙

2019-08-14 10:01
I
网红小智智 星瞳科技

https://singtown.com/learn/50029/