机器视觉开发笔记4:最简单的程序

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/qingwufeiyang12346/article/details/101716623

本文对OpenMV的基本程序进行详细解释,源程序如下:

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(time = 2000)     # Wait for settings take effect.
clock = time.clock()                # Create a clock object to track the FPS.

while(True):
    clock.tick()                    # Update the FPS clock.
    img = sensor.snapshot()         # Take a picture and return the image.
    print(clock.fps())              # Note: OpenMV Cam runs about half as fast when connected
                                    # to the IDE. The FPS should increase once disconnected.

1、输入模块

sensor:用于提取图像

image:用于机器视觉

time:用于追踪经过的时间

2、sensor.reset()

初始化相机传感器。

3、sensor.set_pixformat(sensor.RGB565)

设置相机模块的像素格式。

sensor.GRAYSCALE:每个像素8位。

sensor.RGB565:每个像素16位。

sensor.BAYER:每像素8位Bayer模式。

4、sensor.set_framesize(sensor.QVGA)

设置图像大小。

sensor.QQCIF:88x72

sensor.QCIF:176x144

sensor.CIF:352x288

sensor.QQSIF:88x60

sensor.QSIF:176x120

sensor.SIF:352x240

sensor.QQQQVGA:40x30

sensor.QQQVGA:80x60

sensor.QQVGA:160x120

sensor.QVGA:320x240

sensor.VGA:640x480

sensor.HQQQVGA:80x40

sensor.HQQVGA:160x80

sensor.HQVGA:240x160

sensor.B64X32:64x32(用于image.find_displacement())

sensor.B64X64:64x64(用于image.find_displacement())

sensor.B128X64:128x64(用于image.find_displacement())

sensor.B128X128:128x128(用于image.find_displacement())

sensor.LCD:128x160(与LCD防护罩配合使用)

sensor.QQVGA2:128x160(与LCD防护罩配合使用)

sensor.WVGA:720x480(对于MT9V034)

sensor.WVGA2:752x480(对于MT9V034)

sensor.SVGA:800x600(仅在JPEG模式下用于OV2640 传感器)

sensor.SXGA:1280x1024(仅在OV2640 传感器的 JPEG模式下)

sensor.UXGA:1600x1200(仅在JPEG模式下用于OV2640 传感器)

5、sensor.skip_frames(time = 2000)

这是一个延时时间,由于上面改变了相机设置,等待2秒的时间,让相机稳定。

6、clock = time.clock()

用于建立1个clock对象。

7、clock.tick()和clock.fps()

此2条语句配合使用,clock.tick()用于开始记录经过的时间,clock.fps()停止记录并返回每秒的帧数。

8、sensor.snapshot()

通过相机提取1幅图像并返回给image对象。

 

任何问题,只需在此文章的评论处留言即可,我将尽力解答,不要试图采用其它的联系方式,我一概不理会。

原创性文章,转载请注明出处CSDN:http://blog.csdn.net/qingwufeiyang12346。

 

 

猜你喜欢

转载自blog.csdn.net/qingwufeiyang12346/article/details/101716623
今日推荐