【OpenMV学习笔记(一)】识别色块并与STM通信传输中心坐标

您所在的位置:网站首页 CX–4牌照框 【OpenMV学习笔记(一)】识别色块并与STM通信传输中心坐标

【OpenMV学习笔记(一)】识别色块并与STM通信传输中心坐标

2023-10-11 09:41| 来源: 网络整理| 查看: 265

目录 1.前言2.硬件连接3.代码4.查看结果5.总结

1.前言

一直有想要写些东西的想法正好最近比较闲以及大创项目和电赛备赛需要用到OpenMV所以就记录一下学习过程。因为小白第一次写文章有什么错误希望大家包含在评论区指正。

2.硬件连接

2.1、Openmv端 在这里插入图片描述 这里OpenMV端仅作为数据的发送端,所以只需要共地,以及OpenMV的TX(P4)与开发板的RX端连接即可。 2.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端配置一样即可。 #**************************传输数据的函数************************************ def sending_data(cx,cy): global uart; #frame=[0x2C,18,cx%0xff,int(cx/0xff),cy%0xff,int(cy/0xff),0x5B]; #data = bytearray(frame) data = ustruct.pack("


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3