openmv与msp432串口通信
根据 OpenMV与stm32,msp432等单片机的串口通讯(已经写好一个识别色块的例程,可直接使用)keil(MDK)改进。
一、首先有一个大思想的问题,举个例子就是假如msp432充当“大脑”,openmv就相当于“眼睛”,那么链接所写的就是“眼睛”一直在向“大脑”发送数据,中断会一直触发。那么我们换种思路,如果是我“大脑”发个信号之后,“眼睛”再将数据发送给“大脑”。
(利:中断触发减少,可调整数据发送速率,可主动请求数据。)
(弊:主程序占用,请求可能会被搁置,如果使用定时器的延时可以避免这个。)
二、就是他的那个代码里有一个数据的判断是错误的。文章来源:https://www.toymoban.com/news/detail-601804.html
下面是openmv的代码文章来源地址https://www.toymoban.com/news/detail-601804.html
# Blob Detection and uart transport
import sensor, image, time
from pyb import UART
import json
import lcd
# For color tracking to work really well you should ideally be in a very, very,
# very, controlled enviroment where the lighting is constant...
yellow_threshold = (1, 17, -20, 11, -12, 17)
#记得更改要识别色块的阈值
# 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() # 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.
lcd.init() # Initialize the lcd screen.
#lcd初始化
uart = UART(3, 115200)
uart.init(115200,bits=8,parity=None,stop=1)
#这里是UART3,115200
def find_max(blobs):
max_size=0
for blob in blobs:
if blob.pixels() > max_size:
max_blob=blob
max_size = blob.pixels()
return max_blob
#得到识别面积最大的色块
while(True):
img = sensor.snapshot() # Take a picture and return the image.
blobs = img.find_blobs([yellow_threshold])
if blobs:
max_blob=find_max(blobs)
img.draw_rectangle(max_blob.rect())
img.draw_cross(max_blob.cx(), max_blob
到了这里,关于openmv与msp432串口通信的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!