mv_machine_learning: add task group build option
authorInki Dae <inki.dae@samsung.com>
Tue, 21 Mar 2023 06:33:45 +0000 (15:33 +0900)
committerKwanghoon Son <k.son@samsung.com>
Fri, 7 Apr 2023 08:53:23 +0000 (17:53 +0900)
Change-Id: Icf6ff8816ea7836c7a551a21c5005b4fb343ed1f
Signed-off-by: Inki Dae <inki.dae@samsung.com>
CMakeLists.txt
mv_machine_learning/CMakeLists.txt
packaging/capi-media-vision.spec
test/testsuites/machine_learning/CMakeLists.txt

index b26e4d5..45bf520 100644 (file)
@@ -164,35 +164,41 @@ configure_file(
 )
 install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}-inference.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
 
-set(PC_NAME ${fw_name}-object-detection)
-set(PC_LDFLAGS "-l${MV_OBJECT_DETECTION_LIB_NAME} -l${MV_COMMON_LIB_NAME}")
-configure_file(
-       ${fw_name}.pc.in
-       ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}-object-detection.pc
-       @ONLY
-)
-install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}-object-detection.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
-install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mv_machine_learning/object_detection/meta/object_detection.json DESTINATION ${CMAKE_INSTALL_DATADIR}/${fw_name})
+if (${ENABLE_ML_OBJECT_DETECTION})
+    set(PC_NAME ${fw_name}-object-detection)
+    set(PC_LDFLAGS "-l${MV_OBJECT_DETECTION_LIB_NAME} -l${MV_COMMON_LIB_NAME}")
+    configure_file(
+           ${fw_name}.pc.in
+           ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}-object-detection.pc
+           @ONLY
+    )
+    install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}-object-detection.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+    install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mv_machine_learning/object_detection/meta/object_detection.json DESTINATION ${CMAKE_INSTALL_DATADIR}/${fw_name})
+endif()
 
-set(PC_NAME ${fw_name}-object-detection-3d)
-set(PC_LDFLAGS "-l${MV_OBJECT_DETECTION_3D_LIB_NAME} -l${MV_COMMON_LIB_NAME}")
-configure_file(
-       ${fw_name}.pc.in
-       ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}-object-detection-3d.pc
-       @ONLY
-)
-install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}-object-detection-3d.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
-install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mv_machine_learning/object_detection_3d/meta/object_detection_3d.json DESTINATION ${CMAKE_INSTALL_DATADIR}/${fw_name})
+if (${ENABLE_ML_OBJECT_DETECTION_3D})
+    set(PC_NAME ${fw_name}-object-detection-3d)
+    set(PC_LDFLAGS "-l${MV_OBJECT_DETECTION_3D_LIB_NAME} -l${MV_COMMON_LIB_NAME}")
+    configure_file(
+           ${fw_name}.pc.in
+           ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}-object-detection-3d.pc
+           @ONLY
+    )
+    install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}-object-detection-3d.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+    install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mv_machine_learning/object_detection_3d/meta/object_detection_3d.json DESTINATION ${CMAKE_INSTALL_DATADIR}/${fw_name})
+endif()
 
-set(PC_NAME ${fw_name}-image-classification)
-set(PC_LDFLAGS "-l${MV_IMAGE_CLASSIFICATION_LIB_NAME} -l${MV_COMMON_LIB_NAME}")
-configure_file(
-       ${fw_name}.pc.in
-       ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}-image-classification.pc
-       @ONLY
-)
-install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}-image-classification.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
-install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mv_machine_learning/image_classification/meta/image_classification.json DESTINATION ${CMAKE_INSTALL_DATADIR}/${fw_name})
+if (${ENABLE_ML_IMAGE_CLASSIFICATION})
+    set(PC_NAME ${fw_name}-image-classification)
+    set(PC_LDFLAGS "-l${MV_IMAGE_CLASSIFICATION_LIB_NAME} -l${MV_COMMON_LIB_NAME}")
+    configure_file(
+           ${fw_name}.pc.in
+           ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}-image-classification.pc
+           @ONLY
+    )
+    install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}-image-classification.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+    install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mv_machine_learning/image_classification/meta/image_classification.json DESTINATION ${CMAKE_INSTALL_DATADIR}/${fw_name})
+endif()
 
 if (${ENABLE_ML_FACE_RECOGNITION})
     set(PC_NAME ${fw_name}-training)
