OpenMv学习过程①

[复制链接]
1783|5
手机看帖
扫描二维码
随时随地手机跟帖
caijie001|  楼主 | 2018-3-7 13:03 | 显示全部楼层 |阅读模式
本帖最后由 caijie001 于 2018-3-7 18:49 编辑

最近入手了个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
样例代码
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 (320x240)
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())   # Note: OpenMV Cam runs about half as fast when connected


这就是简单画矩形的图像,想要改变矩形位置就改变的x,y(图像左上角起点)
想要改变矩形面积就改变宽度高度(图像宽高)改变线条颜色就改变 rgb_white

2:绘制十字
函数说明
image.draw_cross(x,y,size = 5,color = White)
参数
X
十字中心的 X 坐标
ÿ
十字中心的 ÿ 坐标
尺寸
十字的长度
颜色
颜色,填入灰度值(0-255),或者 RGB (r,g,b)
样例代码
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 (320x240)
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())          # Note: OpenMV Cam runs about half as fast when connected

学会简单画图,就可以使用 openmv 来做色彩追踪了。
未完待续......下篇用openmv来做色彩追踪




相关帖子

caijie001|  楼主 | 2018-3-7 13:18 | 显示全部楼层
自己顶

使用特权

评论回复
BryanChang| | 2018-3-13 23:35 | 显示全部楼层
不错

使用特权

评论回复
蔬木果| | 2018-7-18 10:27 | 显示全部楼层
学习了。

使用特权

评论回复
caijie001|  楼主 | 2018-7-18 18:34 | 显示全部楼层

使用特权

评论回复
zhoushangshi| | 2018-11-16 10:22 | 显示全部楼层
菜鸟踏过留印。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:21ic公开课专区:http://open.21ic.com/ 21ic资料下载中心:http://dl.21ic.com/ 21ic项目外包中心:http://project.21ic.com/ 杰杰欢迎大家有空常来赛事专区逛逛

131

主题

3790

帖子

63

粉丝