2.openmv中的感光元件

1.sensor对象初体验

import sensor#引入感光元件的模块

# 设置摄像头
sensor.reset()#初始化感光元件
sensor.set_pixformat(sensor.RGB565)#设置为彩色
sensor.set_framesize(sensor.QVGA)#设置图像的大小
sensor.skip_frames()#跳过n张照片,在更改设置后,跳过一些帧,等待感光元件变稳定。

# 一直拍照
while(True):
    img = sensor.snapshot()#拍摄一张照片,img为一个image对象

2.openmv设置彩色/黑白

sensor.set_pixformat()#设置像素模式
参数:
sensor.GRAYSCALE:灰度,每个像素8bit
sensor.RGB565:彩色,每个像素16bit

3.sensor.set_framesize()设置图像大小

参数:
sensor.QQCIF: 88x72
sensor.QCIF: 176x144
sensor.CIF: 352x288
sensor.QQSIF: 88x60
sensor.QSIF: 176x120
sensor.SIF: 352x240

4.跳过一些帧

sensor.skip_frames(n=10)跳过n张照片,在更改设置后,跳过一些帧,等待感光元件变稳定

5.获取一张图像

sensor.snapshot()拍摄一张图片,返回一个image对象

6.自动增益/白平衡/曝光

  • sensor.set_auto_gain()
    设置自动增益开启,True or False,在使用颜色追踪时,需要关闭自动增益

  • sensor.set_auto_whitebal()自动白平衡开启
    在使用颜色追踪时,需要关闭自动白平衡

  • sensor.set_auto_exposure()
    设置曝光

7.设置窗口ROI

sensor.set_windowing(roi)
ROI:Region of In INterest,图像处理中的术语“感兴趣区”,就是在要处理的图像中提取出要处理的区域
sensor.set_framesize(sensor.VGA) # 高分辨率
sensor.set_windowing((640, 80)) #取中间的640*80区域

8.设置翻转

sensor.set_hmirror(True) #水平方向翻转
sensor.set_vfilp(True) #垂直方向翻转

posted @ 2022-07-27 17:11  TCcjx  阅读(156)  评论(0编辑  收藏  举报