硬件連接
1、Openmv端
這里OpenMV端僅作為數據的發送端,所以只需要共地,以及OpenMV的TX(P4)與開發板的RX端連接即可。
2、STM32端
將開發板連接STM芯片RX端與轉串口TX端的跳帽取下,再將OpenMV的TX端(P4)與STM的RX連接。如果使用USB轉TTL則將TTL的RX端與STM的TX端連接,STM的RX端與OpenMV的TX端(P4)連接,然后共地,這樣就可以在串口調試助手中查看數據的傳輸情況了。
3.代碼
3.1、OpenMV端
# Blob Detection and uart transport
import sensor, image, time, math, pyb
from pyb import UART
import json
import ustruct
# For color tracking to work really well you should ideally be in a very, very,
# very, controlled enviroment where the lighting is constant...A
yellow_threshold = (8, 22, -60, -3, 127, -128)
# You may need to tweak the above settings for tracking green things...
# Select an area in the Framebuffer to copy the color settings.sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA) #設置圖像大小QVGA大小為320*240,所以中心坐標應該是(160,120)
sensor.skip_frames(time = 2000)
sensor.set_auto_gain(False) # must be turned off for color tracking
sensor.set_auto_whitebal(False) # must be turned off for color tracking
red_threshold_01=(66, 31, -58, -24, 127, -128)
clock = time.clock()uart = UART(3, 115200)
uart.init(115200, bits=8, parity=None, stop=1) # OpenMV端初始化與STM端配置一樣即可。#**************************傳輸數據的函數******