From 95a17a82e9012ba3f616f9e304e4d508e95bb126 Mon Sep 17 00:00:00 2001 From: Kwang Son Date: Thu, 16 Sep 2021 21:04:05 -0400 Subject: [PATCH] test: Add TestPoseLandmarkDetection Change-Id: Iebbfda014bbf9e6bf0db68c79b675f9879b7de5d Signed-off-by: Kwang Son --- test/CMakeLists.txt | 1 + .../inference/test_pose_landmark_detection.cpp | 45 ++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 test/testsuites/machine_learning/inference/test_pose_landmark_detection.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ae209ce..7008d14 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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 index 0000000..033488c --- /dev/null +++ b/test/testsuites/machine_learning/inference/test_pose_landmark_detection.cpp @@ -0,0 +1,45 @@ +#include +#include +#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 -- 2.7.4