高通qcm6490 用gst-camera-burst-capture-example 那sensor raw 图, 如何解析raw 图?

大笨洋0 2025-10-28 09:17:46

gst-camera-burst-capture-example  -p 1 -c 2
I/Adreno-UNKNOWN (19530,19530): <ReadGpuID:361>: Reading chip ID through GSL
GBM_INFO::msmgbm_mapper(262)::gbm mapper instantiated

gbm_create_device(224): Info: backend name is: msm_drm
Pipeline state change READY was successful

bayer, using sensor width: 4056 and height 3040
Adding all elements to the pipeline...
Linking camera capture pad ...
All elements are linked successfully
Adding all elements to the pipeline...
Linking camera video pad ...
Linking elements...
All elements are linked successfully
gbm_create_device(224): Info: backend name is: msm_drm
Pipeline is PREROLLING ...
GBM_ERR::msmgbm_bo_import_gbm_buf(1605)::DRM_IOCTL_PRIME_FD_TO_HANDLE failed for fd errono: 22 (Invalid argument) drm fd: 6 fd: 24

GBM_ERR::msmgbm_bo_import_gbm_buf(1633)::DRM_IOCTL_PRIME_FD_TO_HANDLE failed for metadatadata fd errono: 22 (Invalid argument) drm fd: 6 metadata fd: 25

Pipeline async state change to PLAYING was successful
g_main_loop_run

Pipeline state changed from NULL to READY, pending: VOID_PENDING

Pipeline state changed from READY to PAUSED, pending: PLAYING

Pipeline state changed from PAUSED to PLAYING, pending: VOID_PENDING

Capturing images with bracketing from 12 to -12 step -6
requesting 3 snapshot...
delaying next request for 10 seconds...

Camera timestamp: 319881880916736
Buffer written to file system: /opt/frame_319881880916736.raw
GBM_ERR::msmgbm_bo_import_gbm_buf(1605)::DRM_IOCTL_PRIME_FD_TO_HANDLE failed for fd errono: 22 (Invalid argument) drm fd: 6 fd: 47

GBM_ERR::msmgbm_bo_import_gbm_buf(1633)::DRM_IOCTL_PRIME_FD_TO_HANDLE failed for metadatadata fd errono: 22 (Invalid argument) drm fd: 6 metadata fd: 48

Camera timestamp: 319881914478350
Buffer written to file system: /opt/frame_319881914478350.raw
GBM_ERR::msmgbm_bo_import_gbm_buf(1605)::DRM_IOCTL_PRIME_FD_TO_HANDLE failed for fd errono: 22 (Invalid argument) drm fd: 6 fd: 49

GBM_ERR::msmgbm_bo_import_gbm_buf(1633)::DRM_IOCTL_PRIME_FD_TO_HANDLE failed for metadatadata fd errono: 22 (Invalid argument) drm fd: 6 metadata fd: 50

Camera timestamp: 319881948040017
Buffer written to file system: /opt/frame_319881948040017.raw
GBM_ERR::msmgbm_bo_import_gbm_buf(1605)::DRM_IOCTL_PRIME_FD_TO_HANDLE failed for fd errono: 22 (Invalid argument) drm fd: 6 fd: 51

GBM_ERR::msmgbm_bo_import_gbm_buf(1633)::DRM_IOCTL_PRIME_FD_TO_HANDLE failed for metadatadata fd errono: 22 (Invalid argument) drm fd: 6 metadata fd: 52

Camera timestamp: 319881981601683
Buffer written to file system: /opt/frame_319881981601683.raw
GBM_ERR::msmgbm_bo_import_gbm_buf(1605)::DRM_IOCTL_PRIME_FD_TO_HANDLE failed for fd errono: 22 (Invalid argument) drm fd: 6 fd: 53

GBM_ERR::msmgbm_bo_import_gbm_buf(1633)::DRM_IOCTL_PRIME_FD_TO_HANDLE failed for metadatadata fd errono: 22 (Invalid argument) drm fd: 6 metadata fd: 54

Camera timestamp: 319882031701683
Buffer written to file system: /opt/frame_319882031701683.raw
拿到raw图大小是19456000,ls -l /opt/frame_319882031701683.raw
-rw-r--r--. 1 root root 19456000 Oct 28 01:13 /opt/frame_319882031701683.raw

 

这个raw 图怎么解析?打印的sensor 的宽高是4056x3040

 

...全文
150 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_38498942 2025-11-24
  • 打赏
  • 举报
回复

你拿到的那个 .raw 其实不是纯粹宽×高×bitdepth 的紧凑数据,QCM6490 的 camera HAL 会在每行做对齐(stride 对齐),所以文件大小会比 4056×3040×bitdepth 计算出来的大。

以你这个 19,456,000 字节为例:

stride = 文件大小 / 30406400 bytes

也就是说每一行占用 6400 字节,而真正有效像素只有 4056,其余都是 padding。这是高通 ISP 很常见的行为。

格式一般是 RAW12 存在 16bit 容器里(LE),只是有效位是 12bit,上位 4bit 是 0 或噪声。解析流程大概就是:

  1. uint16 读文件
  2. reshape 成 (3040, 6400/2)
  3. 把每行后面的 padding 去掉,只保留前 4056 像素
  4. 根据需要把 16bit 缩到 12bit (value & 0x0FFF)
  5. 按你的 Bayer Pattern(比如 RGGB)去 demosaic

简单示例(Python):

import numpy as np

w, h = 4056, 3040
stride = 6400

raw = np.fromfile("frame.raw", dtype=np.uint16).reshape(h, stride//2)
img = raw[:, :w] & 0x0FFF   # 去 padding + 12bit

# 如果要可视化
import cv2
rgb = cv2.cvtColor(img, cv2.COLOR_BayerRG2BGR)  # 根据 pattern 改
cv2.imwrite("out.png", rgb >> 4)

核心点就是:
**QCM6490 的 raw 行宽是有 stride 的,不是紧凑存储。先根据实际文件大小算 stride,再切掉 padding 就能正常解析了。

7,309

社区成员

发帖
与我相关
我的任务
社区描述
本论坛以AI、WoS 、XR、IoT、Auto、生成式AI等核心板块组成,为开发者提供便捷及高效的学习和交流平台。 高通开发者专区主页:https://qualcomm.csdn.net/
人工智能物联网机器学习 技术论坛(原bbs) 北京·东城区
社区管理员
  • csdnsqst0050
  • chipseeker
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