Skip to content

Commit 56604de

Browse files
committed
postprocessing: Split existing postproc stages into loadable so files
Split the existing postprocessing stages into 3 .so files: - Core stages - OpenCV stages - TFLite stages These are installed into the /<system lib>/rpicam-apps-postproc/ directory. Additionally, switch enable_tflite and enable_opencv meson option types to "feature". Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
1 parent ec5e948 commit 56604de

4 files changed

Lines changed: 63 additions & 31 deletions

File tree

.github/workflows/rpicam-apps-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
clean: true
5757

5858
- name: Configure meson
59-
run: meson setup ${{github.workspace}}/build --pkg-config-path=${{env.LIBCAMERA_LKG_DIR}}/lib/aarch64-linux-gnu/pkgconfig/ -Dbuildtype=release -Denable_drm=false -Denable_egl=false -Denable_qt=false -Denable_opencv=false -Denable_tflite=false -Denable_libav=false
59+
run: meson setup ${{github.workspace}}/build --pkg-config-path=${{env.LIBCAMERA_LKG_DIR}}/lib/aarch64-linux-gnu/pkgconfig/ -Dbuildtype=release -Denable_drm=false -Denable_egl=false -Denable_qt=false -Denable_opencv='disabled' -Denable_tflite='disabled' -Denable_libav=false
6060
timeout-minutes: 5
6161

6262
- name: Build

meson.build

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ subdir('encoder')
4848
subdir('image')
4949
subdir('output')
5050
subdir('preview')
51-
subdir('post_processing_stages')
5251
subdir('utils')
5352

5453
add_project_arguments(cpp_arguments, language : 'cpp')
5554

55+
# Must be put after add_project_arguments as it defines shared library targets.
56+
subdir('post_processing_stages')
57+
5658
rpicam_app = library(
5759
'rpicam_app',
5860
rpicam_app_src,

meson_options.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ option('enable_qt',
1919
description : 'Enable QT preview window support')
2020

2121
option('enable_opencv',
22-
type : 'boolean',
23-
value : true,
22+
type : 'feature',
23+
value : 'disabled',
2424
description : 'Enable OpenCV postprocessing support')
2525

2626
option('enable_tflite',
27-
type : 'boolean',
28-
value : false,
27+
type : 'feature',
28+
value : 'disabled',
2929
description : 'Enable Tensorflow Lite postprocessing support')
3030

3131
option('neon_flags',

post_processing_stages/meson.build

Lines changed: 55 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,85 @@
1-
posproc_libdir = get_option('prefix') / get_option('libdir') / 'rpicam-apps-pp'
1+
posproc_libdir = get_option('prefix') / get_option('libdir') / 'rpicam-apps-postproc'
22

33
conf_data = configuration_data()
44
conf_data.set('POSTPROC_LIB_DIR', '"' + posproc_libdir + '"')
55
configure_file(output : 'postproc_lib.h', configuration : conf_data)
66

7+
# Core postprocessing framework files.
78
rpicam_app_src += files([
8-
'hdr_stage.cpp',
99
'histogram.cpp',
10-
'motion_detect_stage.cpp',
11-
'negate_stage.cpp',
1210
'post_processing_stage.cpp',
1311
'pwl.cpp',
1412
])
1513

16-
post_processing_headers = files([
17-
'histogram.hpp',
18-
'object_detect.hpp',
19-
'post_processing_stage.hpp',
20-
'pwl.hpp',
21-
'segmentation.hpp',
22-
'tf_stage.hpp',
14+
# Core postprocessing stages.
15+
core_postproc_src = files([
16+
'hdr_stage.cpp',
17+
'motion_detect_stage.cpp',
18+
'negate_stage.cpp',
2319
])
2420

25-
enable_opencv = get_option('enable_opencv')
26-
opencv_dep = dependency('opencv4', required : false)
27-
if enable_opencv and opencv_dep.found()
28-
rpicam_app_src += files([
21+
core_postproc_lib = shared_module('core-postproc', core_postproc_src,
22+
include_directories : '../..',
23+
dependencies : libcamera_dep,
24+
cpp_args : cpp_arguments,
25+
install : true,
26+
install_dir : posproc_libdir,
27+
name_prefix : '',
28+
)
29+
30+
# OpenCV based postprocessing stages.
31+
enable_opencv = false
32+
opencv_dep = dependency('opencv4', required : get_option('enable_opencv'))
33+
if opencv_dep.found()
34+
opencv_postproc_src = files([
2935
'sobel_cv_stage.cpp',
3036
'face_detect_cv_stage.cpp',
3137
'annotate_cv_stage.cpp',
3238
'plot_pose_cv_stage.cpp',
3339
'object_detect_draw_cv_stage.cpp',
3440
])
35-
rpicam_app_dep += opencv_dep
36-
else
37-
enable_opencv = false
41+
42+
opencv_postproc_lib = shared_module('opencv-postproc', opencv_postproc_src,
43+
include_directories : '../..',
44+
dependencies : [libcamera_dep, opencv_dep],
45+
cpp_args : cpp_arguments,
46+
install : true,
47+
install_dir : posproc_libdir,
48+
name_prefix : '',
49+
)
50+
enable_opencv = true
3851
endif
3952

40-
enable_tflite = get_option('enable_tflite')
41-
tflite_dep = dependency('tensorflow-lite', required : false)
42-
if enable_tflite and tflite_dep.found()
43-
rpicam_app_src += files([
53+
# TFlite based postprocessing stages.
54+
enable_tflite = false
55+
tflite_dep = dependency('tensorflow-lite', required : get_option('enable_tflite'))
56+
if tflite_dep.found()
57+
tflite_postproc_src = files([
4458
'tf_stage.cpp',
4559
'object_classify_tf_stage.cpp',
4660
'pose_estimation_tf_stage.cpp',
4761
'object_detect_tf_stage.cpp',
4862
'segmentation_tf_stage.cpp',
4963
])
50-
rpicam_app_dep += tflite_dep
51-
else
52-
enable_tflite = false
64+
65+
tflite_postproc_lib = shared_module('tflite-postproc', tflite_postproc_src,
66+
include_directories : '../..',
67+
dependencies : [libcamera_dep, tflite_dep],
68+
cpp_args : cpp_arguments,
69+
install : true,
70+
install_dir : posproc_libdir,
71+
name_prefix : '',
72+
)
73+
enable_tflite = true
5374
endif
5475

76+
post_processing_headers = files([
77+
'histogram.hpp',
78+
'object_detect.hpp',
79+
'post_processing_stage.hpp',
80+
'pwl.hpp',
81+
'segmentation.hpp',
82+
'tf_stage.hpp',
83+
])
84+
5585
install_headers(post_processing_headers, subdir: meson.project_name() / 'post_processing_stages')

0 commit comments

Comments
 (0)