Skip to content

Commit 073df9d

Browse files
JianyuWang0623anchao
authored andcommitted
examples/uvc_cam: add UVC camera streaming app
Usage: uvc_cam [nframes] [video_dev] [uvc_dev] V4L2 capture -> write UVC gadget device. Uses boardctl to initialize/deinitialize UVC gadget. Queries sensor pixel format, resolution and frame rate via V4L2. Uses poll() to wait for USB host streaming state. Supports optional device path arguments (default /dev/video0, /dev/uvc0). Supports configurable frame count (0=infinite). Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
1 parent dc4ecc9 commit 073df9d

5 files changed

Lines changed: 608 additions & 0 deletions

File tree

examples/uvc_cam/CMakeLists.txt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# ##############################################################################
2+
# apps/examples/uvc_cam/CMakeLists.txt
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
7+
# license agreements. See the NOTICE file distributed with this work for
8+
# additional information regarding copyright ownership. The ASF licenses this
9+
# file to you under the Apache License, Version 2.0 (the "License"); you may not
10+
# use this file except in compliance with the License. You may obtain a copy of
11+
# the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations under
19+
# the License.
20+
#
21+
# ##############################################################################
22+
23+
if(CONFIG_EXAMPLES_UVC_CAM)
24+
nuttx_add_application(
25+
NAME
26+
${CONFIG_EXAMPLES_UVC_CAM_PROGNAME}
27+
PRIORITY
28+
${CONFIG_EXAMPLES_UVC_CAM_PRIORITY}
29+
STACKSIZE
30+
${CONFIG_EXAMPLES_UVC_CAM_STACKSIZE}
31+
MODULE
32+
${CONFIG_EXAMPLES_UVC_CAM}
33+
SRCS
34+
uvc_cam_main.c)
35+
endif()

examples/uvc_cam/Kconfig

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#
2+
# For a description of the syntax of this configuration file,
3+
# see the file kconfig-language.txt in the NuttX tools repository.
4+
#
5+
6+
config EXAMPLES_UVC_CAM
7+
tristate "UVC Camera streaming example"
8+
default n
9+
depends on USBUVC && VIDEO
10+
---help---
11+
Captures frames from V4L2 camera and streams to USB host
12+
via UVC gadget driver (/dev/uvc0).
13+
14+
if EXAMPLES_UVC_CAM
15+
16+
config EXAMPLES_UVC_CAM_PROGNAME
17+
string "Program name"
18+
default "uvc_cam"
19+
20+
config EXAMPLES_UVC_CAM_PRIORITY
21+
int "Task priority"
22+
default 100
23+
24+
config EXAMPLES_UVC_CAM_STACKSIZE
25+
int "Stack size"
26+
default 4096
27+
28+
config EXAMPLES_UVC_CAM_NFRAMES
29+
int "Number of frames (0=infinite)"
30+
default 0
31+
32+
endif

examples/uvc_cam/Make.defs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
############################################################################
2+
# apps/examples/uvc_cam/Make.defs
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more
7+
# contributor license agreements. See the NOTICE file distributed with
8+
# this work for additional information regarding copyright ownership. The
9+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
# "License"); you may not use this file except in compliance with the
11+
# License. You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations
19+
# under the License.
20+
#
21+
############################################################################
22+
23+
ifneq ($(CONFIG_EXAMPLES_UVC_CAM),)
24+
CONFIGURED_APPS += $(APPDIR)/examples/uvc_cam
25+
endif

examples/uvc_cam/Makefile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
############################################################################
2+
# apps/examples/uvc_cam/Makefile
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more
7+
# contributor license agreements. See the NOTICE file distributed with
8+
# this work for additional information regarding copyright ownership. The
9+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
# "License"); you may not use this file except in compliance with the
11+
# License. You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations
19+
# under the License.
20+
#
21+
############################################################################
22+
23+
include $(APPDIR)/Make.defs
24+
25+
# UVC Camera streaming application
26+
27+
PROGNAME = $(CONFIG_EXAMPLES_UVC_CAM_PROGNAME)
28+
PRIORITY = $(CONFIG_EXAMPLES_UVC_CAM_PRIORITY)
29+
STACKSIZE = $(CONFIG_EXAMPLES_UVC_CAM_STACKSIZE)
30+
MODULE = $(CONFIG_EXAMPLES_UVC_CAM)
31+
32+
MAINSRC = uvc_cam_main.c
33+
34+
include $(APPDIR)/Application.mk

0 commit comments

Comments
 (0)