int RegisterNewFace(mv_source_h img_src, std::string label_name);
int RecognizeFace(mv_source_h img_src);
int DeleteLabel(std::string label_name);
- int GetLabel(const char **out_label);
mv_face_recognition_result_s &GetResult();
};
return MEDIA_VISION_ERROR_NONE;
}
-int FaceRecognition::GetLabel(const char **out_label)
-{
- if (_status != INFERENCED) {
- LOGE("Inference not completed yet.");
- return MEDIA_VISION_ERROR_INVALID_OPERATION;
- }
-
- try {
- _label_manager->GetLabelString(_result.label, _result.label_idx);
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- *out_label = _result.label.c_str();
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
mv_face_recognition_result_s &FaceRecognition::GetResult()
{
+ if (_status != INFERENCED)
+ throw InvalidOperation("Inference not completed yet.");
+
if (!_label_manager)
throw NoData("Label file doesn't exist.");
Name: capi-media-vision
Summary: Media Vision library for Tizen Native API
-Version: 0.23.23
+Version: 0.23.24
Release: 0
Group: Multimedia/Framework
License: Apache-2.0 and BSD-3-Clause
set(TEST_FACE_RECOGNITION test_face_recognition)
set(MEASURE_ACCURACY measure_face_recognition)
-add_executable(${TEST_FACE_RECOGNITION} test_face_recognition.cpp)
-add_executable(${MEASURE_ACCURACY} measure_face_recognition.cpp)
+add_executable(${TEST_FACE_RECOGNITION} face_recognition_test_util.cpp test_face_recognition.cpp)
+add_executable(${MEASURE_ACCURACY} face_recognition_test_util.cpp measure_face_recognition.cpp)
target_link_libraries(${TEST_FACE_RECOGNITION} gtest gtest_main
mv_face_recognition
--- /dev/null
+/**
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+
+#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"
+
+void RemoveModelResources(void)
+{
+ remove(LABEL_FILE_PATH);
+ remove(MODEL_FILE_PATH);
+ remove(FV_FILE_PATH);
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __FACE_RECOGNITION_TEST_UTIL_H__
+#define __FACE_RECOGNITION_TEST_UTIL_H__
+
+void RemoveModelResources(void);
+
+#endif //__FACE_RECOGNITION_TEST_UTIL_H__
#include "ImageHelper.h"
#include "mv_face_recognition.h"
+#include "face_recognition_test_util.h"
#define TRAIN_LIST_FILE "/home/owner/media/res/face_recognition/res/measurement/train_list.txt"
#define TEST_LIST_FILE "/home/owner/media/res/face_recognition/res/measurement/test_list.txt"
ret = mv_face_recognition_destroy(handle);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ RemoveModelResources();
}
int main(int argc, char **argv)
#include "ImageHelper.h"
#include "mv_face_recognition.h"
+#include "face_recognition_test_util.h"
#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, CreateAndDestroyShouldBeOk)
{
mv_face_recognition_h handle;
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
ret = mv_face_recognition_register(handle, mv_source, image.second.c_str());
- ASSERT_EQ(ret, 0);
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
ret = mv_destroy_source(mv_source);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
RemoveModelResources();
}
+TEST(FaceRecognitionTest, GetLabelWithoutInferenceShouldBeError)
+{
+ 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 : training_images) {
+ const string image_path = string(TRAINING_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_register(handle, mv_source, image.second.c_str());
+ ASSERT_EQ(ret, 0);
+
+ 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_EQ(ret, MEDIA_VISION_ERROR_INVALID_OPERATION);
+
+ ret = mv_face_recognition_destroy(handle);
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ RemoveModelResources();
+}
+
TEST(FaceRecognitionTest, InferenceWithoutLabelShouldBeOk)
{
mv_face_recognition_h handle;