OpenMV4开发笔记1-感光元件初始化

import sensor, image, time
#引入此例程依赖的模块,
#sensor 是与摄像头参数设置相关的模块,
#image 是图像处理相关的模块,
#time 时钟控制相关的模块。
#import 相当于 c 语言的#include <>,模块相当于 c 语言的库。

sensor.reset()  #初始化相机传感器
sensor.set_pixformat(sensor.RGB565) #设置相机模块的像素模式。
sensor.set_framesize(sensor.QVGA)  #设置相机模块的帧大小。
sensor.skip_frames(time = 2000)  #Let new settings take affect.

clock = time.clock()  #初始化时钟

while(True):
    clock.tick()  #Track elapsed milliseconds between snapshots()
    img = sensor.snapshot()  #截取当前图像,存放于变量 img 中。
    print(clock.fps())  #打印当前的帧率。

sensor.set_pixformat(pixformat)

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

sensor.GRAYSCALE: 8-bits per pixel.
sensor.RGB565: 16-bits per pixel.
sensor.BAYER: 8-bits per pixel bayer pattern.

sensor.set_framesize(framesize)

设置相机模块的帧大小。
OpenMV4 H7默认配置的OV7725 感光元件处理640×480 8-bit 灰度图或者640×480 16-bit RGB565彩色图像可以达到60 FPS;当分辨率低于320×240可以达到120FPS。大多数简单的算法可以运行60FPS以上。你的 OpenMV 摄像头有一个2.8mm焦距镜头在一个标准M12镜头底座上。如果你想使用更多的特殊的镜头,你可以很容易的安装。

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 (for use with image.find_displacement())
sensor.B64X64: 64x64 (for use with image.find_displacement())
sensor.B128X64: 128x64 (for use with image.find_displacement())
sensor.B128X128: 128x128 (for use with image.find_displacement())
sensor.LCD: 128x160 (for use with the lcd shield)
sensor.QQVGA2: 128x160 (for use with the lcd shield)
sensor.WVGA: 720x480 (for the MT9V034)
sensor.WVGA2:752x480 (for the MT9V034)
sensor.SVGA: 800x600 (only in JPEG mode for the OV2640 sensor)
sensor.SXGA: 1280x1024 (only in JPEG mode for the OV2640 sensor)
sensor.UXGA: 1600x1200 (only in JPEG mode for the OV2640 sensor)

sensor.skip_frames([n, time])

使用 n 个快照,让相机图像在改变相机设置后稳定下来。 n 作为普通参数传输, 例如: skip_frames(10) 跳过 10 帧。您应在改变相机设置后调用该函数。

或者,您可通过关键字参数 time 来跳过几毫秒的帧数,例如: kip_frames(time = 2000) ,跳过2000毫秒的帧。

若 n 和 time 皆未指定,该方法跳过300毫秒的帧。

若二者皆指定,该方法会跳过 n 数量的帧,但将在 time 毫秒后超时。

更多感光元件函数参考:https://docs.singtown.com/micropython/zh/latest/openmvcam/library/omv.sensor.html

猜你喜欢

转载自blog.csdn.net/Stark_/article/details/113102825