LOGW("A given model name is invalid so default task type will be used.");
}
- if (model_file.empty() && meta_file.empty())
- throw InvalidParameter("Model info not invalid.");
+ if (model_file.empty() && meta_file.empty()) {
+ LOGW("Given model info is invalid so default model info will be used instead.");
+ return;
+ }
}
void ObjectDetection3dAdapter::setEngineInfo(const string &engine_type, const string &device_type)
MediaSource *mediaSource = static_cast<MediaSource *>(source);
cv::Mat image = cv::imread(filePath);
+
+ if (!image.data)
+ return MEDIA_VISION_ERROR_INVALID_OPERATION;
+
cv::cvtColor(image, image, CV_BGR2RGB);
if (!(mediaSource->fill(image.data, image.total() * image.elemSize(), image.cols, image.rows, OPEN_CV_COLOR)))
TEST(FaceRecognitionMultithreadTest, RegisterAndRecognizeShouldBeOk)
{
+ RemoveModelResources();
+
mv_face_recognition_h handle;
int ret = mv_face_recognition_create(&handle);
TEST(FaceRecognitionMultithreadTest, RegisterAndRecognizeAndUnregisterShouldBeOk)
{
+ RemoveModelResources();
+
mv_face_recognition_h handle;
int ret = mv_face_recognition_create(&handle);
ret = mv_image_classification_create(&handle);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
- mv_image_classification_set_model(handle, model.model_file.c_str(), model.meta_file.c_str(),
- model.label_file.c_str());
- mv_image_classification_set_engine(handle, "tflite", "cpu");
+ ret = mv_image_classification_set_model(handle, model.model_file.c_str(), model.meta_file.c_str(),
+ model.label_file.c_str());
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_image_classification_set_engine(handle, "tflite", "cpu");
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
ret = mv_image_classification_configure(handle);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
cout << "model name : " << model.model_file << endl;
- mv_image_classification_set_model(handle, model.model_file.c_str(), model.meta_file.c_str(),
- model.label_file.c_str());
- mv_image_classification_set_engine(handle, "tflite", "cpu");
+ ret = mv_image_classification_set_model(handle, model.model_file.c_str(), model.meta_file.c_str(),
+ model.label_file.c_str());
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_image_classification_set_engine(handle, "tflite", "cpu");
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
ret = mv_image_classification_configure(handle);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
cout << "model name : " << model.model_file << endl;
- mv_image_classification_set_model(handle, model.model_file.c_str(), model.meta_file.c_str(),
- model.label_file.c_str());
- mv_image_classification_set_engine(handle, "tflite", "cpu");
+ ret = mv_image_classification_set_model(handle, model.model_file.c_str(), model.meta_file.c_str(),
+ model.label_file.c_str());
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_image_classification_set_engine(handle, "tflite", "cpu");
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
ret = mv_image_classification_configure(handle);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
ret = mv_selfie_segmentation_create(&handle);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
- mv_selfie_segmentation_set_model(handle, model.model_name.c_str(), model.model_file.c_str(),
- model.meta_file.c_str(), model.label_file.c_str());
- mv_selfie_segmentation_set_engine(handle, "tflite", "cpu");
+ ret = mv_selfie_segmentation_set_model(handle, model.model_name.c_str(), model.model_file.c_str(),
+ model.meta_file.c_str(), model.label_file.c_str());
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_selfie_segmentation_set_engine(handle, "tflite", "cpu");
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
ret = mv_selfie_segmentation_configure(handle);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
cout << "model name : " << model.model_file << endl;
- mv_pose_landmark_set_model(handle, model.model_name.c_str(), model.model_file.c_str(), model.meta_file.c_str(),
- model.label_file.c_str());
- mv_pose_landmark_set_engine(handle, "tflite", "cpu");
+ ret = mv_pose_landmark_set_model(handle, model.model_name.c_str(), model.model_file.c_str(),
+ model.meta_file.c_str(), model.label_file.c_str());
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_pose_landmark_set_engine(handle, "tflite", "cpu");
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
ret = mv_pose_landmark_configure(handle);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
cout << "model name : " << model.model_file << endl;
- mv_pose_landmark_set_model(handle, model.model_name.c_str(), model.model_file.c_str(), model.meta_file.c_str(),
- model.label_file.c_str());
- mv_pose_landmark_set_engine(handle, "tflite", "cpu");
+ ret = mv_pose_landmark_set_model(handle, model.model_name.c_str(), model.model_file.c_str(),
+ model.meta_file.c_str(), model.label_file.c_str());
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_pose_landmark_set_engine(handle, "tflite", "cpu");
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
ret = mv_pose_landmark_configure(handle);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
cout << "model name : " << model.model_file << endl;
- mv_facial_landmark_set_model(handle, model.model_name.c_str(), model.model_file.c_str(),
- model.meta_file.c_str(), model.label_file.c_str());
- mv_facial_landmark_set_engine(handle, "tflite", "cpu");
+ ret = mv_facial_landmark_set_model(handle, model.model_name.c_str(), model.model_file.c_str(),
+ model.meta_file.c_str(), model.label_file.c_str());
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_facial_landmark_set_engine(handle, "tflite", "cpu");
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
ret = mv_facial_landmark_configure(handle);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
cout << "model name : " << model.model_file << endl;
- mv_facial_landmark_set_model(handle, model.model_name.c_str(), model.model_file.c_str(),
- model.meta_file.c_str(), model.label_file.c_str());
- mv_facial_landmark_set_engine(handle, "tflite", "cpu");
+ ret = mv_facial_landmark_set_model(handle, model.model_name.c_str(), model.model_file.c_str(),
+ model.meta_file.c_str(), model.label_file.c_str());
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_facial_landmark_set_engine(handle, "tflite", "cpu");
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
ret = mv_facial_landmark_configure(handle);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
ret = mv_object_detection_create(&handle);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
- mv_object_detection_set_model(handle, model.model_name.c_str(), model.model_file.c_str(),
- model.meta_file.c_str(), model.label_file.c_str());
- mv_object_detection_set_engine(handle, "tflite", "cpu");
+ ret = mv_object_detection_set_model(handle, model.model_name.c_str(), model.model_file.c_str(),
+ model.meta_file.c_str(), model.label_file.c_str());
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_object_detection_set_engine(handle, "tflite", "cpu");
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
ret = mv_object_detection_configure(handle);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
ret = mv_face_detection_create(&handle);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
- mv_face_detection_set_model(handle, model.model_name.c_str(), model.model_file.c_str(), model.meta_file.c_str(),
- model.label_file.c_str());
- mv_face_detection_set_engine(handle, "tflite", "cpu");
+ ret = mv_face_detection_set_model(handle, model.model_name.c_str(), model.model_file.c_str(),
+ model.meta_file.c_str(), model.label_file.c_str());
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_face_detection_set_engine(handle, "tflite", "cpu");
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
ret = mv_face_detection_configure(handle);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
cout << "model name : " << model.model_file << endl;
- mv_object_detection_set_model(handle, model.model_name.c_str(), model.model_file.c_str(),
- model.meta_file.c_str(), model.label_file.c_str());
- mv_object_detection_set_engine(handle, "tflite", "cpu");
+ ret = mv_object_detection_set_model(handle, model.model_name.c_str(), model.model_file.c_str(),
+ model.meta_file.c_str(), model.label_file.c_str());
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_object_detection_set_engine(handle, "tflite", "cpu");
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
ret = mv_object_detection_configure(handle);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
cout << "model name : " << model.model_file << endl;
- mv_object_detection_set_model(handle, model.model_name.c_str(), model.model_file.c_str(),
- model.meta_file.c_str(), model.label_file.c_str());
- mv_object_detection_set_engine(handle, "tflite", "cpu");
+ ret = mv_object_detection_set_model(handle, model.model_name.c_str(), model.model_file.c_str(),
+ model.meta_file.c_str(), model.label_file.c_str());
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_object_detection_set_engine(handle, "tflite", "cpu");
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
ret = mv_object_detection_configure(handle);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
cout << "model name : " << model.model_file << endl;
- mv_face_detection_set_model(handle, model.model_name.c_str(), model.model_file.c_str(), model.meta_file.c_str(),
- model.label_file.c_str());
- mv_face_detection_set_engine(handle, "tflite", "cpu");
+ ret = mv_face_detection_set_model(handle, model.model_name.c_str(), model.model_file.c_str(),
+ model.meta_file.c_str(), model.label_file.c_str());
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_face_detection_set_engine(handle, "tflite", "cpu");
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
ret = mv_face_detection_configure(handle);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
cout << "model name : " << model.model_file << endl;
- mv_face_detection_set_model(handle, model.model_name.c_str(), model.model_file.c_str(), model.meta_file.c_str(),
- model.label_file.c_str());
- mv_face_detection_set_engine(handle, "tflite", "cpu");
+ ret = mv_face_detection_set_model(handle, model.model_name.c_str(), model.model_file.c_str(),
+ model.meta_file.c_str(), model.label_file.c_str());
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_face_detection_set_engine(handle, "tflite", "cpu");
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
ret = mv_face_detection_configure(handle);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
ret = mv_object_detection_3d_create(&handle);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
- mv_object_detection_3d_set_model(handle, model.model_name.c_str(), model.model_file.c_str(),
- model.meta_file.c_str(), model.label_file.c_str());
- mv_object_detection_3d_set_engine(handle, "tflite", "cpu");
+ ret = mv_object_detection_3d_set_model(handle, model.model_name.c_str(), model.model_file.c_str(),
+ model.meta_file.c_str(), model.label_file.c_str());
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_object_detection_3d_set_engine(handle, "tflite", "cpu");
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
ret = mv_object_detection_3d_configure(handle);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);