Skip to content

Commit

Permalink
postprocessing: Split existing postproc stages into loadable so files
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
naushir committed May 13, 2024
1 parent 9e89e93 commit 80462c1
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rpicam-apps-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
clean: true

- name: Configure meson
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
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
timeout-minutes: 5

- name: Build
Expand Down
3 changes: 1 addition & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ subdir('preview')
subdir('post_processing_stages')
subdir('utils')

add_project_arguments(cpp_arguments, language : 'cpp')

rpicam_app = library(
'rpicam_app',
rpicam_app_src,
Expand All @@ -61,6 +59,7 @@ rpicam_app = library(
install : true,
name_prefix : '',
dependencies : rpicam_app_dep,
cpp_args : cpp_arguments,
)

# Install a symlink to the old library name for legacy purposes.
Expand Down
8 changes: 4 additions & 4 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ option('enable_qt',
description : 'Enable QT preview window support')

option('enable_opencv',
type : 'boolean',
value : true,
type : 'feature',
value : 'disabled',
description : 'Enable OpenCV postprocessing support')

option('enable_tflite',
type : 'boolean',
value : false,
type : 'feature',
value : 'disabled',
description : 'Enable Tensorflow Lite postprocessing support')

option('neon_flags',
Expand Down
80 changes: 55 additions & 25 deletions post_processing_stages/meson.build
Original file line number Diff line number Diff line change
@@ -1,55 +1,85 @@
posproc_libdir = get_option('prefix') / get_option('libdir') / 'rpicam-apps-pp'
posproc_libdir = get_option('prefix') / get_option('libdir') / 'rpicam-apps-postproc'

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

# Core postprocessing framework files.
rpicam_app_src += files([
'hdr_stage.cpp',
'histogram.cpp',
'motion_detect_stage.cpp',
'negate_stage.cpp',
'post_processing_stage.cpp',
'pwl.cpp',
])

post_processing_headers = files([
'histogram.hpp',
'object_detect.hpp',
'post_processing_stage.hpp',
'pwl.hpp',
'segmentation.hpp',
'tf_stage.hpp',
# Core postprocessing stages.
core_postproc_src = files([
'hdr_stage.cpp',
'motion_detect_stage.cpp',
'negate_stage.cpp',
])

enable_opencv = get_option('enable_opencv')
opencv_dep = dependency('opencv4', required : false)
if enable_opencv and opencv_dep.found()
rpicam_app_src += files([
core_postproc_lib = shared_module('core-postproc', core_postproc_src,
include_directories : '../..',
dependencies : libcamera_dep,
cpp_args : cpp_arguments,
install : true,
install_dir : posproc_libdir,
name_prefix : '',
)

# OpenCV based postprocessing stages.
enable_opencv = false
opencv_dep = dependency('opencv4', required : get_option('enable_opencv'))
if opencv_dep.found()
opencv_postproc_src = files([
'sobel_cv_stage.cpp',
'face_detect_cv_stage.cpp',
'annotate_cv_stage.cpp',
'plot_pose_cv_stage.cpp',
'object_detect_draw_cv_stage.cpp',
])
rpicam_app_dep += opencv_dep
else
enable_opencv = false

opencv_postproc_lib = shared_module('opencv-postproc', opencv_postproc_src,
include_directories : '../..',
dependencies : [libcamera_dep, opencv_dep],
cpp_args : cpp_arguments,
install : true,
install_dir : posproc_libdir,
name_prefix : '',
)
enable_opencv = true
endif

enable_tflite = get_option('enable_tflite')
tflite_dep = dependency('tensorflow-lite', required : false)
if enable_tflite and tflite_dep.found()
rpicam_app_src += files([
# TFlite based postprocessing stages.
enable_tflite = false
tflite_dep = dependency('tensorflow-lite', required : get_option('enable_tflite'))
if tflite_dep.found()
tflite_postproc_src = files([
'tf_stage.cpp',
'object_classify_tf_stage.cpp',
'pose_estimation_tf_stage.cpp',
'object_detect_tf_stage.cpp',
'segmentation_tf_stage.cpp',
])
rpicam_app_dep += tflite_dep
else
enable_tflite = false

tflite_postproc_lib = shared_module('tflite-postproc', tflite_postproc_src,
include_directories : '../..',
dependencies : [libcamera_dep, tflite_dep],
cpp_args : cpp_arguments,
install : true,
install_dir : posproc_libdir,
name_prefix : '',
)
enable_tflite = true
endif

post_processing_headers = files([
'histogram.hpp',
'object_detect.hpp',
'post_processing_stage.hpp',
'pwl.hpp',
'segmentation.hpp',
'tf_stage.hpp',
])

install_headers(post_processing_headers, subdir: meson.project_name() / 'post_processing_stages')

0 comments on commit 80462c1

Please sign in to comment.