index b4509af..c41e4f0 100644 (file)
@@ -1,7 +1,17 @@
 add_subdirectory(inference)
-add_subdirectory(image_classification)
-add_subdirectory(object_detection)
-add_subdirectory(object_detection_3d)
+
+if (${ENABLE_ML_IMAGE_CLASSIFICATION})
+    message("Enabled machine learning image classification task group.")
+    add_subdirectory(image_classification)
+endif()
+if (${ENABLE_ML_OBJECT_DETECTION})
+    message("Enabled machine learning object detection task group.")
+    add_subdirectory(object_detection)
+endif()
+if (${ENABLE_ML_OBJECT_DETECTION_3D})
+    message("Enabled machine learning object detection 3d task group.")
+    add_subdirectory(object_detection_3d)
+endif()
 
 if (${ENABLE_ML_FACE_RECOGNITION})
     message("Enabled machine learning face recognition feature.")
index 6772b91..2b5334a 100644 (file)
@@ -51,6 +51,10 @@ BuildRequires: pkgconfig(grpc++)
 BuildRequires: pkgconfig(training-engine-interface-common)
 Requires:      training-engine-interface-common
 
+%define enable_ml_image_classification 1
+%define enable_ml_object_detection 1
+%define enable_ml_object_detection_3d 1
+
 %define build_depth_stream_testsuite 1
 BuildRequires: pkgconfig(vision-source)
 %ifarch aarch64
@@ -58,8 +62,8 @@ BuildRequires: pkgconfig(vision-source)
 BuildRequires: Open3D-devel
 %endif
 %endif
-%define build_options -DENABLE_INFERENCE_PROFILER=0 -DENABLE_ML_FACE_RECOGNITION=%{enable_ml_face_recognition} -DBUILD_DEPTH_STREAM_TESTSUITE=%{build_depth_stream_testsuite} -DMV_3D_POINTCLOUD_IS_AVAILABLE=%{enable_mv3d_pointcloud}
-
+%define build_options -DENABLE_INFERENCE_PROFILER=0 -DBUILD_DEPTH_STREAM_TESTSUITE=%{build_depth_stream_testsuite} -DMV_3D_POINTCLOUD_IS_AVAILABLE=%{enable_mv3d_pointcloud}
+%define task_group_options -DENABLE_ML_FACE_RECOGNITION=%{enable_ml_face_recognition} -DENABLE_ML_IMAGE_CLASSIFICATION=%{enable_ml_image_classification} -DENABLE_ML_OBJECT_DETECTION=%{enable_ml_object_detection} -DENABLE_ML_OBJECT_DETECTION_3D=%{enable_ml_object_detection_3d}
 Requires:   %{name}-machine_learning
 Requires:   inference-engine-interface-common
 %if !0%{?ml_only:1}
@@ -278,7 +282,7 @@ export FFLAGS+=" -fprofile-arcs -ftest-coverage"
 export LDFLAGS+=" -lgcov"
 %endif
 
-%cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo %{build_options} \
+%cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo %{build_options} %{task_group_options} \
 %if 0%{?ml_only:1}
  -DBUILD_ML_ONLY=ON \
 %endif
@@ -411,12 +415,18 @@ find . -name '*.gcno' -not -path "./test/*" -exec cp --parents '{}' "$gcno_obj_d
 %manifest %{name}.manifest
 %license LICENSE.APLv2 LICENSE.BSD-3-Clause
 %{_libdir}/libmv_inference*.so
+%if "%{enable_ml_object_detection}" == "1"
 %{_datadir}/%{name}/object_detection.json
-%{_libdir}/libmv_object_detection*.so
+%{_libdir}/libmv_object_detection.so
+%endif
+%if "%{enable_ml_object_detection_3d}" == "1"
 %{_datadir}/%{name}/object_detection_3d.json
