Openmv初探 | 您所在的位置:网站首页 › 电脑摄像头开启但是没图像 › Openmv初探 |
import sensor #import the sensor
#the settings of camera
sensor.reset() #startup the sensor
sensor.set_pixformat(sensor.RGB565) #set color
sensor.set_framesize(sensor.QVGA) #set size
sensor.skip_frames() #skip photos
while(True):
img = sensor.snapshot() #take a photo
注释写的非常清楚啦,复制到openmv ide,连接运行即可。 值得注意的是,第一步,初始化摄像头,sensor.reset() 然后设置为彩色模式,即RGB565。 接着调整图像大小,调整为QVGA。 接着跳过一些帧,直接使用skip_frames即可。 在更改设置后,跳过一些帧,等待感光元件变稳定。 效果如下: sensor.set_auto_whitebal() 自动白平衡开启(True)或者关闭(False)。在使用颜色追踪时,需要关闭自动白平衡。 设置窗口ROI sensor.set_windowing(roi) ROI:Region Of Interest,图像处理中的术语“感兴趣区”。就是在要处理的图像中提取出的要处理的区域。 sensor.set_framesize(sensor.VGA) # 高分辨率 sensor.set_windowing((640, 80)) #取中间的640*80区域 Copy roi的格式是(x, y, w, h)。见使用统计信息 设置翻转 sensor.set_hmirror(True) 水平方向翻转 sensor.set_vflip(True) 垂直方向翻转 import sensor sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QVGA) sensor.skip_frames(n=10) sensor.set_hmirror(True) while(1): img = sensor.snapshot() |
CopyRight 2018-2019 实验室设备网 版权所有 |