test: Add TestPoseLandmarkDetection 90/264390/1
authorKwang Son <k.son@samsung.com>
Fri, 17 Sep 2021 01:04:05 +0000 (21:04 -0400)
committerKwang Son <k.son@samsung.com>
Fri, 17 Sep 2021 01:04:05 +0000 (21:04 -0400)
Change-Id: Iebbfda014bbf9e6bf0db68c79b675f9879b7de5d
Signed-off-by: Kwang Son <k.son@samsung.com>
test/CMakeLists.txt
test/testsuites/machine_learning/inference/test_pose_landmark_detection.cpp [new file with mode: 0644]

index ae209ce..7008d14 100644 (file)
@@ -11,6 +11,7 @@ add_executable(${PROJECT_NAME}
     testsuites/machine_learning/inference/test_object_detection.cpp
     testsuites/machine_learning/inference/test_face_detection.cpp
     testsuites/machine_learning/inference/test_face_landmark_detection.cpp
+    testsuites/machine_learning/inference/test_pose_landmark_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_pose_landmark_detection.cpp b/test/testsuites/machine_learning/inference/test_pose_landmark_detection.cpp
new file mode 100644 (file)
index 0000000..033488c
--- /dev/null
@@ -0,0 +1,45 @@
+#include <gtest/gtest.h>
+#include <ImageHelper.h>
+#include "test_inference_helper.hpp"
+
+#define PLD_TFLITE_WEIGHT_MOBILENET_V1_POSENET_257_PATH \
+       MV_CONFIG_PATH                                      \
+       "/models/PLD/tflite/pld_mobilenet_v1_posenet_multi_257x257.tflite"
+#define IMG_POSE_LANDMARK \
+       MV_CONFIG_PATH        \
+       "/res/inference/images/poseLandmark.jpg"
+
+void _pose_landmark_detected_cb(mv_source_h source,
+                                                               mv_inference_pose_result_h pose,
+                                                               void *user_data)
+{
+       int cb_number_of_poses = 0;
+       ASSERT_EQ(mv_inference_pose_get_number_of_poses(pose, &cb_number_of_poses),
+                         MEDIA_VISION_ERROR_NONE);
+       ASSERT_EQ(cb_number_of_poses, 1);
+}
+
+class TestPoseLandmarkDetection : public TestInference
+{
+public:
+       void inferencePoseLandmark()
+       {
+               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_POSE_LANDMARK, mv_source),
+                                 MEDIA_VISION_ERROR_NONE);
+               ASSERT_EQ(mv_inference_pose_landmark_detect(mv_source, infer, NULL,
+                                                                                                       _pose_landmark_detected_cb,
+                                                                                                       NULL),
+                                 MEDIA_VISION_ERROR_NONE);
+       }
+};
+
+TEST_F(TestPoseLandmarkDetection, CPU_TFLITE_MobilenetV1)
+{
+       engine_config_hosted_cpu_tflite(
+                       engine_cfg, PLD_TFLITE_WEIGHT_MOBILENET_V1_POSENET_257_PATH);
+       inferencePoseLandmark();
+}
\ No newline at end of file