Skip to content

Commit 889c197

Browse files
committed
sample: drivers: video: capture: add support for the video shell
Modify the capture sample to only run the video shell when the user enables it with -DCONFIG_VIDEO_SHELL=y, as an alternative way to trigger captures. Signed-off-by: Josuah Demangeon <me@josuah.net>
1 parent 33489af commit 889c197

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

samples/drivers/video/capture/README.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,29 @@ using the :ref:`dvp_20pin_ov7670` and :ref:`lcd_par_s035` connected to the board
8383
:goals: build
8484
:compact:
8585

86+
For :ref:`native_sim`, build this sample application with the following commands:
87+
88+
.. zephyr-app-commands::
89+
:zephyr-app: samples/drivers/video/capture
90+
:board: native_sim
91+
:goals: build
92+
:compact:
93+
8694
For testing purpose without the need of any real video capture and/or display hardwares,
8795
a video software pattern generator is supported by the above build commands without
8896
specifying the shields.
8997

98+
For controlling the camera device using shell commands instead of continuously capturing the data,
99+
append ``-DCONFIG_VIDEO_SHELL=y`` to the build command:
100+
101+
.. zephyr-app-commands::
102+
:zephyr-app: samples/drivers/video/capture
103+
:board: mimxrt1064_evk
104+
:shield: dvp_fpc24_mt9m114,rk043fn66hs_ctg
105+
:gen-args: -DCONFIG_VIDEO_SHELL=y
106+
:goals: build
107+
:compact:
108+
90109
Sample Output
91110
=============
92111

@@ -118,6 +137,28 @@ Sample Output
118137
119138
<repeats endlessly>
120139
140+
If using the shell, the capture would not start, and instead it is possible to access the shell
141+
142+
.. code-block:: console
143+
144+
uart:~$ video
145+
video - Video driver commands
146+
Subcommands:
147+
start : Start a video device and its sources
148+
Usage: video start <device>
149+
stop : Stop a video device and its sources
150+
Usage: video stop <device>
151+
capture : Capture a given number of frames from a device
152+
Usage: video capture <device> <num-frames>
153+
format : Query or set the video format of a device
154+
Usage: video format <device> <ep> [<fourcc> <width>x<height>]
155+
frmival : Query or set the video frame rate/interval of a device
156+
Usage: video frmival <device> <ep> [<n>fps|<n>ms|<n>us]
157+
ctrl : Query or set video controls of a device
158+
Usage: video ctrl <device> [<ctrl> <value>]
159+
uart:~$
160+
161+
121162
References
122163
**********
123164

samples/drivers/video/capture/sample.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,21 @@ tests:
3636
integration_platforms:
3737
- mimxrt1064_evk
3838
- mimxrt1170_evk/mimxrt1176/cm7
39+
sample.video.capture.shell:
40+
tags:
41+
- video
42+
- samples
43+
- shell
44+
extra_configs:
45+
- CONFIG_VIDEO_SHELL=y
46+
- CONFIG_FPU=y
47+
- CONFIG_DISPLAY=n
48+
harness: console
49+
harness_config:
50+
type: one_line
51+
regex:
52+
- "Letting the user control the device with the video shell"
53+
platform_allow:
54+
- native_sim/native/64
55+
integration_platforms:
56+
- native_sim/native/64

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ int main(void)
100100
int i = 0;
101101
int err;
102102

103+
/* When the video shell is enabled, do not run the capture loop */
104+
if (IS_ENABLED(CONFIG_VIDEO_SHELL)) {
105+
LOG_INF("Letting the user control the device with the video shell");
106+
return 0;
107+
}
108+
103109
#if DT_HAS_CHOSEN(zephyr_camera)
104110
const struct device *const video_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_camera));
105111

0 commit comments

Comments
 (0)