摄像头

野火K210 AI视觉相机 使用的摄像头像素大小为 200W像素

例程讲解

该例程在 例程的xxx ,可以在 CanMV IDE 中打开

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
import sensor
import lcd

lcd.init()

sensor.reset(dual_buff=True)
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 1000)

while True:
    img = sensor.snapshot()
    lcd.display(img)

实验准备

  1. 野火K210 AI视觉相机 连接到 CanMV IDE

  2. 执行程序

运行结果

运行之后,可以看到屏幕上一直显示摄像头捕捉的图像

野火logo

程序分析

1
2
3
4
import sensor
import lcd

lcd.init()
  • import sensor :导入用于控制图像传感器的模块

  • import lcd :导入用于控制LCD显示屏的模块

  • lcd.init() :初始化LCD显示屏

1
2
3
4
sensor.reset(dual_buff=True)
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 1000)
  • sensor.reset(dual_buff=True) : 重置图像传感器,并启用双缓冲,以提高图像处理的效率

  • sensor.set_pixformat(sensor.RGB565) :设置相机的图像格式为RGB565

  • sensor.set_framesize(sensor.QVGA) :设置相机的图像分辨率为QVGA(320x240像素)

  • sensor.skip_frames(time = 1000) :跳过1000ms时间内的图像,让相机获得稳定的图像

1
2
3
while True:
    img = sensor.snapshot()
    lcd.display(img)
  • while True: :开始一个无限循环

  • img = sensor.snapshot() :从图像传感器捕获一帧图像

  • lcd.display(img) :将捕获的图像显示在LCD上