UVC摄像头显示到开发板

Viewed 83

问题描述


我使用UVC摄像头进行图像数据传入,用开发板屏幕显示检测结果,但是摄像头是YUY2格式的编码格式,依据官方文档image.png,我使用cvt = True没能把图像更改为RGB565(屏幕显示花屏,且打印图像格式仍然为unpress)。摄像头只支持uncompress,但固件只支持mjpeg,image.png
期望使用CSC更改图片格式,但是csc.convert 输入 frame 为 py_video_frame_info ,是 sensor.snapshot() 的输出,而非UVC.snapshot()。下面是我的代码。

import time, gc, os, image
from media.display import *
from media.media import *
from media.uvc import *

DISPLAY_WIDTH  = 960
DISPLAY_HEIGHT = 540

os.exitpoint(os.EXITPOINT_ENABLE)

Display.init(Display.NT35516, width=DISPLAY_WIDTH, height=DISPLAY_HEIGHT, to_ide=True)
MediaManager.init()

try:
    print("等待UVC摄像头...")
    while True:
        plugin, dev = UVC.probe()
        if plugin:
            print(f"检测到摄像头: {dev}")
            break
        time.sleep_ms(500)

    mode = UVC.video_mode()

    succ, mode = UVC.select_video_mode(mode)
    print(f"select mode success: {succ}, mode: {mode}")

    UVC.start(cvt=True)

    fps = time.clock()
    while True:
        os.exitpoint()
        fps.tick()
        img = UVC.snapshot()
        if img is not None:
            print(img.format(), img.width(), img.height())
            img = img.to_rgb565()
            print(img.format(), img.width(), img.height())
            # 160x120 -> 960x540
            #img = img.scale(x_scale=960/160, y_scale=536/120)
            print(img.format(), img.width(), img.height())
            Display.show_image(img)
            del img
            gc.collect()
            print(f"fps: {fps.fps():.2f}")

finally:
    UVC.stop()
    Display.deinit()
    time.sleep_ms(100)
    MediaManager.deinit()
    print("资源已释放")

下面是终端运行结果


vb common pool count 3
等待UVC摄像头...
检测到摄像头: Generic#USB2.0 PC CAMERA
select mode success: True, mode: {"width":160, "height":120, "format":uncompress, "fps":30.00}
470089730 160 120
201523202 160 120
201523202 160 120
fps: 7.19
470089730 160 120
201523202 160 120
201523202 160 120
fps: 11.24
470089730 160 120
201523202 160 120
201523202 160 120

期望能有什么解决办法,用官方新固件很多都无法适配我的开发板硬件,我是自定义固件。

硬件板卡


rtsmart ai开发套件

软件版本


CanMV-K230_DONGSHANPI_micropython_local_nncase_v2.9.0

1 Answers

你好,最新的sdk已经支持这个格式了,请更新一下固件。https://www.kendryte.com/k230_canmv/zh/main/zh/api/mpp/media_uvc.html

能否提供我一下固件的地址,谢谢

请问哪个固件适配我的开发板呢,我的开发板是使用自定义固件make dongshanpi启动的,但是用最新的dongshanpi固件系统错误。用最新的CanMV K230 V1.0/V1.1能启动,但是之前能运行的程序很多运行不了,请问有这个最新系统的代码仓库地址吗,我需要看看api是咋写的