diff options
author | Kwanghoon Son <k.son@samsung.com> | 2024-01-12 18:09:53 +0900 |
---|---|---|
committer | Kwanghoon Son <k.son@samsung.com> | 2024-01-17 10:31:52 +0900 |
commit | 7db97ca0b3d957b2444fa8e6ba685184c3c8af19 (patch) | |
tree | 7fb3366d4158b2a5526fb88fe69d2b7f066b7526 | |
parent | 6ca5a0714fb6cf70b0d209a583c963bb34080fbb (diff) | |
download | mediavision-7db97ca0b3d957b2444fa8e6ba685184c3c8af19.tar.gz mediavision-7db97ca0b3d957b2444fa8e6ba685184c3c8af19.tar.bz2 mediavision-7db97ca0b3d957b2444fa8e6ba685184c3c8af19.zip |
Skip test when feature key not supported
Change-Id: I577788343140913473405b7511620ab2914dac3f
Signed-off-by: Kwanghoon Son <k.son@samsung.com>
6 files changed, 173 insertions, 301 deletions
diff --git a/test/testsuites/machine_learning/face_recognition/CMakeLists.txt b/test/testsuites/machine_learning/face_recognition/CMakeLists.txt index 816b8219..0f924ed4 100644 --- a/test/testsuites/machine_learning/face_recognition/CMakeLists.txt +++ b/test/testsuites/machine_learning/face_recognition/CMakeLists.txt @@ -3,5 +3,4 @@ set(SRC_FILES testsuites/machine_learning/face_recognition/face_recognition_test_util.cpp testsuites/machine_learning/face_recognition/measure_face_recognition.cpp testsuites/machine_learning/face_recognition/test_face_recognition.cpp - testsuites/machine_learning/face_recognition/test_face_recognition_multi_threads.cpp )
\ No newline at end of file diff --git a/test/testsuites/machine_learning/face_recognition/face_recognition_test_util.cpp b/test/testsuites/machine_learning/face_recognition/face_recognition_test_util.cpp index 899fa65d..c1d8911f 100644 --- a/test/testsuites/machine_learning/face_recognition/face_recognition_test_util.cpp +++ b/test/testsuites/machine_learning/face_recognition/face_recognition_test_util.cpp @@ -16,27 +16,33 @@ #include <stdio.h> #include <string> +#include <vector> #include <app_common.h> +#include <unistd.h> using namespace std; -void RemoveModelResources(void) +static vector<string> __get_full_res_path(void) { - string labelFilePath = "/labels.dat"; - string modelFilePath = "/model_and_weights.ini"; - string FVFilePath = "/feature_vector_file.dat"; - auto trusted_path = app_get_shared_trusted_path(); - auto prefix = [&]() -> string { return trusted_path ? trusted_path : TEST_RES_PATH "/res/face_recognition"; }; + const string prefix = trusted_path ? trusted_path : TEST_RES_PATH "/res/face_recognition"; + free(trusted_path); - labelFilePath.insert(0, prefix()); - modelFilePath.insert(0, prefix()); - FVFilePath.insert(0, prefix()); + return { prefix + "/labels.dat", prefix + "/model_and_weights.ini", prefix + "/feature_vector_file.dat" }; +} - if (trusted_path) - free(trusted_path); +bool check_model_res_exist(void) +{ + for (const auto &path : __get_full_res_path()) { + if (access(path.c_str(), F_OK)) + return true; + } + return false; +} - remove(labelFilePath.c_str()); - remove(modelFilePath.c_str()); - remove(FVFilePath.c_str()); +void remove_model_res(void) +{ + for (const auto &path : __get_full_res_path()) { + remove(path.c_str()); + } }
\ No newline at end of file diff --git a/test/testsuites/machine_learning/face_recognition/face_recognition_test_util.h b/test/testsuites/machine_learning/face_recognition/face_recognition_test_util.h index 6d4e1eca..1e3ee6ec 100644 --- a/test/testsuites/machine_learning/face_recognition/face_recognition_test_util.h +++ b/test/testsuites/machine_learning/face_recognition/face_recognition_test_util.h @@ -17,6 +17,7 @@ #ifndef __FACE_RECOGNITION_TEST_UTIL_H__ #define __FACE_RECOGNITION_TEST_UTIL_H__ -void RemoveModelResources(void); +void remove_model_res(void); +bool check_model_res_exist(void); #endif //__FACE_RECOGNITION_TEST_UTIL_H__ diff --git a/test/testsuites/machine_learning/face_recognition/measure_face_recognition.cpp b/test/testsuites/machine_learning/face_recognition/measure_face_recognition.cpp index 9045f12e..fcdcf6a2 100644 --- a/test/testsuites/machine_learning/face_recognition/measure_face_recognition.cpp +++ b/test/testsuites/machine_learning/face_recognition/measure_face_recognition.cpp @@ -167,5 +167,5 @@ TEST(FaceRecognitionAccuracy, DISABLED_Measure) ret = mv_face_recognition_destroy(handle); ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - RemoveModelResources(); + remove_model_res(); } diff --git a/test/testsuites/machine_learning/face_recognition/test_face_recognition.cpp b/test/testsuites/machine_learning/face_recognition/test_face_recognition.cpp index 9e233398..87244847 100644 --- a/test/testsuites/machine_learning/face_recognition/test_face_recognition.cpp +++ b/test/testsuites/machine_learning/face_recognition/test_face_recognition.cpp @@ -17,6 +17,7 @@ #include <iostream> #include <string.h> #include <map> +#include <thread> #include "gtest/gtest.h" @@ -47,29 +48,127 @@ static const map<string, string> test_images = { using namespace MediaVision::Common; -TEST(FaceRecognitionTest, CreateAndDestroyShouldBeOk) +void Register(mv_face_recognition_h handle) { - mv_face_recognition_h handle; + for (auto &image : training_images) { + const string image_path = string(TRAINING_IMAGE_PATH) + image.first; + mv_source_h mv_source = NULL; - int ret = mv_face_recognition_create(&handle); - ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); + int ret = mv_create_source(&mv_source); + ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - ret = mv_face_recognition_destroy(handle); - 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, MEDIA_VISION_ERROR_NONE); + + ret = mv_destroy_source(mv_source); + ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); + } +} + +void Recognize(mv_face_recognition_h handle) +{ + vector<string> answers = { "3448", "3448", "2929", "2929", "3448", "3448", "7779", "2929", + "2929", "3448", "2929", "7779", "7779", "7779", "7779" }; + + unsigned int image_idx = 0; + unsigned int correct_cnt = 0; + + 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); + if (ret == MEDIA_VISION_ERROR_NO_DATA) { + mv_destroy_source(mv_source); + image_idx++; + continue; + } + + 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); + if (ret != MEDIA_VISION_ERROR_NONE) { + image_idx++; + continue; + } + + string label_str(out_label); + + if (answers[image_idx++] == label_str) + correct_cnt++; + } + + cout << "Correct/Total = " << correct_cnt << " / " << image_idx << endl; +} + +void Unregister(mv_face_recognition_h handle) +{ + vector<string> labels = { "3448", "2929", "7779" }; + + 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, MEDIA_VISION_ERROR_NONE); + + ret = mv_destroy_source(mv_source); + ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); + } + + for (auto &label : labels) { + int ret = mv_face_recognition_unregister(handle, label.c_str()); + ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); + } } -TEST(FaceRecognitionTest, InferenceAfterTrainingShouldBeOk) +class FaceRecognitionTest : public testing::Test { - RemoveModelResources(); +protected: + void SetUp() override + { + create_result = mv_face_recognition_create(&handle); + + if (create_result == MEDIA_VISION_ERROR_NOT_SUPPORTED) + GTEST_SKIP(); + ASSERT_EQ(create_result, MEDIA_VISION_ERROR_NONE); + ASSERT_FALSE(check_model_res_exist()); + } + void TearDown() override + { + if (create_result == MEDIA_VISION_ERROR_NONE) { + ASSERT_EQ(mv_face_recognition_destroy(handle), MEDIA_VISION_ERROR_NONE); + remove_model_res(); + } + } mv_face_recognition_h handle; + int create_result; +}; + +TEST_F(FaceRecognitionTest, InferenceAfterTrainingShouldBeOk) +{ vector<string> answers = { "3448", "3448", "2929", "2929", "3448", "3448", "7779", "2929", "2929", "3448", "2929", "7779", "7779", "7779", "7779" }; - int ret = mv_face_recognition_create(&handle); - ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - - ret = mv_face_recognition_prepare(handle); + auto ret = mv_face_recognition_prepare(handle); ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); for (auto &image : training_images) { @@ -127,18 +226,10 @@ TEST(FaceRecognitionTest, InferenceAfterTrainingShouldBeOk) } cout << "Correct/Total = " << correct_cnt << " / " << image_idx << endl; - - ret = mv_face_recognition_destroy(handle); - ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - - RemoveModelResources(); } -TEST(FaceRecognitionTest, RawResultAfterInferenceShouldBeOk) +TEST_F(FaceRecognitionTest, RawResultAfterInferenceShouldBeOk) { - RemoveModelResources(); - - mv_face_recognition_h handle; vector<string> label_answers = { "3448", "7779", "2929" }; vector<float> tensor_answers = { -0.535841, -1.36535, -1.1602, -0.565637, -1.41806, -1.13575, -1.15139, -1.43894, -0.632066, -1.26517, -1.53925, -0.60648, -0.794678, -1.24318, @@ -148,10 +239,7 @@ TEST(FaceRecognitionTest, RawResultAfterInferenceShouldBeOk) -1.4494, -1.29036, -0.664841, -1.45312, -1.27014, -0.58644, -1.35883, -1.33734, -0.60447, -1.39085 }; - int ret = mv_face_recognition_create(&handle); - ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - - ret = mv_face_recognition_prepare(handle); + auto ret = mv_face_recognition_prepare(handle); ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); for (const auto &image : training_images) { @@ -209,26 +297,15 @@ TEST(FaceRecognitionTest, RawResultAfterInferenceShouldBeOk) 1); } } - - ret = mv_face_recognition_destroy(handle); - ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - - RemoveModelResources(); } -TEST(FaceRecognitionTest, LabelUpdateAfterInferenceShouldBeOk) +TEST_F(FaceRecognitionTest, LabelUpdateAfterInferenceShouldBeOk) { - RemoveModelResources(); - - mv_face_recognition_h handle; vector<string> image_names = { "037830.png", "038965.png", "045978.png", "061310.png", "062261.png", "029342.png", "000928.png", "008922.png", "054616.png" }; vector<string> label_names = { "2929", "2929", "2929", "7779", "7779", "7779", "3448", "3448", "3448" }; - int ret = mv_face_recognition_create(&handle); - ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - - ret = mv_face_recognition_prepare(handle); + auto ret = mv_face_recognition_prepare(handle); ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); // Register two labels. @@ -324,20 +401,11 @@ TEST(FaceRecognitionTest, LabelUpdateAfterInferenceShouldBeOk) // num_of_confidence must be 2 now. ASSERT_EQ(num_of_confidences, 2); - - ret = mv_face_recognition_destroy(handle); - ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - - RemoveModelResources(); } -TEST(FaceRecognitionTest, GetLabelWithoutInferenceShouldBeError) +TEST_F(FaceRecognitionTest, GetLabelWithoutInferenceShouldBeError) { - RemoveModelResources(); - - mv_face_recognition_h handle; - - int ret = mv_face_recognition_create(&handle); + auto ret = mv_face_recognition_create(&handle); ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); ret = mv_face_recognition_prepare(handle); @@ -364,23 +432,11 @@ TEST(FaceRecognitionTest, GetLabelWithoutInferenceShouldBeError) ret = mv_face_recognition_get_label(handle, &out_label); ASSERT_EQ(ret, MEDIA_VISION_ERROR_NO_DATA); - - ret = mv_face_recognition_destroy(handle); - ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - - RemoveModelResources(); } -TEST(FaceRecognitionTest, InferenceWithoutLabelShouldBeOk) +TEST_F(FaceRecognitionTest, InferenceWithoutLabelShouldBeOk) { - RemoveModelResources(); - - 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); + auto ret = mv_face_recognition_prepare(handle); ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); for (auto &image : test_images) { @@ -404,15 +460,10 @@ TEST(FaceRecognitionTest, InferenceWithoutLabelShouldBeOk) 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, LabelRemovalShouldBeOk) +TEST_F(FaceRecognitionTest, LabelRemovalShouldBeOk) { - RemoveModelResources(); - vector<string> labels = { "3448", "2929", "7779" }; vector<vector<string> > answers = { { "none", "none", "2929", "2929", "none", "none", "7779", "2929", "2929", "none", "2929", "7779", "7779", "7779", "7779" }, @@ -422,12 +473,8 @@ TEST(FaceRecognitionTest, LabelRemovalShouldBeOk) "3448", "2929", "none", "none", "none", "none" } }; unsigned int label_idx = 0; - 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); + auto ret = mv_face_recognition_prepare(handle); ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); for (auto &label : labels) { @@ -502,17 +549,10 @@ TEST(FaceRecognitionTest, LabelRemovalShouldBeOk) cout << "Correct/Total = " << correct_cnt << " / " << image_idx << endl; } - - ret = mv_face_recognition_destroy(handle); - ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - - RemoveModelResources(); } -TEST(FaceRecognitionTest, RemoveAllLabelsShouldBeOk) +TEST_F(FaceRecognitionTest, RemoveAllLabelsShouldBeOk) { - RemoveModelResources(); - vector<string> labels = { "3448", "2929", "7779" }; vector<vector<string> > answers = { { "none", "none", "2929", "2929", "none", "none", "7779", "2929", "2929", "none", "2929", "7779", "7779", "7779", "7779" }, @@ -520,12 +560,8 @@ TEST(FaceRecognitionTest, RemoveAllLabelsShouldBeOk) "none", "none", "7779", "7779", "7779", "7779" }, { "none", "none", "none", "none", "none", "none", "none", "none", "none", "none", "none", "none", "none", "none", "none" } }; - 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); + auto ret = mv_face_recognition_prepare(handle); ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); for (auto &image : training_images) { @@ -604,9 +640,33 @@ TEST(FaceRecognitionTest, RemoveAllLabelsShouldBeOk) cout << "Correct/Total = " << correct_cnt << " / " << image_idx << endl; } +} - ret = mv_face_recognition_destroy(handle); +TEST_F(FaceRecognitionTest, RegisterAndRecognizeShouldBeOk) +{ + auto ret = mv_face_recognition_prepare(handle); ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - RemoveModelResources(); -}
\ No newline at end of file + std::thread register_thread([&] { Register(handle); }); + + std::thread recognize_thread([&] { Recognize(handle); }); + + register_thread.join(); + recognize_thread.join(); +} + +TEST_F(FaceRecognitionTest, RegisterAndRecognizeAndUnregisterShouldBeOk) +{ + auto ret = mv_face_recognition_prepare(handle); + ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); + + std::thread register_thread([&] { Register(handle); }); + + std::thread recognize_thread([&] { Recognize(handle); }); + + std::thread unregister_thread([&] { Unregister(handle); }); + + register_thread.join(); + recognize_thread.join(); + unregister_thread.join(); +} diff --git a/test/testsuites/machine_learning/face_recognition/test_face_recognition_multi_threads.cpp b/test/testsuites/machine_learning/face_recognition/test_face_recognition_multi_threads.cpp deleted file mode 100644 index 0d4859e7..00000000 --- a/test/testsuites/machine_learning/face_recognition/test_face_recognition_multi_threads.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/** - * Copyright (c) 2021 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 <unistd.h> -#include <iostream> -#include <string.h> -#include <map> -#include <thread> - -#include "gtest/gtest.h" - -#include "ImageHelper.h" -#include "mv_face_recognition.h" -#include "face_recognition_test_util.h" - -#define TRAINING_IMAGE_PATH TEST_RES_PATH "/res/face_recognition/res/test/training/" -#define TEST_IMAGE_PATH TEST_RES_PATH "/res/face_recognition/res/test/test/" -#define MAX_DATA_SET 15 - -using namespace testing; -using namespace std; - -static const map<string, string> training_images = { - { "037830.png", "2929" }, { "038965.png", "2929" }, { "045978.png", "2929" }, { "050501.png", "2929" }, - { "065899.png", "2929" }, { "010348.png", "7779" }, { "029342.png", "7779" }, { "035939.png", "7779" }, - { "061310.png", "7779" }, { "062261.png", "7779" }, { "000928.png", "3448" }, { "008922.png", "3448" }, - { "029633.png", "3448" }, { "032962.png", "3448" }, { "054616.png", "3448" } -}; - -static const map<string, string> test_images = { - { "068468.png", "2929" }, { "068883.png", "2929" }, { "075004.png", "2929" }, { "078125.png", "2929" }, - { "080649.png", "2929" }, { "074645.png", "7779" }, { "086536.png", "7779" }, { "089334.png", "7779" }, - { "096514.png", "7779" }, { "100336.png", "7779" }, { "054757.png", "3448" }, { "064838.png", "3448" }, - { "072749.png", "3448" }, { "073526.png", "3448" }, { "080451.png", "3448" } -}; - -using namespace MediaVision::Common; - -void Register(mv_face_recognition_h handle) -{ - 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, MEDIA_VISION_ERROR_NONE); - - ret = mv_destroy_source(mv_source); - ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - } -} - -void Recognize(mv_face_recognition_h handle) -{ - vector<string> answers = { "3448", "3448", "2929", "2929", "3448", "3448", "7779", "2929", - "2929", "3448", "2929", "7779", "7779", "7779", "7779" }; - - unsigned int image_idx = 0; - unsigned int correct_cnt = 0; - - 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); - if (ret == MEDIA_VISION_ERROR_NO_DATA) { - mv_destroy_source(mv_source); - image_idx++; - continue; - } - - 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); - if (ret != MEDIA_VISION_ERROR_NONE) { - image_idx++; - continue; - } - - string label_str(out_label); - - if (answers[image_idx++] == label_str) - correct_cnt++; - } - - cout << "Correct/Total = " << correct_cnt << " / " << image_idx << endl; -} - -void Unregister(mv_face_recognition_h handle) -{ - vector<string> labels = { "3448", "2929", "7779" }; - - 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, MEDIA_VISION_ERROR_NONE); - - ret = mv_destroy_source(mv_source); - ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - } - - for (auto &label : labels) { - int ret = mv_face_recognition_unregister(handle, label.c_str()); - ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - } -} - -TEST(FaceRecognitionMultithreadTest, RegisterAndRecognizeShouldBeOk) -{ - RemoveModelResources(); - - 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); - - std::thread register_thread([&] { Register(handle); }); - - std::thread recognize_thread([&] { Recognize(handle); }); - - register_thread.join(); - recognize_thread.join(); - - ret = mv_face_recognition_destroy(handle); - ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - - RemoveModelResources(); -} - -TEST(FaceRecognitionMultithreadTest, RegisterAndRecognizeAndUnregisterShouldBeOk) -{ - RemoveModelResources(); - - 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); - - std::thread register_thread([&] { Register(handle); }); - - std::thread recognize_thread([&] { Recognize(handle); }); - - std::thread unregister_thread([&] { Unregister(handle); }); - - register_thread.join(); - recognize_thread.join(); - unregister_thread.join(); - - ret = mv_face_recognition_destroy(handle); - ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - - RemoveModelResources(); -}
\ No newline at end of file |