├── .clang-format
├── .gitignore
├── .gitmodules
├── .travis.yml
├── LICENSE
├── Makefile.am
├── README.md
├── autogen.sh
├── configure.ac
├── dronecode-camera-manager.service.in
├── m4
├── .gitignore
├── attributes.m4
└── ax_cxx_compile_stdcxx.m4
├── plugins
├── AeroAtomIspCamera
│ ├── CameraDeviceAeroAtomIsp.cpp
│ ├── CameraDeviceAeroAtomIsp.h
│ ├── PluginAeroAtomIsp.cpp
│ └── PluginAeroAtomIsp.h
├── CustomCamera
│ ├── CameraDeviceCustom.cpp
│ ├── CameraDeviceCustom.h
│ ├── PluginCustom.cpp
│ └── PluginCustom.h
├── GazeboCamera
│ ├── CameraDeviceGazebo.cpp
│ ├── CameraDeviceGazebo.h
│ ├── PluginGazebo.cpp
│ └── PluginGazebo.h
├── RealSenseCamera
│ ├── CameraDeviceRealSense.cpp
│ ├── CameraDeviceRealSense.h
│ ├── PluginRealSense.cpp
│ └── PluginRealSense.h
└── V4l2Camera
│ ├── CameraDeviceV4l2.cpp
│ ├── CameraDeviceV4l2.h
│ ├── PluginV4l2.cpp
│ └── PluginV4l2.h
├── samples
├── config
│ ├── aero.conf
│ ├── config.sample
│ ├── gazebo.conf
│ ├── picam.conf
│ └── ubuntu.conf
└── def
│ ├── camera-def-gazebo.xml
│ ├── camera-def-picam.xml
│ ├── camera-def-rs-rgb.xml
│ └── camera-def-uvc.xml
├── src
├── CameraComponent.cpp
├── CameraComponent.h
├── CameraDevice.h
├── CameraParameters.cpp
├── CameraParameters.h
├── CameraServer.cpp
├── CameraServer.h
├── ImageCapture.h
├── ImageCaptureGst.cpp
├── ImageCaptureGst.h
├── PluginBase.h
├── PluginManager.cpp
├── PluginManager.h
├── VideoCapture.h
├── VideoCaptureGst.cpp
├── VideoCaptureGst.h
├── VideoStream.h
├── VideoStreamRtsp.cpp
├── VideoStreamRtsp.h
├── VideoStreamUdp.cpp
├── VideoStreamUdp.h
├── avahi_publisher.cpp
├── avahi_publisher.h
├── conf_file.cpp
├── conf_file.h
├── glib_mainloop.cpp
├── glib_mainloop.h
├── log.cpp
├── log.h
├── macro.h
├── main.cpp
├── mainloop.cpp
├── mainloop.h
├── mavlink_server.cpp
├── mavlink_server.h
├── pollable.cpp
├── pollable.h
├── settings.cpp
├── settings.h
├── socket.cpp
├── socket.h
├── util.c
├── util.h
├── v4l2_interface.cpp
└── v4l2_interface.h
├── test
├── test_camera_parameters.cpp
├── test_mavlink_protocol.cpp
└── test_rtsp_udp_stream_discovery.cpp
├── tools
├── checkpatch
├── export_v4l2_param_xml
│ ├── Makefile
│ └── export_v4l2_param_xml.cpp
└── git-clang-format
└── valgrind.supp
/.clang-format:
--------------------------------------------------------------------------------
1 | ---
2 | BasedOnStyle: WebKit
3 |
4 | AlignAfterOpenBracket: true
5 | AlignEscapedNewlinesLeft: true
6 | AlignTrailingComments: true
7 | AllowShortBlocksOnASingleLine: false
8 | AllowShortFunctionsOnASingleLine: Inline
9 | ColumnLimit: 100
10 | Cpp11BracedListStyle: true
11 | DerivePointerAlignment: false
12 | IndentCaseLabels: false
13 | Language: Cpp
14 | NamespaceIndentation: None
15 | PointerAlignment: Right
16 | SortIncludes: true
17 | SpaceAfterCStyleCast: false
18 | SpaceInEmptyParentheses: false
19 | Standard: Cpp11
20 | TabWidth: 4
21 | ...
22 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.o
2 | *.lo
3 | *.la
4 | *.a
5 | /*.tar.xz
6 | /*.md5sum
7 | .deps/
8 | .libs/
9 | .dirstamp
10 | /Makefile
11 | Makefile.in
12 |
13 | /aclocal.m4
14 | /autom4te.cache
15 | /build-aux/
16 | /dronecode-camera-manager.service
17 | /config.h
18 | /config.h.in
19 | /config.log
20 | /config.status
21 | /configure
22 | /include/mavlink
23 | /libtool
24 | /perf.data
25 | /perf.data.old
26 | /stamp-h1
27 |
28 | *~
29 | .*.swp
30 | cscope.out
31 | tags
32 |
33 | /dcm
34 | /test/test-camera-parameters
35 | /test/test-custom-stream
36 | /test/test-mavlink-protocol
37 | /test/test-rtsp-udp-stream-discovery
38 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "modules/mavlink"]
2 | path = modules/mavlink
3 | url = https://github.com/mavlink/mavlink.git
4 | branch = master
5 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: generic
2 |
3 | services: docker
4 |
5 | before_install:
6 | - CONTAINER=$(docker run -it -d -v $PWD:/build ubuntu:16.04 /bin/bash)
7 | - docker exec -i $CONTAINER /bin/bash -c "apt-get update -qq && apt-get install -y -qq libavahi-glib-dev libavahi-client-dev libavahi-core-dev libgstreamer1.0-dev libgstrtspserver-1.0-dev libgstreamer-plugins-base1.0-dev build-essential autoconf libtool wget libgstrtspserver-1.0-dev python2.7 python-future"
8 | - docker exec -i $CONTAINER /bin/bash -c "apt-get update -qq && apt-get install -y -qq software-properties-common python-software-properties"
9 | - docker exec -i $CONTAINER /bin/bash -c "add-apt-repository http://packages.osrfoundation.org/gazebo/ubuntu && wget --quiet http://packages.osrfoundation.org/gazebo.key -O - | apt-key add -"
10 | - docker exec -i $CONTAINER /bin/bash -c "apt-get update -qq && apt-get install -y -qq libgazebo8-dev"
11 | - docker exec -i $CONTAINER /bin/bash -c "add-apt-repository http://realsense-alm-public.s3.amazonaws.com/apt-repo | apt-key adv --keyserver keys.gnupg.net --recv-key D6FB2970"
12 | - docker exec -i $CONTAINER /bin/bash -c "apt-get update -qq && apt-get install -y -qq librealsense-dev"
13 |
14 | script:
15 | - docker exec -i $CONTAINER /bin/bash -c "cd /build && ./autogen.sh c --with-systemdsystemunitdir=/usr/lib/systemd/system && make -j && make -j test"
16 | - docker exec -i $CONTAINER /bin/bash -c "cd /build && make distclean && ./autogen.sh c --with-systemdsystemunitdir=/usr/lib/systemd/system --enable-aero --enable-realsense && make -j && make -j test"
17 | - docker exec -i $CONTAINER /bin/bash -c "cd /build && make distclean && ./autogen.sh c --with-systemdsystemunitdir=/usr/lib/systemd/system --enable-aero --enable-realsense --enable-mavlink --enable-avahi && make -j && make -j test"
18 | - docker exec -i $CONTAINER /bin/bash -c "cd /build && make distclean && ./autogen.sh c --with-systemdsystemunitdir=/usr/lib/systemd/system --enable-mavlink --enable-realsense --enable-avahi && make -j && make -j test"
19 | - docker exec -i $CONTAINER /bin/bash -c "cd /build && make distclean && ./autogen.sh c --with-systemdsystemunitdir=/usr/lib/systemd/system --enable-gazebo --enable-mavlink && make -j && make -j test"
20 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 |
3 | Version 2.0, January 2004
4 |
5 | http://www.apache.org/licenses/
6 |
7 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8 |
9 | 1. Definitions.
10 |
11 | "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
16 |
17 | "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
18 |
19 | "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
20 |
21 | "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
22 |
23 | "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
24 |
25 | "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
26 |
27 | "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
28 |
29 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
30 |
31 | 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
32 |
33 | 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
34 |
35 | 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
36 |
37 | You must give any other recipients of the Work or Derivative Works a copy of this License; and
38 | You must cause any modified files to carry prominent notices stating that You changed the files; and
39 | You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
40 | If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
41 |
42 | You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
43 |
44 | 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
45 |
46 | 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
47 |
48 | 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
49 |
50 | 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
51 |
52 | 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
53 |
54 | END OF TERMS AND CONDITIONS
55 |
--------------------------------------------------------------------------------
/Makefile.am:
--------------------------------------------------------------------------------
1 | DISTCLEAN_LOCAL_HOOKS =
2 | EXTRA_DIST =
3 | CLEANFILES = $(BUILT_FILES)
4 | noinst_LTLIBRARIES =
5 | bin_PROGRAMS =
6 | noinst_PROGRAMS =
7 | noinst_SCRIPTS =
8 | BUILT_FILES =
9 | ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
10 | AM_MAKEFLAGS = --no-print-directory
11 |
12 | GCC_COLORS ?= 'yes'
13 | export GCC_COLORS
14 |
15 | BUILT_SOURCES =
16 | test_deps =
17 |
18 | clean-local:
19 | rm -rf $(top_builddir)/include/mavlink
20 | rm -rf $(EXTRA_PROGRAMS)
21 |
22 | #if SYSTEMD
23 | systemdsystemunitdir = @SYSTEMD_SYSTEMUNITDIR@
24 | systemdsystemunit_DATA = dronecode-camera-manager.service
25 | #endif
26 |
27 |
28 | AM_CPPFLAGS = \
29 | -include $(abs_top_builddir)/config.h \
30 | -DSYSCONFDIR=\""$(sysconfdir)"\"
31 |
32 | AM_CFLAGS = \
33 | -pipe \
34 | -Wall \
35 | -W \
36 | -Wextra \
37 | -Wno-inline \
38 | -Wundef \
39 | -Wformat=2 \
40 | -Wlogical-op \
41 | -Wsign-compare \
42 | -Wformat-security \
43 | -Wmissing-include-dirs \
44 | -Wformat-nonliteral \
45 | -Wold-style-definition \
46 | -Wpointer-arith \
47 | -Winit-self \
48 | -Wdeclaration-after-statement \
49 | -Wfloat-equal \
50 | -Wmissing-prototypes \
51 | -Wstrict-prototypes \
52 | -Wredundant-decls \
53 | -Wmissing-declarations \
54 | -Wmissing-noreturn \
55 | -Wshadow \
56 | -Wendif-labels \
57 | -Wstrict-aliasing=3 \
58 | -Wwrite-strings \
59 | -Wno-long-long \
60 | -Wno-overlength-strings \
61 | -Wno-unused-parameter \
62 | -Wno-missing-field-initializers \
63 | -Wno-unused-result \
64 | -Wnested-externs \
65 | -Wchar-subscripts \
66 | -Wtype-limits \
67 | -Wuninitialized \
68 | -fno-common \
69 | -fdiagnostics-show-option \
70 | -fvisibility=hidden \
71 | -ffunction-sections \
72 | -fdata-sections \
73 | ${GST_CFLAGS}
74 |
75 | AM_CXXFLAGS = \
76 | -I$(top_builddir)/src \
77 | -I$(srcdir)/ \
78 | -pipe \
79 | -Wall \
80 | -W \
81 | -Wextra \
82 | -Wno-inline \
83 | -Wundef \
84 | -Wformat=2 \
85 | -Wlogical-op \
86 | -Wsign-compare \
87 | -Wformat-security \
88 | -Wmissing-include-dirs \
89 | -Wformat-nonliteral \
90 | -Wpointer-arith \
91 | -Winit-self \
92 | -Wfloat-equal \
93 | -Wredundant-decls \
94 | -Wmissing-declarations \
95 | -Wmissing-noreturn \
96 | -Wshadow \
97 | -Wendif-labels \
98 | -Wstrict-aliasing=3 \
99 | -Wwrite-strings \
100 | -Wno-long-long \
101 | -Wno-overlength-strings \
102 | -Wno-unused-parameter \
103 | -Wno-missing-field-initializers \
104 | -Wno-unused-result \
105 | -Wchar-subscripts \
106 | -Wtype-limits \
107 | -Wuninitialized \
108 | -fno-common \
109 | -fdiagnostics-show-option \
110 | -fvisibility=hidden \
111 | -ffunction-sections \
112 | -fdata-sections \
113 | ${GST_CFLAGS}
114 |
115 | AM_LDFLAGS = \
116 | -Wl,--as-needed \
117 | -Wl,--no-undefined \
118 | -Wl,--gc-sections
119 |
120 | BASE_FILES = \
121 | src/conf_file.cpp \
122 | src/conf_file.h \
123 | src/glib_mainloop.cpp \
124 | src/glib_mainloop.h \
125 | src/log.cpp \
126 | src/log.h \
127 | src/macro.h \
128 | src/mainloop.cpp \
129 | src/mainloop.h \
130 | src/pollable.cpp \
131 | src/pollable.h \
132 | src/socket.cpp \
133 | src/socket.h \
134 | src/util.c \
135 | src/util.h \
136 | src/CameraParameters.cpp \
137 | src/CameraParameters.h \
138 | src/CameraComponent.cpp \
139 | src/CameraComponent.h \
140 | src/CameraServer.cpp \
141 | src/CameraServer.h \
142 | src/CameraDevice.h \
143 | src/ImageCapture.h \
144 | src/ImageCaptureGst.h \
145 | src/ImageCaptureGst.cpp \
146 | src/VideoStream.h \
147 | src/VideoStreamUdp.h \
148 | src/VideoStreamUdp.cpp \
149 | src/VideoStreamRtsp.h \
150 | src/VideoStreamRtsp.cpp \
151 | src/VideoCapture.h \
152 | src/VideoCaptureGst.h \
153 | src/VideoCaptureGst.cpp \
154 | src/PluginManager.h \
155 | src/PluginManager.cpp \
156 | src/PluginBase.h \
157 | src/v4l2_interface.cpp \
158 | src/v4l2_interface.h \
159 | plugins/V4l2Camera/PluginV4l2.h\
160 | plugins/V4l2Camera/PluginV4l2.cpp \
161 | plugins/V4l2Camera/CameraDeviceV4l2.cpp \
162 | plugins/V4l2Camera/CameraDeviceV4l2.h
163 |
164 | if ENABLE_REALSENSE
165 | BASE_FILES += \
166 | plugins/RealSenseCamera/PluginRealSense.h \
167 | plugins/RealSenseCamera/PluginRealSense.cpp \
168 | plugins/RealSenseCamera/CameraDeviceRealSense.h \
169 | plugins/RealSenseCamera/CameraDeviceRealSense.cpp
170 | endif
171 |
172 | if ENABLE_AERO
173 | BASE_FILES += \
174 | plugins/AeroAtomIspCamera/PluginAeroAtomIsp.h \
175 | plugins/AeroAtomIspCamera/PluginAeroAtomIsp.cpp \
176 | plugins/AeroAtomIspCamera/CameraDeviceAeroAtomIsp.h \
177 | plugins/AeroAtomIspCamera/CameraDeviceAeroAtomIsp.cpp
178 | endif
179 |
180 | if ENABLE_CUSTOM
181 | BASE_FILES += \
182 | plugins/CustomCamera/PluginCustom.h \
183 | plugins/CustomCamera/PluginCustom.cpp \
184 | plugins/CustomCamera/CameraDeviceCustom.h \
185 | plugins/CustomCamera/CameraDeviceCustom.cpp
186 | endif
187 |
188 |
189 | bin_PROGRAMS += dcm
190 |
191 | SED_PROCESS = $(AM_V_GEN) $(MKDIR_P) $(dir $@) && \
192 | $(SED) -e 's,@bindir\@,$(bindir),g' \
193 | < $< > $@
194 |
195 | %.service: %.service.in Makefile
196 | $(SED_PROCESS)
197 |
198 |
199 | dcm_SOURCES = \
200 | ${BASE_FILES} \
201 | src/main.cpp
202 |
203 | dcm_LDADD = $(GLIB_LIBS) $(GST_LIBS) $(GZB_LIBS)
204 |
205 | CLEANFILES += dronecode-camera-manager.service
206 |
207 | #Samples
208 | EXTRA_PROGRAMS = test/test-custom-stream
209 |
210 | test_test_custom_stream_LDADD = ${dcm_LDADD}
211 |
212 | test_test_custom_stream_SOURCES = \
213 | $(BASE_FILES) \
214 | src/main.cpp \
215 | plugins/CustomCamera/PluginCustom.cpp \
216 | plugins/CustomCamera/PluginCustom.h \
217 | plugins/CustomCamera/CameraDeviceCustom.cpp \
218 | plugins/CustomCamera/CameraDeviceCustom.h
219 |
220 | if ENABLE_AVAHI
221 | EXTRA_PROGRAMS += test/test-rtsp-udp-stream-discovery
222 | BASE_FILES += \
223 | src/avahi_publisher.cpp \
224 | src/avahi_publisher.h
225 |
226 | AM_CXXFLAGS += ${AVAHI_CFLAGS}
227 | AM_CXXFLAGS += ${AVAHI_CFLAGS}
228 | dcm_LDADD += $(AVAHI_LIBS)
229 |
230 | test_test_rtsp_udp_stream_discovery_SOURCES = \
231 | test/test_rtsp_udp_stream_discovery.cpp \
232 | src/log.cpp \
233 | src/log.h \
234 | src/glib_mainloop.cpp \
235 | src/glib_mainloop.h \
236 | src/mainloop.cpp \
237 | src/mainloop.h
238 |
239 | test_test_rtsp_udp_stream_discovery_LDADD = $(GLIB_LIBS) $(AVAHI_LIBS)
240 | endif
241 |
242 | if ENABLE_MAVLINK
243 |
244 | EXTRA_PROGRAMS += test/test-camera-parameters
245 |
246 | test_test_camera_parameters_SOURCES = \
247 | src/CameraParameters.cpp \
248 | src/CameraParameters.h \
249 | test/test_camera_parameters.cpp \
250 | src/log.cpp \
251 | src/log.h \
252 | src/util.c \
253 | src/util.h
254 |
255 | test_test_camera_parameters_LDADD = $(GLIB_LIBS)
256 |
257 | EXTRA_PROGRAMS += test/test-mavlink-protocol
258 |
259 | BUILT_SOURCES += include/mavlink/ardupilotmega/mavlink.h
260 | include/mavlink/ardupilotmega/mavlink.h: modules/mavlink/pymavlink/tools/mavgen.py modules/mavlink/message_definitions/v1.0/ardupilotmega.xml
261 | $(AM_V_GEN)$(PYTHON) $(srcdir)/modules/mavlink/pymavlink/tools/mavgen.py \
262 | -o include/mavlink \
263 | --lang C \
264 | --wire-protocol 2.0 \
265 | $(srcdir)/modules/mavlink/message_definitions/v1.0/ardupilotmega.xml
266 |
267 | AM_CPPFLAGS += \
268 | -I$(abs_top_builddir)/include/mavlink \
269 | -I$(abs_top_builddir)/include/mavlink/ardupilotmega
270 |
271 | BASE_FILES += \
272 | src/mavlink_server.cpp \
273 | src/mavlink_server.h
274 |
275 | test_test_mavlink_protocol_SOURCES = \
276 | test/test_mavlink_protocol.cpp \
277 | src/log.cpp \
278 | src/log.h \
279 | src/glib_mainloop.cpp \
280 | src/glib_mainloop.h \
281 | src/mainloop.cpp \
282 | src/mainloop.h \
283 | src/pollable.cpp \
284 | src/pollable.h \
285 | src/socket.cpp \
286 | src/socket.h \
287 | src/util.c \
288 | src/util.h
289 |
290 | test_test_mavlink_protocol_LDADD = $(GLIB_LIBS)
291 | if ENABLE_AVAHI
292 | test_test_mavlink_protocol_LDADD += $(AVAHI_LIBS)
293 | endif
294 |
295 | test_deps = test_test_mavlink_protocol_LDADD
296 | endif
297 |
298 | if ENABLE_GAZEBO
299 |
300 | AM_CXXFLAGS += \
301 | ${GZB_CFLAGS}
302 |
303 | BASE_FILES += \
304 | plugins/GazeboCamera/PluginGazebo.h \
305 | plugins/GazeboCamera/PluginGazebo.cpp \
306 | plugins/GazeboCamera/CameraDeviceGazebo.h \
307 | plugins/GazeboCamera/CameraDeviceGazebo.cpp
308 | endif
309 |
310 | .PHONY: test
311 | test: $(test_deps)
312 | $(MAKE) $(EXTRA_PROGRAMS)
313 |
314 | # ------------------------------------------------------------------------------
315 | # coverity
316 | # ------------------------------------------------------------------------------
317 |
318 | #TODO
319 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # THIS REPOSITORY HAS BEEN DEPRECATED
2 |
3 | # Dronecode Camera Manager
4 |
5 | [](https://travis-ci.org/intel/camera-streaming-daemon)
6 |
7 |
9 |
10 |
11 | The [Dronecode Camera Manager](https://camera-manager.dronecode.org/en/) (DCM) is an extensible Linux camera server for interfacing cameras with the Dronecode platform.
12 |
13 | It provides a [MAVLink Camera Protocol](https://mavlink.io/en/protocol/camera.html) compatible API for video and image capture etc., and an RTSP service for advertising and sharing video streams. The server can connect to and manage multiple cameras, and has been designed so that it can be extended to support new camera types and protocols when needed.
14 |
15 | > **Tip** The DCM is the easiest way for Camera OEMs to interface with the Dronecode platform. Many cameras will just work "out of the box". At most OEMs will need to implement a camera integration layer.
16 |
17 | Full instructions for [building](https://camera-manager.dronecode.org/en/getting_started/), [using](https://camera-manager.dronecode.org/en/guide/overview.html), [extending](https://camera-manager.dronecode.org/en/guide/extending.html) and [contributing](https://camera-manager.dronecode.org/en/contribute/) to the camera manager can be found in the [guide](https://camera-manager.dronecode.org/en/).
18 |
--------------------------------------------------------------------------------
/autogen.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | set -e
4 |
5 | oldpwd=$(pwd)
6 | topdir=$(dirname $0)
7 | cd $topdir
8 |
9 | autoreconf --force --install --symlink
10 |
11 | libdir() {
12 | echo $(cd "$1/$(gcc -print-multi-os-directory)"; pwd)
13 | }
14 |
15 | args="\
16 | --sysconfdir=/etc \
17 | --localstatedir=/var \
18 | --libdir=$(libdir /usr/lib) \
19 | "
20 |
21 | if [ -f "$topdir/.config.args" ]; then
22 | args="$args $(cat $topdir/.config.args)"
23 | fi
24 |
25 | if [ ! -L /bin ]; then
26 | args="$args \
27 | --with-rootprefix= \
28 | --with-rootlibdir=$(libdir /lib) \
29 | "
30 | fi
31 |
32 | cd $oldpwd
33 |
34 | if [ $# -ge 1 ]; then
35 | cmd=$1
36 | shift
37 | fi
38 |
39 | args="$args $@"
40 |
41 | if [ "$cmd" = "c" ]; then
42 | $topdir/configure CFLAGS='-g -O2' CXXFLAGS='-g -O2' $args
43 | make clean
44 | elif [ "$cmd" = "g" ]; then
45 | $topdir/configure CFLAGS='-g -Og' CXXFLAGS='-g -O2' $args
46 | make clean
47 | elif [ "$cmd" = "l" ]; then
48 | $topdir/configure CC=clang CXX=clang++ CFLAGS='-g -O2' CXXFLAGS='-g -O2' $args
49 | make clean
50 | elif [ "$cmd" = "a" ]; then
51 | $topdir/configure CFLAGS='-g -O2 -Wsuggest-attribute=pure -Wsuggest-attribute=const' CXXFLAGS='-g -O2 -Wsuggest-attribute=pure -Wsuggest-attribute=const' $args
52 | make clean
53 | elif [ "$cmd" = "s" ]; then
54 | scan-build $topdir/configure CFLAGS='-g -O0 -std=gnu11' CXXFLAGS='-g -O0 -std=gnu++11' $args
55 | scan-build make
56 | else
57 | echo
58 | echo "----------------------------------------------------------------"
59 | echo "Initialized build system. For a common configuration please run:"
60 | echo "----------------------------------------------------------------"
61 | echo
62 | echo "$topdir/configure CFLAGS='-g -O2' CXXFLAGS='-g -O2' $args"
63 | echo
64 | fi
65 |
--------------------------------------------------------------------------------
/configure.ac:
--------------------------------------------------------------------------------
1 | AC_PREREQ(2.64)
2 | AC_INIT([dronecode-camera-manager],
3 | [1],
4 | [],
5 | [dronecode-camera-manager],
6 | [])
7 |
8 | PKG_CHECK_MODULES(GLIB, [glib-2.0])
9 | PKG_CHECK_MODULES(GST, [gstreamer-rtsp-1.0, gstreamer-1.0, gstreamer-rtsp-server-1.0 gstreamer-app-1.0])
10 |
11 | AC_CONFIG_SRCDIR([src/main.cpp])
12 | AC_CONFIG_MACRO_DIR([m4])
13 | AC_CONFIG_HEADERS(config.h)
14 | AC_CONFIG_AUX_DIR([build-aux])
15 | AC_ARG_ENABLE([realsense], AS_HELP_STRING([--enable-realsense], [Enable Realsense Support]),
16 | [
17 | AC_SEARCH_LIBS([rs_create_context], [realsense],
18 | [
19 | enable_realsense=yes
20 | AM_CONDITIONAL([ENABLE_REALSENSE], true)
21 | ],
22 | [
23 | AC_MSG_ERROR([librealsense not installed, cannot enable realsense support])
24 | enable_realsense=no
25 | AM_CONDITIONAL([ENABLE_REALSENSE], false)
26 | ])
27 | ],
28 | [
29 | enable_realsense=no
30 | AM_CONDITIONAL([ENABLE_REALSENSE], false)
31 | ])
32 | AC_ARG_ENABLE([aero], AS_HELP_STRING([--enable-aero], [Include streams specific for Intel Aero drone]),
33 | [
34 | enable_aero=yes
35 | AM_CONDITIONAL([ENABLE_AERO], true)
36 | ],
37 | [
38 | enable_aero=no
39 | AM_CONDITIONAL([ENABLE_AERO], false)
40 | ])
41 |
42 | AC_ARG_ENABLE([custom], AS_HELP_STRING([--enable-custom], [Include custom camera device]),
43 | [
44 | enable_custom=yes
45 | AM_CONDITIONAL([ENABLE_CUSTOM], true)
46 | ],
47 | [
48 | enable_custom=no
49 | AM_CONDITIONAL([ENABLE_CUSTOM], false)
50 | ])
51 |
52 | AC_ARG_ENABLE([mavlink],
53 | AS_HELP_STRING([--enable-mavlink], [Enable MAVLink advertisement]),
54 | [
55 | enable_mavlink=yes
56 | AM_CONDITIONAL([ENABLE_MAVLINK], true)
57 | AC_DEFINE(ENABLE_MAVLINK, 1, [Enable MAVLink advertisement])
58 | ],
59 | [
60 | enable_mavlink=no
61 | AM_CONDITIONAL([ENABLE_MAVLINK], false)
62 | ])
63 |
64 | AC_ARG_ENABLE([avahi],
65 | AS_HELP_STRING([--enable-avahi], [Enable avahi advertisement]),
66 | [
67 | PKG_CHECK_MODULES(AVAHI, [avahi-client, avahi-core, avahi-glib])
68 | enable_avahi=yes
69 | AM_CONDITIONAL([ENABLE_AVAHI], true)
70 | AC_DEFINE(ENABLE_AVAHI, 1, [Enable avahi advertisement])
71 | ],
72 | [
73 | enable_avahi=no
74 | AM_CONDITIONAL([ENABLE_AVAHI], false)
75 | ])
76 |
77 |
78 | AC_ARG_ENABLE([gazebo],
79 | AS_HELP_STRING([--enable-gazebo], [Enable Gazebo Simulator Mode]),
80 | [
81 | PKG_CHECK_MODULES(GZB, [gazebo])
82 | enable_gazebo=yes
83 | AM_CONDITIONAL([ENABLE_GAZEBO], true)
84 | AC_DEFINE(ENABLE_GAZEBO, 1, [Enable Gazebo Simulator Mode])
85 | ],
86 | [
87 | enable_gazebo=no
88 | AM_CONDITIONAL([ENABLE_GAZEBO], false)
89 | ])
90 |
91 |
92 | AC_USE_SYSTEM_EXTENSIONS
93 | AC_SYS_LARGEFILE
94 | AC_PREFIX_DEFAULT([/usr])
95 | PKG_PROG_PKG_CONFIG
96 | AM_MAINTAINER_MODE([enable])
97 | AM_INIT_AUTOMAKE([check-news foreign 1.11 silent-rules tar-pax no-dist-gzip dist-xz subdir-objects color-tests parallel-tests])
98 | AM_SILENT_RULES([yes])
99 |
100 | #####################################################################
101 | # Program checks and configurations
102 | #####################################################################
103 |
104 | AC_PROG_CC_C99
105 | AX_CXX_COMPILE_STDCXX([11], [ext], [mandatory])
106 | AM_PATH_PYTHON([2.7])
107 |
108 | #####################################################################
109 |
110 | LT_INIT([disable-static pic-only])
111 |
112 | #####################################################################
113 | # Function and structure checks
114 | #####################################################################
115 |
116 | AC_MSG_CHECKING([whether _Static_assert() is supported])
117 | AC_COMPILE_IFELSE(
118 | [AC_LANG_SOURCE([[_Static_assert(1, "Test");]])],
119 | [AC_DEFINE([HAVE_STATIC_ASSERT], [1], [Define if _Static_assert() is available])
120 | AC_MSG_RESULT([yes])],
121 | [AC_MSG_RESULT([no])])
122 |
123 | AC_MSG_CHECKING([whether _Noreturn is supported])
124 | AC_COMPILE_IFELSE(
125 | [AC_LANG_SOURCE([[_Noreturn int foo(void) { exit(0); }]])],
126 | [AC_DEFINE([HAVE_NORETURN], [1], [Define if _Noreturn is available])
127 | AC_MSG_RESULT([yes])],
128 | [AC_MSG_RESULT([no])])
129 |
130 |
131 | #####################################################################
132 | # --with-
133 | #####################################################################
134 |
135 | AC_ARG_WITH([rootlibdir],
136 | AS_HELP_STRING([--with-rootlibdir=DIR], [rootfs directory to install shared libraries]),
137 | [], [with_rootlibdir=$libdir])
138 | AC_ARG_WITH([systemdsystemunitdir],
139 | AC_HELP_STRING([--with-systemdsystemunitdir=DIR],
140 | [path to systemd system unit directory]),
141 | [path_systemunitdir=${withval}])
142 | if (test "${enable_systemd}" != "no" && test -z "${path_systemunitdir}"); then
143 | AC_MSG_CHECKING([systemd system unit dir])
144 | path_systemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir systemd`"
145 | if (test -z "${path_systemunitdir}"); then
146 | AC_MSG_ERROR([systemd system unit directory is required])
147 | fi
148 | AC_MSG_RESULT([${path_systemunitdir}])
149 | fi
150 |
151 | AC_SUBST([rootlibdir], [$with_rootlibdir])
152 |
153 | #####################################################################
154 | # --enable-
155 | #####################################################################
156 | AC_ARG_ENABLE(systemd, AC_HELP_STRING([--disable-systemd],
157 | [disable systemd integration]), [enable_systemd=${enableval}])
158 | AM_CONDITIONAL(SYSTEMD, test "${enable_systemd}" != "no")
159 |
160 | #####################################################################
161 | # Default CFLAGS and LDFLAGS
162 | #####################################################################
163 | DEFAULT_FLAGS=" -fstack-protector-all -fPIE -fPIC -O2 -D_FORTIFY_SOURCE=2 -pthread -Wformat -Wformat-security"
164 | CFLAGS+=$DEFAULT_FLAGS
165 | CXXFLAGS+=$DEFAULT_FLAGS
166 | LDFLAGS+=" -z noexecstack -z relro -z now"
167 |
168 | #####################################################################
169 | # Generate files from *.in
170 | #####################################################################
171 |
172 | AC_CONFIG_FILES([
173 | Makefile
174 | ])
175 |
176 | #####################################################################
177 | AC_SUBST(SYSTEMD_SYSTEMUNITDIR, [${path_systemunitdir}])
178 |
179 | AC_OUTPUT
180 | AC_MSG_RESULT([
181 | $PACKAGE $VERSION
182 | ==========================
183 |
184 | prefix: ${prefix}
185 | sysconfdir: ${sysconfdir}
186 | libdir: ${libdir}
187 | rootlibdir: ${rootlibdir}
188 | includedir: ${includedir}
189 | bindir: ${bindir}
190 |
191 | C compiler: ${CC}
192 | C++ compiler: ${CXX}
193 | CFLAGS: ${CFLAGS}
194 | CXXFLAGS: ${CXXFLAGS}
195 | LDFLAGS: ${LDFLAGS}
196 |
197 | RealSense support: $enable_realsense
198 | MAVLink support: $enable_mavlink
199 | AVAHI support: $enable_avahi
200 | Intel Aero support: $enable_aero
201 | Gazebo support: $enable_gazebo
202 | Custom support: $enable_custom
203 | ])
204 |
--------------------------------------------------------------------------------
/dronecode-camera-manager.service.in:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=Dronecode Camera Manager
3 | After=multi-user.target
4 |
5 | [Service]
6 | Type=simple
7 | ExecStart=@bindir@/dcm
8 | Restart=on-failure
9 |
10 | [Install]
11 | WantedBy=multi-user.target
12 |
--------------------------------------------------------------------------------
/m4/.gitignore:
--------------------------------------------------------------------------------
1 | libtool.m4
2 | ltoptions.m4
3 | ltsugar.m4
4 | ltversion.m4
5 | lt~obsolete.m4
6 | gtk-doc.m4
7 |
--------------------------------------------------------------------------------
/plugins/AeroAtomIspCamera/CameraDeviceAeroAtomIsp.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the Dronecode Camera Manager
3 | *
4 | * Copyright (C) 2018 Intel Corporation. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | #pragma once
19 | #include
20 | #include
21 | #include
22 | #include
23 |
24 | #include "CameraDevice.h"
25 | #include "CameraParameters.h"
26 |
27 | class CameraDeviceAeroAtomIsp final : public CameraDevice {
28 | public:
29 | CameraDeviceAeroAtomIsp(std::string device);
30 | ~CameraDeviceAeroAtomIsp();
31 | std::string getDeviceId() const;
32 | Status getInfo(CameraInfo &camInfo) const;
33 | bool isGstV4l2Src() const;
34 | Status init(CameraParameters &camParam);
35 | Status uninit();
36 | Status start();
37 | Status stop();
38 | Status read(CameraData &data);
39 | Status setParam(CameraParameters &camParam, const std::string param, const char *param_value,
40 | const size_t value_size, const int param_type);
41 | Status resetParams(CameraParameters &camParam);
42 | Status setSize(const uint32_t width, const uint32_t height);
43 | Status getSize(uint32_t &width, uint32_t &height) const;
44 | Status getSupportedSizes(std::vector &sizes) const;
45 | Status setPixelFormat(const CameraParameters::PixelFormat format);
46 | Status getPixelFormat(CameraParameters::PixelFormat &format) const;
47 | Status getSupportedPixelFormats(std::vector &formats) const;
48 | Status setMode(const CameraParameters::Mode mode);
49 | Status getMode(CameraParameters::Mode &mode) const;
50 | Status getSupportedModes(std::vector &modes) const;
51 | Status setFrameRate(const uint32_t fps);
52 | Status getFrameRate(uint32_t &fps) const;
53 | Status getSupportedFrameRates(uint32_t &minFps, uint32_t &maxFps) const;
54 | Status setCameraDefinitionUri(const std::string uri);
55 | std::string getCameraDefinitionUri() const;
56 |
57 | private:
58 | CameraDevice::Status init();
59 | Status setState(const CameraDevice::State state);
60 | CameraDevice::State getState() const;
61 | int allocFrameBuffer(int bufCnt, size_t bufSize);
62 | int freeFrameBuffer();
63 | int pollCamera(int fd);
64 | std::string mDeviceId;
65 | std::atomic mState;
66 | uint32_t mWidth;
67 | uint32_t mHeight;
68 | CameraParameters::PixelFormat mPixelFormat;
69 | CameraParameters::Mode mMode;
70 | uint32_t mFrmRate;
71 | std::string mCamDefUri;
72 | std::mutex mLock;
73 | int mFd;
74 | void **mFrameBuffer;
75 | size_t mFrameBufferSize;
76 | uint32_t mFrameBufferCnt;
77 | };
78 |
--------------------------------------------------------------------------------
/plugins/AeroAtomIspCamera/PluginAeroAtomIsp.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the Dronecode Camera Manager
3 | *
4 | * Copyright (C) 2018 Intel Corporation. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | #include
19 | #include
20 |
21 | #include "CameraDeviceAeroAtomIsp.h"
22 | #include "PluginAeroAtomIsp.h"
23 |
24 | static PluginAeroAtomIsp aero;
25 |
26 | PluginAeroAtomIsp::PluginAeroAtomIsp()
27 | : PluginBase()
28 | {
29 | /*
30 | * 1. Discover the list of camera devices for this Plugin Class
31 | * 2. Add the IDs of the devices in the list
32 | */
33 |
34 | discoverCameras(mCamList);
35 | }
36 |
37 | PluginAeroAtomIsp::~PluginAeroAtomIsp()
38 | {
39 | }
40 |
41 | std::vector PluginAeroAtomIsp::getCameraDevices()
42 | {
43 | return mCamList;
44 | }
45 |
46 | std::shared_ptr PluginAeroAtomIsp::createCameraDevice(std::string deviceID)
47 | {
48 | /* check if the device exists in the list */
49 | if (std::find(mCamList.begin(), mCamList.end(), deviceID) == mCamList.end()) {
50 | log_error("Camera Device not found : %s", deviceID.c_str());
51 | return nullptr;
52 | }
53 |
54 | return std::make_shared(deviceID);
55 | }
56 |
57 | void PluginAeroAtomIsp::discoverCameras(std::vector &camList)
58 | {
59 | /*
60 | * Add the logic to discover the camera devices
61 | * For RealSense cameras, its hardcoded
62 | */
63 |
64 | /* Bottom Camera */
65 | camList.push_back("bottom");
66 | /* Front Camera*/
67 | /* camList.push_back("front"); */
68 |
69 | return;
70 | }
71 |
--------------------------------------------------------------------------------
/plugins/AeroAtomIspCamera/PluginAeroAtomIsp.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the Dronecode Camera Manager
3 | *
4 | * Copyright (C) 2018 Intel Corporation. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | #pragma once
19 |
20 | #include
21 | #include
22 |
23 | #include "CameraDevice.h"
24 | #include "PluginBase.h"
25 |
26 | class PluginAeroAtomIsp final : public PluginBase {
27 | public:
28 | PluginAeroAtomIsp();
29 | ~PluginAeroAtomIsp();
30 |
31 | std::vector getCameraDevices();
32 | std::shared_ptr createCameraDevice(std::string);
33 |
34 | private:
35 | std::vector mCamList;
36 | void discoverCameras(std::vector &camList);
37 | };
38 |
--------------------------------------------------------------------------------
/plugins/CustomCamera/CameraDeviceCustom.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the Dronecode Camera Manager
3 | *
4 | * Copyright (C) 2017 Intel Corporation. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | #pragma once
19 | #include
20 | #include
21 | #include
22 |
23 | #include "CameraDevice.h"
24 | #include "CameraParameters.h"
25 |
26 | class CameraDeviceCustom final : public CameraDevice {
27 | public:
28 | CameraDeviceCustom(std::string device);
29 | ~CameraDeviceCustom();
30 | std::string getDeviceId() const;
31 | Status getInfo(CameraInfo &camInfo) const;
32 | bool isGstV4l2Src() const;
33 | Status init(CameraParameters &camParam);
34 | Status uninit();
35 | Status start();
36 | Status stop();
37 | Status read(CameraData &data);
38 | Status setParam(CameraParameters &camParam, const std::string param, const char *param_value,
39 | const size_t value_size, const int param_type);
40 | Status resetParams(CameraParameters &camParam);
41 | Status setSize(const uint32_t width, const uint32_t height);
42 | Status getSize(uint32_t &width, uint32_t &height) const;
43 | Status getSupportedSizes(std::vector &sizes) const;
44 | Status setPixelFormat(const CameraParameters::PixelFormat format);
45 | Status getPixelFormat(CameraParameters::PixelFormat &format) const;
46 | Status getSupportedPixelFormats(std::vector &formats) const;
47 | Status setMode(const CameraParameters::Mode mode);
48 | Status getMode(CameraParameters::Mode &mode) const;
49 | Status getSupportedModes(std::vector &modes) const;
50 | Status setFrameRate(const uint32_t fps);
51 | Status getFrameRate(uint32_t &fps) const;
52 | Status getSupportedFrameRates(uint32_t &minFps, uint32_t &maxFps);
53 | Status setCameraDefinitionUri(const std::string uri);
54 | std::string getCameraDefinitionUri() const;
55 | std::string getOverlayText() const;
56 |
57 | private:
58 | // Declare parameter name & ID
59 | // Possible values of the params are in camera definition file
60 | static const char PARAMETER_CUSTOM_UINT8[];
61 | static const int ID_PARAMETER_CUSTOM_UINT8;
62 | static const char PARAMETER_CUSTOM_UINT32[];
63 | static const int ID_PARAMETER_CUSTOM_UINT32;
64 | static const char PARAMETER_CUSTOM_INT32[];
65 | static const int ID_PARAMETER_CUSTOM_INT32;
66 | static const char PARAMETER_CUSTOM_REAL32[];
67 | static const int ID_PARAMETER_CUSTOM_REAL32;
68 | static const char PARAMETER_CUSTOM_ENUM[];
69 | static const int ID_PARAMETER_CUSTOM_ENUM;
70 | std::string mDeviceId;
71 | std::atomic mState;
72 | uint32_t mWidth;
73 | uint32_t mHeight;
74 | CameraParameters::PixelFormat mPixelFormat;
75 | CameraParameters::Mode mMode;
76 | uint32_t mFrmRate;
77 | std::string mCamDefUri;
78 | std::string mOvText;
79 | };
80 |
--------------------------------------------------------------------------------
/plugins/CustomCamera/PluginCustom.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the Dronecode Camera Manager
3 | *
4 | * Copyright (C) 2018 Intel Corporation. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | #include
20 | #include
21 |
22 | #include "CameraDeviceCustom.h"
23 | #include "PluginCustom.h"
24 |
25 | static PluginCustom custom;
26 |
27 | PluginCustom::PluginCustom()
28 | : PluginBase()
29 | {
30 | /*
31 | * 1. Discover the list of camera devices for this Plugin Class
32 | * 2. Add the IDs of the devices in the list
33 | */
34 |
35 | discoverCameras(mCamList);
36 | }
37 |
38 | PluginCustom::~PluginCustom()
39 | {
40 | }
41 |
42 | std::vector PluginCustom::getCameraDevices()
43 | {
44 | return mCamList;
45 | }
46 |
47 | std::shared_ptr PluginCustom::createCameraDevice(std::string deviceID)
48 | {
49 | // check if the device exists in the list
50 | if (std::find(mCamList.begin(), mCamList.end(), deviceID) == mCamList.end()) {
51 | log_error("Camera Device not found : %s", deviceID.c_str());
52 | return nullptr;
53 | }
54 |
55 | return std::make_shared(deviceID);
56 | }
57 |
58 | void PluginCustom::discoverCameras(std::vector &camList)
59 | {
60 | /*
61 | * 1. Add the logic to discover the camera devices
62 | * 2. For V4L2, its scanning the video* nodes in /dev/ dir
63 | * 3. For Gazebo, the topics with "camera/image" is assumed to be a camera
64 | */
65 |
66 | return;
67 | }
68 |
--------------------------------------------------------------------------------
/plugins/CustomCamera/PluginCustom.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the Dronecode Camera Manager
3 | *
4 | * Copyright (C) 2018 Intel Corporation. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | #include
20 | #include
21 |
22 | #include "CameraDevice.h"
23 | #include "PluginBase.h"
24 |
25 | class PluginCustom final : public PluginBase {
26 | public:
27 | PluginCustom();
28 | ~PluginCustom();
29 |
30 | std::vector getCameraDevices();
31 | std::shared_ptr createCameraDevice(std::string);
32 |
33 | private:
34 | std::vector mCamList;
35 | void discoverCameras(std::vector &camList);
36 | };
37 |
--------------------------------------------------------------------------------
/plugins/GazeboCamera/CameraDeviceGazebo.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the Dronecode Camera Manager
3 | *
4 | * Copyright (C) 2017 Intel Corporation. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | #pragma once
19 | #include
20 | #include
21 | #include
22 |
23 | #include "CameraDevice.h"
24 | #include "CameraParameters.h"
25 |
26 | class CameraDeviceGazebo final : public CameraDevice {
27 | public:
28 | CameraDeviceGazebo(std::string device);
29 | ~CameraDeviceGazebo();
30 | std::string getDeviceId() const;
31 | Status getInfo(CameraInfo &camInfo) const;
32 | bool isGstV4l2Src() const;
33 | Status init(CameraParameters &camParam);
34 | Status uninit();
35 | Status start();
36 | Status stop();
37 | Status read(CameraData &data);
38 | Status setParam(CameraParameters &camParam, const std::string param, const char *param_value,
39 | const size_t value_size, const int param_type);
40 | Status resetParams(CameraParameters &camParam);
41 | Status getSize(uint32_t &width, uint32_t &height) const;
42 | Status getPixelFormat(CameraParameters::PixelFormat &format) const;
43 | Status setMode(const CameraParameters::Mode mode);
44 | Status getMode(CameraParameters::Mode &mode) const;
45 | Status setCameraDefinitionUri(const std::string uri);
46 | std::string getCameraDefinitionUri() const;
47 | std::string getOverlayText() const;
48 |
49 | private:
50 | // Declare parameter name & ID
51 | // Possible values of the params are in camera definition file
52 | static const char PARAMETER_CUSTOM_UINT8[];
53 | static const int ID_PARAMETER_CUSTOM_UINT8;
54 | static const char PARAMETER_CUSTOM_UINT32[];
55 | static const int ID_PARAMETER_CUSTOM_UINT32;
56 | static const char PARAMETER_CUSTOM_INT32[];
57 | static const int ID_PARAMETER_CUSTOM_INT32;
58 | static const char PARAMETER_CUSTOM_REAL32[];
59 | static const int ID_PARAMETER_CUSTOM_REAL32;
60 | static const char PARAMETER_CUSTOM_ENUM[];
61 | static const int ID_PARAMETER_CUSTOM_ENUM;
62 | int setOverlayText(std::string text);
63 | void cbOnImages(ConstImagesStampedPtr &_msg);
64 | int getImage(const gazebo::msgs::Image &_msg);
65 | std::string mDeviceId;
66 | std::atomic mState;
67 | uint32_t mWidth;
68 | uint32_t mHeight;
69 | CameraParameters::Mode mMode;
70 | CameraParameters::PixelFormat mPixelFormat;
71 | std::string mCamDefUri;
72 | std::string mTopicName;
73 | gazebo::transport::NodePtr mNode;
74 | gazebo::transport::SubscriberPtr mSub;
75 | std::mutex mLock;
76 | std::vector mFrameBuffer = {};
77 | std::string mOvText;
78 | };
79 |
--------------------------------------------------------------------------------
/plugins/GazeboCamera/PluginGazebo.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the Dronecode Camera Manager
3 | *
4 | * Copyright (C) 2018 Intel Corporation. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 |
25 | #include "CameraDeviceGazebo.h"
26 | #include "PluginGazebo.h"
27 |
28 | #define GZB_CMD_TOPIC "gz topic -l | grep \"camera/image\" "
29 |
30 | static PluginGazebo gzb;
31 |
32 | PluginGazebo::PluginGazebo()
33 | : PluginBase()
34 | {
35 | discoverCameras(mCamList);
36 | }
37 |
38 | PluginGazebo::~PluginGazebo()
39 | {
40 | }
41 |
42 | std::vector PluginGazebo::getCameraDevices()
43 | {
44 | return mCamList;
45 | }
46 |
47 | std::shared_ptr PluginGazebo::createCameraDevice(std::string deviceID)
48 | {
49 | // check if the device exists in the list
50 | if (std::find(mCamList.begin(), mCamList.end(), deviceID) == mCamList.end()) {
51 | log_error("Camera Device not found : %s", deviceID.c_str());
52 | return nullptr;
53 | }
54 |
55 | return std::make_shared(deviceID);
56 | }
57 |
58 | void PluginGazebo::discoverCameras(std::vector &camList)
59 | {
60 | std::string result;
61 | std::array buffer;
62 | std::shared_ptr pipe(popen(GZB_CMD_TOPIC, "r"), pclose);
63 | if (!pipe) {
64 | log_error("popen() failed!");
65 | return;
66 | }
67 | while (!feof(pipe.get())) {
68 | if (fgets(buffer.data(), 128, pipe.get()) != nullptr) {
69 | result = buffer.data();
70 | // Remove newline at the end
71 | result.pop_back();
72 | camList.push_back(result);
73 | }
74 | }
75 |
76 | return;
77 | }
78 |
--------------------------------------------------------------------------------
/plugins/GazeboCamera/PluginGazebo.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the Dronecode Camera Manager
3 | *
4 | * Copyright (C) 2018 Intel Corporation. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | #include
20 | #include
21 |
22 | #include "CameraDevice.h"
23 | #include "PluginBase.h"
24 |
25 | class PluginGazebo final : public PluginBase {
26 | public:
27 | PluginGazebo();
28 | ~PluginGazebo();
29 |
30 | std::vector getCameraDevices();
31 | std::shared_ptr createCameraDevice(std::string);
32 |
33 | private:
34 | std::vector mCamList;
35 | void discoverCameras(std::vector &camList);
36 | };
37 |
--------------------------------------------------------------------------------
/plugins/RealSenseCamera/CameraDeviceRealSense.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the Dronecode Camera Manager
3 | *
4 | * Copyright (C) 2018 Intel Corporation. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | #pragma once
19 | #include
20 | #include
21 | #include
22 | #include
23 |
24 | #include
25 |
26 | #include "CameraDevice.h"
27 | #include "CameraParameters.h"
28 |
29 | class CameraDeviceRealSense final : public CameraDevice {
30 | public:
31 | CameraDeviceRealSense(std::string device);
32 | ~CameraDeviceRealSense();
33 | std::string getDeviceId() const;
34 | Status getInfo(CameraInfo &camInfo) const;
35 | bool isGstV4l2Src() const;
36 | Status init(CameraParameters &camParam);
37 | Status uninit();
38 | Status start();
39 | Status stop();
40 | Status read(CameraData &data);
41 | Status setParam(CameraParameters &camParam, const std::string param, const char *param_value,
42 | const size_t value_size, const int param_type);
43 | Status resetParams(CameraParameters &camParam);
44 | Status setSize(const uint32_t width, const uint32_t height);
45 | Status getSize(uint32_t &width, uint32_t &height) const;
46 | Status getSupportedSizes(std::vector &sizes) const;
47 | Status setPixelFormat(const CameraParameters::PixelFormat format);
48 | Status getPixelFormat(CameraParameters::PixelFormat &format) const;
49 | Status getSupportedPixelFormats(std::vector &formats) const;
50 | Status setMode(const CameraParameters::Mode mode);
51 | Status getMode(CameraParameters::Mode &mode) const;
52 | Status getSupportedModes(std::vector &modes) const;
53 | Status setFrameRate(const uint32_t fps);
54 | Status getFrameRate(uint32_t &fps) const;
55 | Status getSupportedFrameRates(uint32_t &minFps, uint32_t &maxFps) const;
56 | Status setCameraDefinitionUri(const std::string uri);
57 | std::string getCameraDefinitionUri() const;
58 |
59 | private:
60 | Status setState(const CameraDevice::State state);
61 | CameraDevice::State getState() const;
62 | std::string mDeviceId;
63 | std::atomic mState;
64 | uint32_t mWidth;
65 | uint32_t mHeight;
66 | CameraParameters::PixelFormat mPixelFormat;
67 | CameraParameters::Mode mMode;
68 | uint32_t mFrmRate;
69 | std::string mCamDefUri;
70 | std::mutex mLock;
71 | uint8_t *mFrameBuffer;
72 | size_t mFrameBufferSize;
73 | rs_device *mRSDev;
74 | rs_context *mRSCtx;
75 | int mRSStream;
76 | static int sStrmCnt;
77 | };
78 |
--------------------------------------------------------------------------------
/plugins/RealSenseCamera/PluginRealSense.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the Dronecode Camera Manager
3 | *
4 | * Copyright (C) 2018 Intel Corporation. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | #include
20 | #include
21 |
22 | #include "CameraDeviceRealSense.h"
23 | #include "PluginRealSense.h"
24 |
25 | static PluginRealSense rs;
26 |
27 | PluginRealSense::PluginRealSense()
28 | : PluginBase()
29 | {
30 | /*
31 | * 1. Discover the list of camera devices for this Plugin Class
32 | * 2. Add the IDs of the devices in the list
33 | */
34 |
35 | discoverCameras(mCamList);
36 | }
37 |
38 | PluginRealSense::~PluginRealSense()
39 | {
40 | }
41 |
42 | std::vector PluginRealSense::getCameraDevices()
43 | {
44 | return mCamList;
45 | }
46 |
47 | std::shared_ptr PluginRealSense::createCameraDevice(std::string deviceID)
48 | {
49 | /* check if the device exists in the list */
50 | if (std::find(mCamList.begin(), mCamList.end(), deviceID) == mCamList.end()) {
51 | log_error("Camera Device not found : %s", deviceID.c_str());
52 | return nullptr;
53 | }
54 |
55 | return std::make_shared(deviceID);
56 | }
57 |
58 | void PluginRealSense::discoverCameras(std::vector &camList)
59 | {
60 | /*
61 | * Add the logic to discover the camera devices
62 | * For RealSense cameras, its hardcoded
63 | */
64 |
65 | /* Depth Camera */
66 | camList.push_back("rsdepth");
67 | /* Infrared Camera*/
68 | camList.push_back("rsir");
69 | /* Infrared Camera2*/
70 | camList.push_back("rsir2");
71 |
72 | return;
73 | }
74 |
--------------------------------------------------------------------------------
/plugins/RealSenseCamera/PluginRealSense.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the Dronecode Camera Manager
3 | *
4 | * Copyright (C) 2018 Intel Corporation. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | #pragma once
19 |
20 | #include
21 | #include
22 |
23 | #include "CameraDevice.h"
24 | #include "PluginBase.h"
25 |
26 | class PluginRealSense final : public PluginBase {
27 | public:
28 | PluginRealSense();
29 | ~PluginRealSense();
30 |
31 | std::vector getCameraDevices();
32 | std::shared_ptr createCameraDevice(std::string);
33 |
34 | private:
35 | std::vector mCamList;
36 | void discoverCameras(std::vector &camList);
37 | };
38 |
--------------------------------------------------------------------------------
/plugins/V4l2Camera/CameraDeviceV4l2.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the Dronecode Camera Manager
3 | *
4 | * Copyright (C) 2017 Intel Corporation. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | #pragma once
19 | #include
20 | #include
21 |
22 | #include "CameraDevice.h"
23 | #include "CameraParameters.h"
24 |
25 | class CameraDeviceV4l2 final : public CameraDevice {
26 | public:
27 | CameraDeviceV4l2(std::string device);
28 | ~CameraDeviceV4l2();
29 | std::string getDeviceId() const;
30 | Status getInfo(CameraInfo &camInfo) const;
31 | bool isGstV4l2Src() const;
32 | Status init(CameraParameters &camParam);
33 | Status uninit();
34 | Status start();
35 | Status stop();
36 | Status setParam(CameraParameters &camParam, const std::string param, const char *param_value,
37 | const size_t value_size, const int param_type);
38 | Status resetParams(CameraParameters &camParam);
39 | Status setSize(const uint32_t width, const uint32_t height);
40 | Status setPixelFormat(const CameraParameters::PixelFormat format);
41 | Status setMode(const CameraParameters::Mode mode);
42 | Status getMode(CameraParameters::Mode &mode) const;
43 | Status setCameraDefinitionUri(const std::string uri);
44 | std::string getCameraDefinitionUri() const;
45 |
46 | private:
47 | std::string mDeviceId;
48 | std::string mCardName;
49 | std::string mDriverName;
50 | std::string mCamDefURI;
51 | uint32_t mVersion;
52 | CameraParameters::Mode mMode;
53 | int initInfo();
54 | int initParams(CameraParameters &camParam);
55 | int declareParams(CameraParameters &camParam);
56 | int resetV4l2Params(CameraParameters &camParam);
57 | int declareV4l2Params(CameraParameters &camParam);
58 | std::string getParamName(int cid);
59 | int getParamId(int cid);
60 | CameraParameters::param_type getParamType(v4l2_ctrl_type type);
61 | int getV4l2ControlId(int paramId);
62 | int setV4l2Control(int ctrl_id, int value);
63 | };
64 |
--------------------------------------------------------------------------------
/plugins/V4l2Camera/PluginV4l2.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the Dronecode Camera Manager
3 | *
4 | * Copyright (C) 2018 Intel Corporation. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | #include
20 |
21 | #include "PluginV4l2.h"
22 | #include "v4l2_interface.h"
23 |
24 | static PluginV4l2 v4l2;
25 |
26 | PluginV4l2::PluginV4l2()
27 | : PluginBase()
28 | {
29 | v4l2_list_devices(mCamList);
30 | }
31 |
32 | PluginV4l2::~PluginV4l2()
33 | {
34 | }
35 |
36 | std::vector PluginV4l2::getCameraDevices()
37 | {
38 | return mCamList;
39 | }
40 |
41 | std::shared_ptr PluginV4l2::createCameraDevice(std::string deviceID)
42 | {
43 | // check if the device exists in the list
44 | if (std::find(mCamList.begin(), mCamList.end(), deviceID) == mCamList.end()) {
45 | log_error("Camera Device not found : %s", deviceID.c_str());
46 | return nullptr;
47 | }
48 |
49 | return std::make_shared(deviceID);
50 | }
51 |
--------------------------------------------------------------------------------
/plugins/V4l2Camera/PluginV4l2.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the Dronecode Camera Manager
3 | *
4 | * Copyright (C) 2018 Intel Corporation. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | #include
20 | #include
21 |
22 | #include "CameraDevice.h"
23 | #include "CameraDeviceV4l2.h"
24 | #include "PluginBase.h"
25 |
26 | class PluginV4l2 final : public PluginBase {
27 | public:
28 | PluginV4l2();
29 | ~PluginV4l2();
30 |
31 | std::vector getCameraDevices();
32 | std::shared_ptr createCameraDevice(std::string);
33 |
34 | private:
35 | std::vector mCamList;
36 | };
37 |
--------------------------------------------------------------------------------
/samples/config/aero.conf:
--------------------------------------------------------------------------------
1 | [gstreamer]
2 | muxer=rtph264pay
3 | encoder=vaapih264enc
4 | converter=autovideoconvert
5 |
6 | [v4l2]
7 | blacklist=video0,video1,video3,video4,video5,video6,video7,video8,video9,video10,video11,video12
8 |
9 | [mavlink]
10 | broadcast_addr=127.0.0.1
11 | port=80550
12 | rtsp_server_addr=192.168.8.1
13 |
14 | [uri]
15 | video13=http://192.168.8.1:8000/camera-def-rs-rgb.xml
16 |
--------------------------------------------------------------------------------
/samples/config/config.sample:
--------------------------------------------------------------------------------
1 | # camera-streaming-daemon configuration file is composed of sections,
2 | # each section has some keys and values. They
3 | # are case insensitive, so `Key=Value` is the same as `key=value`.
4 | #
5 | # [This-is-a-section]
6 | # ThisIsAKey=ThisIsAValue
7 | # =ThisIsAValue
8 | # Following specifications of expected sessions and key/values.
9 | #
10 | # Section [Mavlink]:
11 | #
12 | # Keys:
13 | # Port
14 | # MAVLink destination UDP port.
15 | # Default: 14550
16 | #
17 | # System_ID
18 | # System ID of the Camera-Streaming-Daemon to be used in MAVLink
19 | # communications.
20 | # Default: 42
21 | #
22 | # Rtsp_Server_Addr
23 | # IP address or hostname of the interface where the rtsp server is
24 | # running. This is the address that will be used by the client to
25 | # make the rtsp request.
26 | # Default: 0.0.0.0
27 | #
28 | # Broadcast_Addr
29 | # Broadcast address to send MAVLink heartbeat messages.
30 | # Default: 255.255.255.255
31 | #
32 | # Section [Gstreamer]:
33 | #
34 | # Keys:
35 | # Muxer
36 | # Muxer used to create the gstreamer pipeline
37 | # Default: rtph264pay
38 | #
39 | # Converter
40 | # Converter used to create the gstreamer pipeline
41 | # Default: autovideoconvert
42 | #
43 | # Encoder
44 | # Muxer used to create the gstreamer pipeline
45 | # Default: x264enc
46 | #
47 | # Section [V4L2]
48 | #
49 | # Keys:
50 | # Blacklist
51 | # Coma separated list of /dev/video devices that won't be exported by
52 | # camera-streaming-daemon. If the video streams from cameras /dev/video123
53 | # and /dev/video456 can't be exported, set:
54 | # blacklist = video123,video456
55 | # Default:
56 | #
57 | # Section [uri]:
58 | #
59 | # Keys:
60 | #
61 | # URI for the Camera Definition File of the camera device
62 | # video0 = http://ipofdronefromgroundstation/video0_camera_definition.xml
63 | #
64 | #
65 | # Section [gazebo]:
66 | #
67 | # Keys:
68 | # camtopic
69 | # Gazebo topic where camera images are published.
70 | #
71 | #
72 | # Section [imgcap]:
73 | #
74 | # Keys:
75 | # width
76 | # Width of the image to be captured in pixels.
77 | # Default: Full width of camera frame for sensor type (i.e 1080P - 1920, 720P - 1280, etc)
78 | # Possible Values: Dependent on camera sensor
79 | #
80 | # height
81 | # Height of the image to be captured in pixels.
82 | # Default: Full height of camera frame for sensor type (i.e 1080P - 1080, 720P - 720, etc)
83 | # Possible Values: Dependent on camera sensor
84 | #
85 | # format
86 | # Image format
87 | # Default: 2 (JPEG)
88 | # Possible Values:
89 | # 1 - Not Supported (IMAGE_FILE_RAW)
90 | # 2 - JPEG Format (IMAGE_FILE_JPEG)
91 | # 3 - Not Supported (IMAGE_FILE_EXIF)
92 | # 4 - Not Supported (IMAGE_FILE_TIFF)
93 | # 5 - Not Supported (IMAGE_FILE_GIF)
94 | # 6 - Not Supported (IMAGE_FILE_PNG)
95 | # 7 - Not Supported (IMAGE_FILE_BMP)
96 | #
97 | # location
98 | # Location of the image file to write
99 | # Default: /tmp/
100 | # Possible Values: The path should be accessible and writeable
101 | #
102 | #
103 | # Section [vidcap]:
104 | #
105 | # Keys:
106 | # width
107 | # Width of the video to be captured in pixels.
108 | # Default: Full width of camera frame for sensor type (i.e 1080P - 1920, 720P - 1280, etc)
109 | # Possible Values: Dependent on camera sensor
110 | #
111 | # height
112 | # Height of the video to be captured in pixels.
113 | # Default: Full height of camera frame for sensor type (i.e 1080P - 1080, 720P - 720, etc)
114 | # Possible Values: Dependent on camera sensor
115 | #
116 | # framerate
117 | # Camera framerate for video capture
118 | # Default: Default framerate of camera sensor (eg - 25)
119 | # Possible Values: Dependent on camera sensor
120 | #
121 | # bitrate
122 | # Bitrate of the encoded video data in kbps
123 | # Default: 512
124 | # Possible Values: [1,2048000]
125 | #
126 | # encoder
127 | # Video encoding format
128 | # Default: 3 (AVC)
129 | # Possible Values:
130 | # 1 - Not Supported (VIDEO_CODING_H263)
131 | # 2 - Not Supported (VIDEO_CODING_MPEG4)
132 | # 3 - H.264 (VIDEO_CODING_AVC)
133 | # 4 - Not Supported (VIDEO_CODING_MJPEG)
134 | # 5 - Not Supported (VIDEO_CODING_WMV)
135 | #
136 | # format
137 | # Video file format
138 | # Default: 1 (MP4)
139 | # Possible Values:
140 | # 1 - Moving Pictures Expert Group 4 (VIDEO_FILE_MP4)
141 | # 2 - Not Supported (VIDEO_FILE_AVI)
142 | # 3 - Not Supported (VIDEO_FILE_WMV)
143 | # 4 - Not Supported (VIDEO_FILE_FLV)
144 | # 5 - Not Supported (VIDEO_FILE_MOV)
145 | #
146 | # location
147 | # Location of the video file to write
148 | # Default: /tmp/
149 | # Possible Values: The path that is accessible and writeable
150 | #
151 | # Section [rtsp]:
152 | #
153 | # Keys:
154 | # pipeline
155 | # A gstreamer pipeline to transmit the video to the ground station.
156 | # Default: none
157 | # [rtsp]
158 | # pipeline=v4l2src device=/dev/video0 ! videoconvert ! video/x-raw, format=I420 ! x264enc speed-preset=ultrafast tune=zerolatency ! rtph264pay name=pay0
159 | #
160 |
--------------------------------------------------------------------------------
/samples/config/gazebo.conf:
--------------------------------------------------------------------------------
1 | [mavlink]
2 | port=14550
3 | broadcast_addr=127.0.0.255
4 | rtsp_server_addr=127.0.0.1
5 | system_id=1
6 |
7 | [uri]
8 | gazebo=http://127.0.0.1:8000/camera-def-gazebo.xml
9 |
10 | [imgcap]
11 | location=~/Temp/
12 |
13 | [gazebo]
14 | camtopic=~/typhoon_h480/cgo3_camera_link/camera/image
15 |
16 | [rtsp]
17 | pipeline=appsrc name=mysrc ! videoconvert ! video/x-raw, format=I420 ! vaapih264enc ! rtph264pay name=pay0
18 |
--------------------------------------------------------------------------------
/samples/config/picam.conf:
--------------------------------------------------------------------------------
1 | [mavlink]
2 | port=14550
3 | broadcast_addr=127.0.0.255
4 | rtsp_server_addr=127.0.0.1
5 | system_id=1
6 |
7 | [uri]
8 | video0=http://127.0.0.1:8000/camera-def-picam.xml
9 |
10 | [vidcap]
11 | width=640
12 | height=480
13 | framerate=25
14 | bitrate=1000
15 | encoder=6
16 | format=1
17 | location=/tmp/
18 |
19 | [rtsp]
20 | pipeline=rpicamsrc bitrate=1000000 ! video/x-h264, width=640, height=480, framerate=25/1 ! h264parse ! rtph264pay name=pay0
21 |
22 |
--------------------------------------------------------------------------------
/samples/config/ubuntu.conf:
--------------------------------------------------------------------------------
1 | [mavlink]
2 | port=14550
3 | broadcast_addr=127.0.0.255
4 | rtsp_server_addr=127.0.0.1
5 | system_id=1
6 |
7 | [uri]
8 | video0=http://127.0.0.1:8000/camera-def-uvc.xml
9 |
10 | [imgcap]
11 | width=640
12 | height=480
13 | format=2
14 | location=/tmp/
15 |
16 | [vidcap]
17 | width=640
18 | height=480
19 | framerate=25
20 | bitrate=1000
21 | encoder=3
22 | format=1
23 | location=/tmp/
24 |
25 | [rtsp]
26 | pipeline=v4l2src device=/dev/video0 ! videoconvert ! video/x-raw, format=I420 ! x264enc speed-preset=ultrafast tune=zerolatency ! rtph264pay name=pay0
27 |
--------------------------------------------------------------------------------
/samples/def/camera-def-gazebo.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Gazebo Camera
5 | PX4 SITL
6 |
7 |
8 |
9 |
10 | Camera Mode
11 |
12 |
17 |
19 |
20 |
21 |
22 | ParamInt32
23 |
24 |
25 | ParamUint32
26 |
27 |
28 | ParamInt32
29 |
30 |
31 | ParamInt32
32 |
33 |
34 | ParamEnum
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/samples/def/camera-def-picam.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | PiCam
5 | Raspberry PI Cam
6 |
7 |
8 |
9 | Camera Mode
10 |
11 |
16 |
18 |
19 |
20 |
21 | Brightness
22 |
23 |
24 | Contrast
25 |
26 |
27 | Saturation
28 |
29 |
30 | Gain
31 |
32 |
33 | Sharpness
34 |
35 |
36 | Backlight Compensation
37 |
38 |
39 | Power Line Frequency
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | White Balance Mode
48 |
49 |
50 |
55 |
56 |
57 |
58 | White Balance Temperature
59 |
60 |
61 | Exposure Mode
62 |
63 |
64 |
69 |
70 |
71 |
72 | Exposure Absolute
73 |
74 |
75 | Exposure Auto Priority
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/samples/def/camera-def-rs-rgb.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | RealSense RGB Camera
5 | Intel Corporation
6 |
7 |
8 |
9 |
10 | Camera Mode
11 |
12 |
17 |
19 |
20 |
21 |
22 | Brightness
23 |
24 |
25 | Contrast
26 |
27 |
28 | Saturation
29 |
30 |
31 | Hue
32 |
33 |
34 | Gamma
35 |
36 |
37 | Gain
38 |
39 |
40 | Sharpness
41 |
42 |
43 | Backlight Compensation
44 |
45 |
46 | Power Line Frequency
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | White Balance Mode
55 |
56 |
57 |
62 |
63 |
64 |
65 | White Balance Temperature
66 |
67 |
68 | Exposure Mode
69 |
70 |
71 |
76 |
77 |
78 |
79 | Exposure Absolute
80 |
81 |
82 | Video Resolution
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/samples/def/camera-def-uvc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | UVC Camera
5 | Logitech C270HD Webcam
6 |
7 |
8 |
9 | Camera Mode
10 |
11 |
16 |
18 |
19 |
20 |
21 | Brightness
22 |
23 |
24 | Contrast
25 |
26 |
27 | Saturation
28 |
29 |
30 | Gain
31 |
32 |
33 | Sharpness
34 |
35 |
36 | Backlight Compensation
37 |
38 |
39 | Power Line Frequency
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | White Balance Mode
48 |
49 |
50 |
55 |
56 |
57 |
58 | White Balance Temperature
59 |
60 |
61 | Exposure Mode
62 |
63 |
64 |
69 |
70 |
71 |
72 | Exposure Absolute
73 |
74 |
75 | Exposure Auto Priority
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/src/CameraComponent.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the Dronecode Camera Manager
3 | *
4 | * Copyright (C) 2017 Intel Corporation. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | #pragma once
19 | #include