当前位置:网站首页>openmv学习 2022.5.9

openmv学习 2022.5.9

2022-08-02 03:28:00 jualay

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档


提示:以下是本篇文章正文内容,下面案例可供参考

一、灰度图和彩色图

一、组成不同

1、灰度图:灰度图把白色与黑色之间按对数关系用灰度表示的图像。

2、彩色图:彩色图是每个像素由R、G、B分量构成的图像。

二、通道不同

1、灰度图:灰度图只有一个单独的灰度通道。

2、彩色图:彩色图有多个叠加的彩色通道。

三、表示不同

1、灰度图:灰度图由单个像素点通过8位的灰度值(0-255)来表示。

2、彩色图:彩色图由R、G、B三个不同的8位的灰度值(0-255)来表示。

 

二、画图例程

1.原代码

代码如下(示例):

# Hello World Example
#
# Welcome to the OpenMV IDE! Click on the green run arrow button below to run the script!

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!")

2.细节

  • line_tuple的格式是(x0, y0, x1, y1),意思是(x0, y0)到(x1, y1)的直线。颜色可以是灰度值(0-255),或者是彩色值(red, green, blue)的tupple。默认是白色
  • rect_tuple 的格式是 (x, y, width, height)。在图像中画一个矩形框。
  • image.draw_circle(x, y, radius半径,color=White) 在图像中画一个圆。
  • image.draw_cross(x, y, size两侧的尺寸, color=White) 在图像中画一个十字
  • image.draw_string(x, y, text, color=White) 在图像中写字 8x10的像素

                x,y是坐标。使用\n, \r, and \r\n会使光标移动到下一行,

                text是要写的字符串。


总结

openmv画图

原网站

版权声明
本文为[jualay]所创,转载请带上原文链接,感谢
https://blog.csdn.net/jualay/article/details/121001526