test: Add FaceDetection test 85/262785/1
authorKwang Son <k.son@samsung.com>
Thu, 19 Aug 2021 23:02:08 +0000 (19:02 -0400)
committerKwang Son <k.son@samsung.com>
Thu, 19 Aug 2021 23:02:08 +0000 (19:02 -0400)
Change-Id: Ice45ea84dcdb2c2fd1348e1c0c37210d3c94b30c
Signed-off-by: Kwang Son <k.son@samsung.com>
test/CMakeLists.txt
test/testsuites/machine_learning/inference/test_face_detection.cpp [new file with mode: 0644]

index a45abd5..9a33829 100644 (file)
@@ -9,6 +9,7 @@ add_executable(${PROJECT_NAME}
     testsuites/machine_learning/inference/test_inference_helper.cpp
     testsuites/machine_learning/inference/test_image_classification.cpp
     testsuites/machine_learning/inference/test_object_detection.cpp
+    testsuites/machine_learning/inference/test_face_detection.cpp
 )
 target_link_libraries(${PROJECT_NAME} gtest gtest_main mv_inference mv_image_helper mv_barcode_detector)
 install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
\ No newline at end of file
diff --git a/test/testsuites/machine_learning/inference/test_face_detection.cpp b/test/testsuites/machine_learning/inference/test_face_detection.cpp
new file mode 100644 (file)
index 0000000..ebf37e5
--- /dev/null
@@ -0,0 +1,45 @@
+#include <gtest/gtest.h>
+#include <string>
+#include <ImageHelper.h>
+#include "test_inference_helper.hpp"
+
+#define FD_TFLITE_WEIGHT_MOBILENET_V1_SSD_300_PATH \
+       MV_CONFIG_PATH                                 \
+       "/models/FD/tflite/fd_mobilenet_v1_ssd_postop_300x300.tflite"
+#define FD_TFLITE_WEIGHT_BLAZEFACE_128_PATH \
+       MV_CONFIG_PATH                          \
+       "/models/FD/tflite/fd_blazeface_front_128x128.tflite"
+#define IMG_FACE   \
+       MV_CONFIG_PATH \
+       "/res/inference/images/faceDetection.jpg"
+
+void _face_detected_cb(mv_source_h source, const int number_of_faces,
+                                          const float *confidences,
+                                          const mv_rectangle_s *locations, void *user_data)
+{
+       EXPECT_GT(number_of_faces, 0);
+}
+
+class TestFaceDetection : public TestInference
+{
+public:
+       void inferenceFace()
+       {
+               ASSERT_EQ(mv_inference_configure(infer, engine_cfg),
+                                 MEDIA_VISION_ERROR_NONE);
+               ASSERT_EQ(mv_inference_prepare(infer), MEDIA_VISION_ERROR_NONE);
+               ASSERT_EQ(MediaVision::Common::ImageHelper::loadImageToSource(
+                                                 IMG_FACE, mv_source),
+                                 MEDIA_VISION_ERROR_NONE);
+               ASSERT_EQ(mv_inference_face_detect(mv_source, infer, _face_detected_cb,
+                                                                                  NULL),
+                                 MEDIA_VISION_ERROR_NONE);
+       }
+};
+
+TEST_F(TestFaceDetection, CPU_TFLITE_MobilenetV1_SSD)
+{
+       engine_config_hosted_cpu_tflite(engine_cfg,
+                                                                       FD_TFLITE_WEIGHT_MOBILENET_V1_SSD_300_PATH);
+       inferenceFace();
+}
\ No newline at end of file