从原始视频中提取帧

2024-04-27 20:49:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我将配置设置为:

v4l2-ctl -v pixelformat=pRCC,width=4056,height=3040
v4l2-ctl -p 10

然后使用以下方法获取帧:

v4l2-ctl --stream-mmap=3 --stream-count=100 --stream-to=test.avi

这就成功地结束了。现在我一直在尝试从这个视频文件中提取帧,并将其转换为RGB进行查看

我有两种摄像头操作模式,第一种是直接将it连接到地址总线,而不是将结果列为:

v4l2-ctl --list-formats-ext

ioctl: VIDIOC_ENUM_FMT
Type: Video Capture

[0]: 'pRCC' (12-bit Bayer RGRG/GBGB Packed)
    Size: Discrete 4056x3040
    Size: Discrete 2028x1520
    Size: Discrete 2028x1080
[1]: 'RG12' (12-bit Bayer RGRG/GBGB)
    Size: Discrete 4056x3040
    Size: Discrete 2028x1520
    Size: Discrete 2028x1080
[2]: 'pRAA' (10-bit Bayer RGRG/GBGB Packed)
    Size: Discrete 1012x760
[3]: 'RG10' (10-bit Bayer RGRG/GBGB)
    Size: Discrete 1012x760

如果通过操作系统连接,则结果是:

ioctl: VIDIOC_ENUM_FMT
Type: Video Capture

[0]: 'YU12' (Planar YUV 4:2:0)
    Size: Stepwise 32x32 - 4056x3040 with step 2/2
[1]: 'YUYV' (YUYV 4:2:2)
    Size: Stepwise 32x32 - 4056x3040 with step 2/2
[2]: 'RGB3' (24-bit RGB 8-8-8)
    Size: Stepwise 32x32 - 4056x3040 with step 2/2
[3]: 'JPEG' (JFIF JPEG, compressed)
    Size: Stepwise 32x32 - 4056x3040 with step 2/2
[4]: 'H264' (H.264, compressed)
    Size: Stepwise 32x32 - 4056x3040 with step 2/2
[5]: 'MJPG' (Motion-JPEG, compressed)
    Size: Stepwise 32x32 - 4056x3040 with step 2/2
[6]: 'YVYU' (YVYU 4:2:2)
    Size: Stepwise 32x32 - 4056x3040 with step 2/2
[7]: 'VYUY' (VYUY 4:2:2)
    Size: Stepwise 32x32 - 4056x3040 with step 2/2
[8]: 'UYVY' (UYVY 4:2:2)
    Size: Stepwise 32x32 - 4056x3040 with step 2/2
[9]: 'NV12' (Y/CbCr 4:2:0)
    Size: Stepwise 32x32 - 4056x3040 with step 2/2
[10]: 'BGR3' (24-bit BGR 8-8-8)
    Size: Stepwise 32x32 - 4056x3040 with step 2/2
[11]: 'YV12' (Planar YVU 4:2:0)
    Size: Stepwise 32x32 - 4056x3040 with step 2/2
[12]: 'NV21' (Y/CrCb 4:2:0)
    Size: Stepwise 32x32 - 4056x3040 with step 2/2
[13]: 'RX24' (32-bit XBGR 8-8-8-8)
    Size: Stepwise 32x32 - 4056x3040 with step 2/2

正如我所提到的,我正在尽可能快地获取未触及的12位数据,然后能够在Python上查看像素数据,最好是(我也愿意接受其他建议)

如果有经验的用户能提供一些解决方案,我将非常高兴


Tags: streamsizestepwithbitcompressedjpegctl