openmv程序中串口3通信在openmv H7上可以用,在openmv H7 plus上就不可以是怎么回事
-
import sensor, image, time from pyb import UART,LED #from pid import PID sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QQVGA) sensor.skip_frames(time = 2000) sensor.set_auto_whitebal(False) clock = time.clock() LED(1).on() LED(2).on() LED(3).on() uart = UART(3,9600,timeout_char=1000) yellow_threshold = [(100, 58, -128, 127, 31, 127), (33, 77, -41, -69, 11, 33)] size_threshold = 2000 def find_max(blobs): max_size=0 max_blob=None for blob in blobs: if blob[2]*blob[3] > max_size: max_blob=blob max_size = blob[2]*blob[3] return max_blob #flag = 0 while(True): clock.tick() img = sensor.snapshot() blobs = img.find_blobs(yellow_threshold) max_blob = None if blobs: max_blob = find_max(blobs) img.draw_rectangle(max_blob[0:4]) img.draw_cross(max_blob[5], max_blob[6]) if max_blob: pan_error = max_blob.cx()-img.width()/2 if pan_error <0: print("左移") uart.write("$LY!") time.sleep_ms(100) if pan_error >0: print("右移") uart.write("$RY!") time.sleep_ms(100) if pan_error ==0: print("抓取") if max_blob.code()==1: uart.write("$ZC!") time.sleep_ms(400) # flag=1
-
我使用OpenMV4 和OpenMV4 Plus测试了,没有出现错误。
-
我运行也没有错误,但是和其他单片机通信,一样的程序,openmv4可以成功通信,plus不行,不清楚原因
-
已经解决了解决了