工具与软件:
专家、您好!
我正在尝试使用 v4l2和 viss 模块创建一个用于 IMX568摄像头(摄像头的 Linux 驱动程序在内部开发)的简单图形(请参阅下面的代码)。
我们使用的是 SDK 09_02_00_05和 edgeai-app-stack 存储库:b6ff3ac11bf1c672eaa63f6dfadfa819da02c4b9。
目前最终的 YUV 图像非常模糊。
原始图像和 viss 模块输出:
我已经分离了 v4l2和 vis 模块。 仅使用 VISS 模块(从文件中读取原始图像)可以很好地工作。 使用 v4l2模块并从 v4l2_capture_module 内 tiovx_Buffer->handle 中映射 dma 也得出了一个好的原始图像。 这些模块之间的一些东西似乎会扭曲原始图像、或者在 v4l2模块中发生了一些我不理解的其他事情。
我已经尝试将 fps 降低到~30并更改图形调度、但问题仍然存在。
任何帮助或见解都会有所帮助! 非常感谢!
此致、
Andras
代码:
#include <stdio.h> #include <stdlib.h> #include <getopt.h> #include <unistd.h> #include <TI/tivx.h> #include <tiovx_modules.h> #include <v4l2_capture_module.h> #include <tiovx_utils.h> #include <app_init.h> #define APP_BUFQ_DEPTH (7) //#define APP_NUM_CH (1) #define APP_NUM_ITERATIONS (20) #define INPUT_WIDTH (1236) #define INPUT_HEIGHT (1032) #define SENSOR_NAME "SENSOR_SONY_IMX568" #define DCC_VISS "/opt/imaging/imx568/linear/dcc_viss.bin" int main(int argc, char *argv[]) { int32_t statusInit = 0; statusInit = appInit(); if (statusInit) { printf("App init error!\n"); } vx_status status = VX_FAILURE; GraphObj graph; NodeObj *node = NULL; TIOVXVissNodeCfg cfg; BufPool *in_buf_pool = NULL, *out_buf_pool = NULL; Buf *inbuf = NULL, *outbuf = NULL; char* output_filename; v4l2CaptureCfg v4l2_capture_cfg; v4l2CaptureHandle *v4l2_capture_handle; tiovx_viss_init_cfg(&cfg); sprintf(cfg.sensor_name, SENSOR_NAME); snprintf(cfg.dcc_config_file, TIVX_FILEIO_FILE_PATH_LENGTH, "%s", DCC_VISS); cfg.width = INPUT_WIDTH; cfg.height = INPUT_HEIGHT; sprintf(cfg.target_string, TIVX_TARGET_VPAC_VISS1); cfg.input_cfg.params.format[0].pixel_container = TIVX_RAW_IMAGE_8_BIT; cfg.input_cfg.params.format[0].msb = 7; status = tiovx_modules_initialize_graph(&graph); if(VX_SUCCESS != status) { printf("Init graph error!\n"); } node = tiovx_modules_add_node(&graph, TIOVX_VISS, (void *)&cfg); node->sinks[0].bufq_depth = APP_BUFQ_DEPTH; graph.schedule_mode = VX_GRAPH_SCHEDULE_MODE_QUEUE_AUTO; status = tiovx_modules_verify_graph(&graph); if (VX_SUCCESS != status) { printf("Verify graph error!\n"); } in_buf_pool = node->sinks[0].buf_pool; out_buf_pool = node->srcs[0].buf_pool; v4l2_capture_init_cfg(&v4l2_capture_cfg); v4l2_capture_cfg.width = INPUT_WIDTH; v4l2_capture_cfg.height = INPUT_HEIGHT; v4l2_capture_cfg.pix_format = V4L2_PIX_FMT_SRGGB8; v4l2_capture_cfg.bufq_depth = APP_BUFQ_DEPTH + 1; sprintf(v4l2_capture_cfg.device, "/dev/video-imx568-cam0"); v4l2_capture_handle = v4l2_capture_create_handle(&v4l2_capture_cfg); for (int i = 0; i < APP_BUFQ_DEPTH; i++) { inbuf = tiovx_modules_acquire_buf(in_buf_pool); v4l2_capture_enqueue_buf(v4l2_capture_handle, inbuf); } v4l2_capture_start(v4l2_capture_handle); for (int j = 0; j < 2; j++) { inbuf = v4l2_capture_dqueue_buf(v4l2_capture_handle); tiovx_modules_enqueue_buf(inbuf); } for (int i = 1; i < APP_NUM_ITERATIONS; i++) { do { inbuf = v4l2_capture_dqueue_buf(v4l2_capture_handle); } while (inbuf == NULL); tiovx_modules_enqueue_buf(inbuf); outbuf = tiovx_modules_acquire_buf(out_buf_pool); tiovx_modules_enqueue_buf(outbuf); //tiovx_modules_schedule_graph(&graph); //tiovx_modules_wait_graph(&graph); inbuf = tiovx_modules_dequeue_buf(in_buf_pool); outbuf = tiovx_modules_dequeue_buf(out_buf_pool); v4l2_capture_enqueue_buf(v4l2_capture_handle, inbuf); if ((i % 5) == 0) { sprintf(output_filename, "/opt/tiovx-imx568/output/imx568_1236x1032_%d.yuv", i); writeImage(output_filename, (vx_image)outbuf->handle); } tiovx_modules_release_buf(outbuf); } v4l2_capture_stop(v4l2_capture_handle); v4l2_capture_delete_handle(v4l2_capture_handle); tiovx_modules_clean_graph(&graph); printf("Running test successful!\n"); appDeInit(); return status; }
代码输出:
APP: Init ... !!! MEM: Init ... !!! MEM: Initialized DMA HEAP (fd=5) !!! MEM: Init ... Done !!! IPC: Init ... !!! IPC: Init ... Done !!! REMOTE_SERVICE: Init ... !!! REMOTE_SERVICE: Init ... Done !!! 30.807099 s: GTC Frequency = 200 MHz APP: Init ... Done !!! 30.810698 s: VX_ZONE_INIT:Enabled 30.810731 s: VX_ZONE_ERROR:Enabled 30.810746 s: VX_ZONE_WARNING:Enabled 30.813495 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:116] Added target MPU-0 30.813642 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:116] Added target MPU-1 30.813738 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:116] Added target MPU-2 30.813893 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:116] Added target MPU-3 30.813919 s: VX_ZONE_INIT:[tivxInitLocal:136] Initialization Done !!! 30.819293 s: VX_ZONE_INIT:[tivxHostInitLocal:101] Initialization Done for HOST !!! Running test successful! 33.497632 s: VX_ZONE_INIT:[tivxHostDeInitLocal:115] De-Initialization Done for HOST !!! 33.502108 s: VX_ZONE_INIT:[tivxDeInitLocal:204] De-Initialization Done !!! APP: Deinit ... !!! REMOTE_SERVICE: Deinit ... !!! REMOTE_SERVICE: Deinit ... Done !!! IPC: Deinit ... !!! IPC: DeInit ... Done !!! MEM: Deinit ... !!! DDR_SHARED_MEM: Alloc's: 13 alloc's of 16116181 bytes DDR_SHARED_MEM: Free's : 13 free's of 16116181 bytes DDR_SHARED_MEM: Open's : 0 allocs of 0 bytes MEM: Deinit ... Done !!! APP: Deinit ... Done !!!