野火电子论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9318|回复: 3

openmv学习之旅——stm32f7

[复制链接]
发表于 2018-6-8 11:51:09 | 显示全部楼层 |阅读模式
最近入手了个OpenMv,还要感谢二姨家的平台啊。感谢
装IDE这种小事就不说了。说说真正入门的操作吧。对python也没啥要求。我也是这样子马上上手的,当然在过程我是学习了python的。

1:绘制矩形
绘制矩形
函数说明
image.draw_rectangle(rect_tuple,color=White)
参数
rect_tuple
格式 (x, y, w, h)
矩阵的起始坐标, (x, y), 即矩形的左上角坐标
w : 矩形的宽度
h : 矩形的高度
x, y, w, h 均为整数
color
颜色,填入灰度值(0-255), 或者RGB(r, g, b)
下面简单画个矩形

捕获.PNG

[mw_shl_code=python,true]import sensor, image, time

sensor.reset()       # Reset and initialize the sensor.
sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA (320×240)
sensor.skip_frames(30) # Wait for settings take effect.
clock = time.clock() # Create a clock object to track the FPS.

x = 100
y = 100
width = 100
height = 100

rect_tuple = (x, y, width, height)

rgb_white = (255, 255, 255) # (r=255, g=255, b=255) -> white color

while(True):
clock.tick() # Update the FPS clock.
img = sensor.snapshot() # Take a picture and return the image.
img.draw_string(x, y, “(%d, %d)”%(x, y), color=rgb_white)
img.draw_rectangle(rect_tuple, color=rgb_white)
print(clock.fps()) #打印帧率[/mw_shl_code]
这就是简单画矩形的图像,想要改变矩形位置就改变的x,y(图像左上角起点)
想要改变矩形面积就改变宽度高度(图像宽高)改变线条颜色就改变 rgb_white

2:绘制十字
函数说明
image.draw_cross(x,y,size = 5,color = White)
参数
X
十字中心的 X 坐标
y
十字中心的 y 坐标
size
十字的大小
color
颜色,填入灰度值(0-255),或者 RGB (r,g,b)
样例代码
[mw_shl_code=python,true]import sensor, image, time

sensor.reset() # Reset and initialize the sensor.
sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA (320×240)
sensor.skip_frames(30) # Wait for settings take effect.
clock = time.clock() # Create a clock object to track the FPS.

x = 150
y = 150
size = 20

rgb_white = (255, 255, 255) # (r=255, g=255, b=255) -> white color

while(True):
clock.tick() # Update the FPS clock.
img = sensor.snapshotA() # Take a picture and return the image.
img.draw_string(x, y, “(%d, %d)”%(x, y), color=rgb_white)
img.draw_cross(x, y, size=size, color=rgb_white)

print(clock.fps())#打印帧率[/mw_shl_code]
学会简单画图,就可以使用 openmv 来做色彩追踪了。
未完待续......下篇用openmv来做色彩追踪并且优化它




回复

使用道具 举报

发表于 2018-6-8 16:20:17 | 显示全部楼层

不知道python在stm32上运行的效率会多低呢
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-6-8 17:39:23 | 显示全部楼层
魚丸粗麵 发表于 2018-6-8 16:20
不知道python在stm32上运行的效率会多低呢

低,但是编程方便哈哈哈哈
回复 支持 反对

使用道具 举报

发表于 2024-2-4 06:45:11 | 显示全部楼层
能运行在指南者上么
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

联系站长|手机版|野火电子官网|野火淘宝店铺|野火电子论坛 ( 粤ICP备14069197号 ) 大学生ARM嵌入式2群

GMT+8, 2024-4-28 18:50 , Processed in 0.033689 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表