#define TRAINING_IMAGE_PATH "/home/owner/media/res/face_recognition/res/test/training/"
#define TEST_IMAGE_PATH "/home/owner/media/res/face_recognition/res/test/test/"
+#define LABEL_FILE_PATH "/home/owner/media/res/face_recognition/training/labels.dat"
+#define MODEL_FILE_PATH "/home/owner/media/res/face_recognition/training/model_and_weights.ini"
+#define FV_FILE_PATH "/home/owner/media/res/face_recognition/training/feature_vector_file.dat"
using namespace testing;
using namespace std;
using namespace MediaVision::Common;
+static void RemoveModelResources(void)
+{
+ remove(LABEL_FILE_PATH);
+ remove(MODEL_FILE_PATH);
+ remove(FV_FILE_PATH);
+}
+
TEST(FaceRecognitionTest, FaceRecognitionSimpleTest)
{
mv_face_recognition_h handle;
ret = mv_face_recognition_destroy(handle);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ RemoveModelResources();
+}
+
+TEST(FaceRecognitionTest, NoLabelShouldBeOk)
+{
+ mv_face_recognition_h handle;
+
+ int ret = mv_face_recognition_create(&handle);
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_face_recognition_prepare(handle);
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ for (auto& image : test_images) {
+ const string image_path = string(TEST_IMAGE_PATH) + image.first;
+ mv_source_h mv_source = NULL;
+
+ int ret = mv_create_source(&mv_source);
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ ret = ImageHelper::loadImageToSource(image_path.c_str(), mv_source);
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_face_recognition_inference(handle, mv_source);
+ ASSERT_NE(ret, MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_destroy_source(mv_source);
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ const char *out_label = NULL;
+
+ ret = mv_face_recognition_get_label(handle, &out_label);
+ ASSERT_NE(ret, MEDIA_VISION_ERROR_NONE);
+ }
+
+ ret = mv_face_recognition_destroy(handle);
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
}
TEST(FaceRecognitionTest, FaceRecognitionClassWithEachLabelRemovalShouldBeOk)
ret = mv_face_recognition_destroy(handle);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ RemoveModelResources();
}
TEST(FaceRecognitionTest, RemoveAllLabelsShouldBeOk)
ret = mv_face_recognition_destroy(handle);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ RemoveModelResources();
}
int main(int argc, char **argv)