Photosensitive element
Sensor module, used to set the parameters of the photosensitive element.
For example:
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对象
Initialization
- sensor.reset() initializes the photosensitive element
Set color/black and white
- sensor.set_pixformat() sets the pixel mode.
- sensor.GRAYSCALE: grayscale, 8 bits per pixel.
- sensor.RGB565: color, 16 bits per pixel.
Set the image size
- sensor.set_framesize() Set the image size
- 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 frame difference image.find_displacement())
- sensor.B64X64: 64x64 for frame difference image.find_displacement())
- sensor.B128X64: 128x64 (for frame difference image.find_displacement())
- sensor.B128X128: 128x128 (for frame difference image.find_displacement())
- sensor.LCD: 128x160 (for LCD expansion board)
- sensor.QQVGA2: 128x160 (for LCD expansion board)
- sensor.WVGA: 720x480 (for MT9V034)
- sensor.WVGA2:752x480 (for MT9V034)
- sensor.SVGA: 800x600 (for OV5640 sensor only)
- sensor.XGA: 1024x768 (for OV5640 sensor only)
- sensor.SXGA: 1280x1024 (for OV5640 sensor only)
- sensor.UXGA: 1600x1200 (for OV5640 sensor only)
- sensor.HD: 1280x720 (for OV5640 sensor only)
- sensor.FHD: 1920x1080 (for OV5640 sensor only)
- sensor.QHD: 2560x1440 (for OV5640 sensor only)
- sensor.QXGA: 2048x1536 (OV5640 sensor only)
- sensor.WQXGA: 2560x1600 (OV5640 sensor only)
- sensor.WQXGA2: 2592x1944 (OV5640 sensor only)
Skip some frames
- sensor.skip_frames(n=10) Skip n photos. After changing the settings, skip some frames and wait for the sensor to stabilize.
Get an image
- sensor.snapshot() Take a photo and return an image object.
Automatic gain/white balance/exposure
sensor.set_auto_gain() Automatic gain on (True) or off (False). When using color tracking, you need to turn off automatic gain.
sensor.set_auto_whitebal() Automatic white balance on (True) or off (False). When using color tracking, you need to turn off automatic white balance.
sensor.set_auto_exposure(enable[\, exposure_us])
- enable turns auto exposure on (True) or off (False). On by default.
- If enable is False, exposure_us can be used to set a fixed exposure time (in microseconds).
Set window ROI
sensor.set_windowing(roi)
ROI: Region Of Interest, the term "region of interest" in image processing. It is the region to be processed extracted from the image to be processed.\
sensor.set_framesize(sensor.VGA) # 高分辨率
sensor.set_windowing((640, 80)) #取中间的640*80区域
The format of roi is (x, y, w, h). See using statistics
Set flip
sensor.set_hmirror(True)\ Horizontal flip
sensor.set_vflip(True)\ Vertical flip
For more sensor settings, see the official Chinese documentation of OpenMV: https://docs.singtown.com/micropython/zh/latest/openmvcam/library/omv.sensor.html