openMV不能正常脱机工作,如何解决?急!
-
各位大咖,openMV未能正常脱机工作,不知是哪里出了错,想请教大家。大致情况是:
1、如果我单单让openmv通过串口发消息到arduino板上,不进行图像识别的话,发消息在脱机状态下是可以实现的,它会一直发送;
2、加上图像识别的代码后,不脱机连接电脑的情况下,是能识别以及发送消息的;
3、但一旦脱机好像openmv就不工作了,也不知是不会去识别了还是识别了没发消息;
4、程序我事先都已经是烧到openmv板以及SD卡里了。
5、供电正常。
——————————接线图——————————————————————————
——————————openMV IDE程序——————————————————————————import time, sensor, image, time, pyb from image import SEARCH_EX, SEARCH_DS from pyb import UART sensor.reset() sensor.set_contrast(1) sensor.set_gainceiling(16) sensor.set_framesize(sensor.QQVGA) sensor.set_pixformat(sensor.GRAYSCALE) template1 = image.Image("/J.pgm") template2 = image.Image("/Js.pgm") template3 = image.Image("/Jx.pgm") template4 = image.Image("/Jz.pgm") template5 = image.Image("/Jy.pgm") uart = UART(3, 9600) clock = time.clock() while (True): clock.tick() img = sensor.snapshot() r1 = img.find_template(template1, 0.70, step=4, search=SEARCH_EX) if r1: img.draw_rectangle(r1) uart.write("1\r") time.sleep(1000) r2 = img.find_template(template2, 0.70, step=4, search=SEARCH_EX) if r2: img.draw_rectangle(r2) uart.write("1\r") time.sleep(1000) r3 = img.find_template(template3, 0.70, step=4, search=SEARCH_EX) if r3: img.draw_rectangle(r3) uart.write("1\r") time.sleep(1000) r4 = img.find_template(template4, 0.70, step=4, search=SEARCH_EX) if r4: img.draw_rectangle(r4) uart.write("1\r") time.sleep(1000) r5 = img.find_template(template5, 0.70, step=4, search=SEARCH_EX) if r5: img.draw_rectangle(r5) uart.write("1\r") time.sleep(1000) print(clock.fps())
——————————arudino程序——————————————————————————
#include <SoftwareSerial.h> SoftwareSerial softSerial(10, 11); // RX, TX void setup() { // put your setup code here, to run once: softSerial.begin(9600); Serial.begin(9600); } void loop() { int a1=1; while (a1=1){ while (softSerial.available()>0) { char rec=(char)softSerial.read(); Serial.print(rec); delay(5); } } }
谢谢大家~
-
-
@kidswong999 格式化试过了,没有用。。。。
-
https://book.openmv.cc/example/02-Board-Control/led-control.html
测试闪LED的程序,如果不行,就寄回维修。