--- /dev/null
+#include <gtest/gtest.h>
+#include <ImageHelper.h>
+#include "test_inference_helper.hpp"
+
+#define FLD_OPENCV_WEIGHT_CAFFE_PATH \
+ MV_CONFIG_PATH \
+ "/models/FLD/caffe/fld_caffe_model_tweak.caffemodel"
+#define FLD_OPENCV_CONFIG_CAFFE_PATH \
+ MV_CONFIG_PATH \
+ "models/FLD/caffe/fld_caffe_model_tweak.prototxt"
+#define IMG_FACE_LANDMARK \
+ MV_CONFIG_PATH \
+ "/res/inference/images/faceLandmark.jpg"
+
+void _facial_landmark_detected_cb(mv_source_h source,
+ const int number_of_landmarks,
+ const mv_point_s *locations, void *user_data)
+{
+ EXPECT_GT(number_of_landmarks, 0);
+}
+
+class TestFaceLandmarkDetection : public TestInference
+{
+public:
+ void inferenceFaceLandmark()
+ {
+ 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_LANDMARK, mv_source),
+ MEDIA_VISION_ERROR_NONE);
+ ASSERT_EQ(mv_inference_facial_landmark_detect(
+ mv_source, infer, NULL, _facial_landmark_detected_cb,
+ NULL),
+ MEDIA_VISION_ERROR_NONE);
+ }
+};
+
+TEST_F(TestFaceLandmarkDetection, CPU_OPENCV_CAFFE_CNNCASCADE)
+{
+ const char *inputNodeName = "data";
+ const char *outputNodeName[] = { "Sigmoid_fc2" };
+
+ ASSERT_EQ(mv_engine_config_set_string_attribute(
+ engine_cfg, MV_INFERENCE_MODEL_WEIGHT_FILE_PATH,
+ FLD_OPENCV_WEIGHT_CAFFE_PATH),
+ MEDIA_VISION_ERROR_NONE);
+ ASSERT_EQ(mv_engine_config_set_int_attribute(engine_cfg,
+ MV_INFERENCE_INPUT_DATA_TYPE,
+ MV_INFERENCE_DATA_FLOAT32),
+ MEDIA_VISION_ERROR_NONE);
+ ASSERT_EQ(mv_engine_config_set_string_attribute(
+ engine_cfg, MV_INFERENCE_MODEL_CONFIGURATION_FILE_PATH,
+ FLD_OPENCV_CONFIG_CAFFE_PATH),
+ MEDIA_VISION_ERROR_NONE);
+ ASSERT_EQ(mv_engine_config_set_double_attribute(
+ engine_cfg, MV_INFERENCE_MODEL_MEAN_VALUE, 127.5),
+ MEDIA_VISION_ERROR_NONE);
+ ASSERT_EQ(mv_engine_config_set_double_attribute(
+ engine_cfg, MV_INFERENCE_MODEL_STD_VALUE, 127.5),
+ MEDIA_VISION_ERROR_NONE);
+ ASSERT_EQ(mv_engine_config_set_int_attribute(engine_cfg,
+ MV_INFERENCE_BACKEND_TYPE,
+ MV_INFERENCE_BACKEND_OPENCV),
+ MEDIA_VISION_ERROR_NONE);
+ ASSERT_EQ(mv_engine_config_set_int_attribute(engine_cfg,
+ MV_INFERENCE_TARGET_TYPE,
+ MV_INFERENCE_TARGET_CPU),
+ MEDIA_VISION_ERROR_NONE);
+ ASSERT_EQ(mv_engine_config_set_int_attribute(
+ engine_cfg, MV_INFERENCE_INPUT_TENSOR_WIDTH, 128),
+ MEDIA_VISION_ERROR_NONE);
+ ASSERT_EQ(mv_engine_config_set_int_attribute(
+ engine_cfg, MV_INFERENCE_INPUT_TENSOR_HEIGHT, 128),
+ MEDIA_VISION_ERROR_NONE);
+ ASSERT_EQ(mv_engine_config_set_int_attribute(
+ engine_cfg, MV_INFERENCE_INPUT_TENSOR_CHANNELS, 3),
+ MEDIA_VISION_ERROR_NONE);
+ ASSERT_EQ(mv_engine_config_set_string_attribute(
+ engine_cfg, MV_INFERENCE_INPUT_NODE_NAME, inputNodeName),
+ MEDIA_VISION_ERROR_NONE);
+ ASSERT_EQ(mv_engine_config_set_array_string_attribute(
+ engine_cfg, MV_INFERENCE_OUTPUT_NODE_NAMES,
+ outputNodeName, 1),
+ MEDIA_VISION_ERROR_NONE);
+ inferenceFaceLandmark();
+}
\ No newline at end of file