关于视觉识别后的结果通过串口发送到其他设备 要怎么做
-
Single Color RGB565 Blob Tracking Example
This example shows off single color RGB565 tracking using the OpenMV Cam.
import sensor, image, time
threshold_index = 0 # 0 for red, 1 for green, 2 for blue
Color Tracking Thresholds (L Min, L Max, A Min, A Max, B Min, B Max)
The below thresholds track in general red/green/blue things. You may wish to tune them...
thresholds = [(30, 100, 15, 127, 15, 127), # generic_red_thresholds
(30, 100, -64, -8, -32, 32), # generic_green_thresholds
(0, 30, 0, 64, -128, 0)] # generic_blue_thresholdssensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
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
clock = time.clock()Only blobs that with more pixels than "pixel_threshold" and more area than "area_threshold" are
returned by "find_blobs" below. Change "pixels_threshold" and "area_threshold" if you change the
camera resolution. "merge=True" merges all overlapping blobs in the image.
while(True):
clock.tick()
img = sensor.snapshot()
for blob in img.find_blobs([thresholds[threshold_index]], pixels_threshold=200, area_threshold=200, merge=True):
img.draw_rectangle(blob.rect())
img.draw_cross(blob.cx(), blob.cy())
print(clock.fps())这个是openMV自带的单颜色识别,
UART Control 串口通信
import time
from pyb import UARTuart = UART(3, 115200)
uart.init(115200, bits=8, parity=None, stop=1) # init with given parameters
while(True):
uart.write("Hello World!\r")
print("Hello World")
# 休眠1s
time.sleep(1000)这个是向串口发送数据的代码
、
现在要实现 在OPENMV用自带的代码 进行单颜色识别 识别了颜色后会发出一个信号符或标识符, 通过串口发送到
TTL 转接到PC上的串口的显示 从而进行单片机之间的通信
例如, 识别了红色后 发出一个1或red的信号 通过串口 发送到 串口调试助手, 显示出1或red
这两个代码要怎么结合 做才能达到这个效果,, PYthon新手,求各位大神指导
-