赞
踩
实验目的:本实验实现使用openMV检测前方色块,并传回色块的坐标位置给STM32,控制舵机转动来跟踪色块。
openMV部分
import sensor, image, time from pyb import UART import json red_threshold = (87, 21, 27, 93, -5, 92) 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 affeOpenMV_Xct. sensor.set_auto_whitebal(False) # turn this off. clock = time.clock() # Tracks FPS. uart = UART(3, 115200) uart.init(115200, bits=8, parity=None, stop=1) #8位数据位,无校验位,1位停止位 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 def sending_data(cx_max,cy_max): global uart; data = ustruct.pack("<bbbb", #格式为俩个字符俩个短整型(2字节)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。