'''
实验名称:摄像头使用
实验平台:01Studio CanMV K230
说明:实现摄像头图像采集显示
'''
import time, os, sys,image
from media.sensor import * #导入sensor模块,使用摄像头相关接口
from media.display import * #导入display模块,使用display相关接口
from media.media import * #导入media模块,使用meida相关接口
sensor = Sensor() #构建摄像头对象 标配70°,可选140°
sensor.reset() #复位和初始化摄像头
sensor.set_framesize(Sensor.SVGA) #设置帧大小FHD(1920x1080),默认通道0
sensor.set_pixformat(Sensor.GRAYSCALE) #设置输出图像格式,默认通道0 RGB565
#使用IDE缓冲区输出图像,显示尺寸和sensor配置一致。
Display.init(Display.VIRT, sensor.width(), sensor.height())
MediaManager.init() #初始化media资源管理器
sensor.run() #启动sensor
clock = time.clock()
while True:
################
## 这里编写代码 ##
################
clock.tick()
img = sensor.snapshot() #拍摄一张图
for l in img.find_line_segments(merge_distance = 0, max_theta_diff = 5):
img.draw_line(l.line(), color = (255, 0, 0))
Display.show_image(img) #显示图片
print(clock.fps()) #打印FPS
Traceback (most recent call last):
File "", line 36, in
MemoryError: Out of fast frame buffer stack memory
MPY: soft reboot
CanMV v1.2.2(based on Micropython e00a144) on 2024-12-18; k230_canmv_01studio with K230
01的canmv k230开发板,2G内存。