openmv对物体进行色块识别,但是想脱离PC对识别过程进行录制,类似在IDE中帧缓冲区的录制效果
G
g61w
@g61w
0
声望
3
楼层
208
资料浏览
0
粉丝
0
关注
g61w 发布的帖子
-
openmv和esp32串口通信有问题?
我通过openmv和esp32进行串口通信,但是将openmv IDE的程序停止运行后,esp32依然会接收到串口数据
import sensor, image, time from pyb import UART sensor.reset() # Initialize the camera sensor. sensor.set_pixformat(sensor.RGB565) # use RGB565. sensor.set_framesize(sensor.QQVGA) # use QQVGA for speed. sensor.skip_frames(10) # Let new settings take affect. sensor.set_auto_whitebal(False) # turn this off. clock = time.clock() # Tracks FPS. roi_threshold = (55, 100, -5, 127, -25, 127) uart = UART(3, 115200) 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 while(True): clock.tick() # Track elapsed milliseconds between snapshots(). img = sensor.snapshot() # Take a picture and return the image. blobs = img.find_blobs([roi_threshold]) if blobs: max_blob=find_max(blobs) if max_blob.cx()<70: flag=0 elif max_blob.cx()>90: flag=1 else: flag=2 output_str="%d" %flag uart.write(str(flag)) img.draw_rectangle(max_blob.rect()) img.draw_cross(max_blob.cx(), max_blob.cy()) output_string="[%d,%d]" % (max_blob.cx(),max_blob.cy()) #方式1 print('you send:',output_str) else: print('not found!')
#include <ESP32Servo.h> volatile int degree; volatile int step; Servo servo_23; char flag; void setup() { Serial2.begin(115200); Serial.begin(115200); servo_23.attach(13,500,2500); } void loop() { if (Serial2.available()>0) { flag=Serial2.read(); if (flag=='1') { Serial.println(1); servo_23.write(60); } if (flag=='0') { Serial.println(0); servo_23.write(120); } if (flag=='2') { Serial.println(2); servo_23.write(90); } } }