wall_threshold = (42, 57, -57, -38, 14, 42)
blobs = img.find_blobs([wall_threshold])
为什么会弹这个错误呢
acqs 发布的帖子
-
代码错误:TypeError: object 'int' is not a tuple or list
-
openmv连了电源以后温度上升很快(比刚用的时候烫很多),但程序还能运行,应该怎么办。
openmv连了电源以后温度上升很快(比刚用的时候烫很多),但程序还能运行,应该怎么办。
-
RE: 连电脑后,led闪绿灯后闪黄灯,摄像头拍的是白屏,芯片很烫是怎么回事。
hello world没问题,但是 img = sensor.snapshot()是一直白屏的,而且芯片很烫
-
RE: 连电脑后,led闪绿灯后闪黄灯,摄像头拍的是白屏,芯片很烫是怎么回事。
import sensor, image, time
from pid import PID
from pyb import Pin, Timer, UART
import timegnd = Pin('P0', Pin.OUT_PP)
ain1 = Pin('P1', Pin.OUT_PP)
bin1 = Pin('P2', Pin.OUT_PP)
slp = Pin('P3', Pin.OUT_PP)
gnd.low()
ain1.low()
bin1.low()
slp.high()
pwma = Pin('P7')
pwmb = Pin('P8')
tim = Timer(4, freq=1000)
ch1 = tim.channel(1, Timer.PWM, pin=pwma)
ch2 = tim.channel(2, Timer.PWM, pin=pwmb)
ch1.pulse_width_percent(0)
ch2.pulse_width_percent(0)30 -30
def run(left_speed, right_speed):if left_speed < 0: ain1.low() else: ain1.high() ch1.pulse_width_percent(abs(left_speed)) if right_speed < 0: bin1.high() else: bin1.low() ch2.pulse_width_percent(abs(right_speed))
def Uart_sevor(zu,t_s):
uart = UART(3, 9600, timeout_char=1000)
uart.init(9600, bits=8, parity=None, stop=1, timeout_char=1000)
TxBuf =bytearray([0x55,0x55,5,0x06,zu,0x01,0x00])
uart.write(TxBuf)
time.sleep(t_s*1000)sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(10)
sensor.set_auto_whitebal(False)
clock = time.clock()
green_threshold = (62, 99, 45, -28, 80, 33)
size_threshold = 5356
x_pid = PID(p=0.3, i=1, imax=100)
h_pid = PID(p=0.001, i=0.1, imax=30)
def find_max(blobs):
max_size=0
for blob in blobs:
if blob[2]*blob[3] > max_size:
max_blob=blob
max_size = blob[2]*blob[3]
return max_blob
Uart_sevor(0,1)
while(True):
clock.tick()
img = sensor.snapshot()
blobs = img.find_blobs([green_threshold])
if blobs:
max_blob = find_max(blobs)
x_error = max_blob[5]-img.width()/2
h_error = max_blob[2]*max_blob[3]-size_threshold
img.draw_rectangle(max_blob[0:4])
img.draw_cross(max_blob[5], max_blob[6])
x_output=x_pid.get_pid(x_error,1)
h_output=h_pid.get_pid(h_error,1)
a = ((-h_output-x_output))
b = ((-h_output+x_output))
print("a",a)
print("b",b)
if(-200 < h_error < 200):
run(0,0)
Uart_sevor(1,10)
break
run(a,b)
else:
run(30,-30)