详细见这篇:2022年十月份电赛OpenMV巡线方案详细代码分析(1)_openmv巡线代码-优快云博客
1.初始化配置
导入相关库
import sensor, image, time,math,pyb
from pyb import UART
from pyb import LED
import ustruct #压缩和不压缩原始数据类型,主要是串口发送那里
from image import SEARCH_EX,SEARCH_DS
import time
import sensor
相关设置
sensor.reset() #重置感光元件,重置摄像机
sensor.set_pixformat(sensor.RGB565) #设置颜色格式为RGB565,彩色,每个像素16bit。
#sensor.set_pixformat(sensor.GRAYSCALE) # use grayscale.画面呈现灰色
sensor.set_framesize(sensor.QQVGA) #图像大小为QQVGA 160*120的分辨率
sensor.skip_frames(time = 2000) #跳过n张照片,在更改设置后,跳过一些帧,等待感光元件变稳定。
sensor.set_auto_gain(False) #颜色识别必须关闭自动增益,会影响颜色识别效果
sensor.set_auto_whitebal(False)