Skip to content

Commit 0c21bc2

Browse files
committed
samples: drivers: video: improve the video capture sample
Set proper value for some resources. Use configurable fps. Signed-off-by: Aiden Hu <[email protected]>
1 parent f428572 commit 0c21bc2

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

samples/drivers/video/capture/boards/rd_rw612_bga.conf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ CONFIG_USB_HOST_STACK=y
33
CONFIG_USBH_VIDEO_CLASS=y
44

55
# Video buffer configuration
6-
CONFIG_VIDEO_BUFFER_POOL_SZ_MAX=154000
7-
CONFIG_VIDEO_BUFFER_POOL_NUM_MAX=2
6+
CONFIG_VIDEO_BUFFER_POOL_SZ_MAX=116000
7+
CONFIG_VIDEO_BUFFER_POOL_NUM_MAX=6
88
CONFIG_VIDEO_BUFFER_POOL_ALIGN=32
99

1010

1111
# Memory configuration for USB transfers
12-
CONFIG_HEAP_MEM_POOL_SIZE=70000
13-
CONFIG_MAIN_STACK_SIZE=80960
12+
CONFIG_HEAP_MEM_POOL_SIZE=40960
13+
CONFIG_MAIN_STACK_SIZE=10240
1414
CONFIG_USBH_USB_DEVICE_HEAP=8912
15-
CONFIG_UHC_BUF_POOL_SIZE=4096
15+
CONFIG_UHC_BUF_POOL_SIZE=4096

samples/drivers/video/capture/prj.conf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ CONFIG_REQUIRES_FLOAT_PRINTF=y
1111
CONFIG_DEBUG_OPTIMIZATIONS=y
1212
CONFIG_USBH_VIDEO_LOG_LEVEL_WRN=y
1313
CONFIG_VIDEO_FRAME_WIDTH=320
14-
CONFIG_VIDEO_FRAME_HEIGHT=240
14+
CONFIG_VIDEO_FRAME_HEIGHT=180
15+
CONFIG_VIDEO_TARGET_FPS=15
16+
CONFIG_USBH_VIDEO_MULTIPLE_PRIME_COUNT=8

samples/drivers/video/capture/src/main.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,18 @@ int main(void)
399399
fie.index++;
400400
}
401401

402+
#if CONFIG_VIDEO_TARGET_FPS > 0
403+
frmival.denominator = CONFIG_VIDEO_TARGET_FPS;
404+
frmival.numerator = 1;
405+
if (!video_set_frmival(uvc_host, &frmival)) {
406+
/* Get the actual frame rate that was set */
407+
if (!video_get_frmival(uvc_host, &frmival)) {
408+
LOG_INF("- Target frame rate set to: %f fps",
409+
1.0 * frmival.denominator / frmival.numerator);
410+
}
411+
}
412+
#endif
413+
402414
/* Get supported controls */
403415
LOG_INF("- Supported controls:");
404416
const struct device *last_dev = NULL;
@@ -456,7 +468,6 @@ int main(void)
456468
break;
457469
}
458470

459-
/* TODO: CONFIG_VIDEO_BUFFER_POOL_NUM_MAX is 1 now, consider to use multiple video buffers */
460471
for (i = 0; i < CONFIG_VIDEO_BUFFER_POOL_NUM_MAX; i++) {
461472
/*
462473
* For some hardwares, such as the PxP used on i.MX RT1170 to do image rotation,

0 commit comments

Comments
 (0)