-%{_libdir}/libmv_object_detection_3d*.so
+%{_libdir}/libmv_object_detection_3d.so
+%endif
+%if "%{enable_ml_image_classification}" == "1"
 %{_datadir}/%{name}/image_classification.json
-%{_libdir}/libmv_image_classification*.so
+%{_libdir}/libmv_image_classification.so
+%endif
 %if "%{enable_ml_face_recognition}" == "1"
 %{_datadir}/%{name}/face_recognition.json
 %{_libdir}/libmv_training.so
@@ -425,13 +435,22 @@ find . -name '*.gcno' -not -path "./test/*" -exec cp --parents '{}' "$gcno_obj_d
 
 %files machine_learning-devel
 %{_includedir}/media/mv_infer*.h
-%{_includedir}/media/mv_object_detection*.h
-%{_includedir}/media/mv_object_detection_3d*.h
-%{_includedir}/media/mv_image_classification*.h
-%{_libdir}/pkgconfig/*inference.pc
+%if "%{enable_ml_object_detection}" == "1"
+%{_includedir}/media/mv_object_detection_internal.h
+%{_includedir}/media/mv_object_detection_type.h
 %{_libdir}/pkgconfig/*object-detection.pc
+%endif
+%if "%{enable_ml_object_detection_3d}" == "1"
+%{_includedir}/media/mv_object_detection_3d_internal.h
+%{_includedir}/media/mv_object_detection_3d_type.h
 %{_libdir}/pkgconfig/*object-detection-3d.pc
+%endif
+%if "%{enable_ml_image_classification}" == "1"
+%{_includedir}/media/mv_image_classification_internal.h
+%{_includedir}/media/mv_image_classification_type.h
 %{_libdir}/pkgconfig/*image-classification.pc
+%endif
+%{_libdir}/pkgconfig/*inference.pc
 %if "%{enable_ml_face_recognition}" == "1"
 %{_includedir}/media/mv_face_recognition*.h
 %{_libdir}/pkgconfig/*training.pc
@@ -458,9 +477,15 @@ find . -name '*.gcno' -not -path "./test/*" -exec cp --parents '{}' "$gcno_obj_d
 %endif
 %{_libdir}/libmv_testsuite*.so
 %{_bindir}/mv_*
+%if "%{enable_ml_image_classification}" == "1"
 %{_bindir}/test_image_classification
+%endif
+%if "%{enable_ml_object_detection}" == "1"
 %{_bindir}/test_object_detection
+%endif
+%if "%{enable_ml_object_detection_3d}" == "1"
 %{_bindir}/test_object_detection_3d
+%endif
 %if "%{enable_ml_face_recognition}" == "1"
 %{_bindir}/test_face_recognition
 %{_bindir}/test_face_recognition_multi_threads
index bce74e1..9b8e668 100644 (file)
@@ -2,11 +2,20 @@ project(machine_learning)
 cmake_minimum_required(VERSION 2.6...3.13)
 
 add_subdirectory(${PROJECT_SOURCE_DIR}/inference)
-add_subdirectory(${PROJECT_SOURCE_DIR}/image_classification)
-add_subdirectory(${PROJECT_SOURCE_DIR}/object_detection)
-add_subdirectory(${PROJECT_SOURCE_DIR}/object_detection_3d)
 
+if (${ENABLE_ML_IMAGE_CLASSIFICATION})
+    message("Enabled image classification test case.")
+    add_subdirectory(${PROJECT_SOURCE_DIR}/image_classification)
+endif()
+if (${ENABLE_ML_OBJECT_DETECTION})
+    message("Enabled object detection test case.")
+    add_subdirectory(${PROJECT_SOURCE_DIR}/object_detection)
+endif()
+if (${ENABLE_ML_OBJECT_DETECTION_3D})
+    message("Enabled object detection 3d test case.")
+    add_subdirectory(${PROJECT_SOURCE_DIR}/object_detection_3d)
+endif()
 if (${ENABLE_ML_FACE_RECOGNITION})
-    message("Enabled machine learning face recognition test cases.")
+    message("Enabled machine learning face recognition test case.")
     add_subdirectory(${PROJECT_SOURCE_DIR}/face_recognition)
 endif()