OpenMV学习笔记(4) 画图

您所在的位置:网站首页 opencv画框函数 OpenMV学习笔记(4) 画图

OpenMV学习笔记(4) 画图

2024-06-18 01:15| 来源: 网络整理| 查看: 265

目录

一、前言

二、画线

三、画框 

四、画圆 

 五、画十字

 六、写字

 七、完整代码

一、前言

视觉系统通常需要给使用者提供一些反馈信息,直接在图像中显示出来,很直观。在这里。我们需要把ROI区域用图形框标注出来

二、画线 image.draw_line(line_tuple, color=White) line_tuple的格式是(x0, y0, x1, y1),意思是(x0, y0)到(x1, y1)的直线。颜色可以是灰度值(0-255),或者是彩色值(r, g, b)的tupple。默认是白色 三、画框  image.draw_rectangle(rect_tuple, color=White) rect_tuple 的格式是 (x, y, w, h)。此区域在第三节笔记有讲 OpenMV学习笔记(3) 获取图像的颜色信息_yzfzzz的博客-CSDN博客 四、画圆  image.draw_circle(x, y, radius, color=White) x,y是圆心坐标radius是圆的半径  五、画十字 image.draw_cross(x, y, size=5, color=White) x,y是坐标size是两侧的尺寸  六、写字 image.draw_string(x, y, text, color=White) x,y是坐标。使用\n, \r, and \r\n会使光标移动到下一行。text是要写的字符串。

 例:

img.draw_string(10,10, "hello world!")  七、完整代码 import sensor, image, time sensor.reset() # 初始化摄像头 sensor.set_pixformat(sensor.RGB565) # 格式为 RGB565. sensor.set_framesize(sensor.QQVGA) sensor.skip_frames(10) # 跳过10帧,使新设置生效 while(True): img = sensor.snapshot() # Take a picture and return the image. img.draw_line((20, 30, 40, 50)) img.draw_line((80, 50, 100, 100), color=(255,0,0)) img.draw_rectangle((20, 30, 41, 51), color=(255,0,0)) img.draw_circle(50, 50, 30) img.draw_cross(90,60,size=10) img.draw_string(10,10, "hello world!")



【本文地址】


今日新闻


推荐新闻


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