由于时间以及资金问题,我采用了将openmv直接通过蓝牙模块传输至电脑PC端以查看其串口输出数据,但串口调试助手的显示数据与我所输出的数据不符。示波器显示有数据输出。


openmv代码:
# Untitled - By: 小柱 - 周三 4月 17 2019
import sensor, image, time
from pyb import UART
import json
threshold = [(37, 67, 45, 84, 4, 68), #red
(34, 67, -55, -22, 2, 41), #green
(25, 67, -37, 26, -63, -26)] #blue
#设置红色的阈值,括号里面的数值分别是L A B 的最大值和最小值(minL, maxL, minA,
# maxA, minB, maxB),LAB的值在图像左侧三个坐标图中选取。如果是灰度图,则只需
#设置(min, max)两个数字即可。
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000 )
sensor.set_auto_whitebal(False)
#关闭白平衡。白平衡是默认开启的,在颜色识别中,需要关闭白平衡。
clock = time.clock()
uart = UART(3, 115200)
uart.init(115200, bits=8, parity=None, stop=1) #8位数据位,无校验位,1位停止位、
while(True):
clock.tick()
img = sensor.snapshot()
blob = img.find_blobs(threshold, area_threshold=300)
if blob: #如果找到了目标颜色
# print(blob)
# uart.write("B3 B3 ") #一帧数据的帧头
FH = bytearray([0xb3,0xb3])
uart.write(FH)
for b in blob:
#迭代找到的目标颜色区域
img.draw_rectangle(b[0:4]) # rect
img.draw_cross(b[5], b[6]) # cx, cy
x = b.cx()
y = b.cy()
print(x, y, end = ',')
data = bytearray([x,y])
uart.write(data)
#uart.write("%x %x \r"%(x,y)) #以16进制的格式输出,(16进制不能这样输出啊,浪费了我两天的时间)
#img.draw_circle((50, 50, 30), color = (250, 0, 0))
print(clock.fps())中间环节太多,我也不知道哪里的问题。
https://singtown.com/learn/50235/