From fb71eab6c97e43e974069c862fb08a1473d85e04 Mon Sep 17 00:00:00 2001 From: Tae-Young Chung Date: Mon, 5 Oct 2020 12:52:12 +0900 Subject: [PATCH 01/16] Fix landmarks to two dimensions mv_inference_pose_s composes of number_of_pose and mv_inference_landmark_s. The mv_inference_landmarks_s should include the pose index as well as landmark index. So, fix the landmarks from one dimensions to two dimensions. Change-Id: I68ce167846618487521df5ec92652e944413edf0 Signed-off-by: Tae-Young Chung --- include/mv_inference.h | 1 + include/mv_inference_private.h | 2 +- mv_inference/inference/src/Inference.cpp | 32 +++++++++++++----------- mv_inference/inference/src/mv_inference_open.cpp | 18 ++++++------- 4 files changed, 29 insertions(+), 24 deletions(-) diff --git a/include/mv_inference.h b/include/mv_inference.h index 3ed5c5a..6949592 100644 --- a/include/mv_inference.h +++ b/include/mv_inference.h @@ -910,6 +910,7 @@ int mv_pose_set_from_file(mv_pose_h pose, const char *motion_capture_file_path, * Their similarity will be given by the score between 0 ~ 1. * * @since_tizen 6.0 + * @remarks If @a action contains multiple poses, the first pose is used for comparison. * * @param[in] pose The handle to the pose * @param[in] action The action pose diff --git a/include/mv_inference_private.h b/include/mv_inference_private.h index 8125283..95dff31 100644 --- a/include/mv_inference_private.h +++ b/include/mv_inference_private.h @@ -50,7 +50,7 @@ typedef struct { typedef struct { int number_of_poses; int number_of_landmarks_per_pose; /**< The number of landmarks*/ - mv_inference_landmark_s *landmarks; /**< A set of landmarks describing pose */ + mv_inference_landmark_s **landmarks; /**< A set of landmarks describing pose */ } mv_inference_pose_s; /** diff --git a/mv_inference/inference/src/Inference.cpp b/mv_inference/inference/src/Inference.cpp index 771da37..2847190 100644 --- a/mv_inference/inference/src/Inference.cpp +++ b/mv_inference/inference/src/Inference.cpp @@ -138,6 +138,9 @@ namespace inference } if (mPoseResult) { + for (int poseIndex = 0; poseIndex < mPoseResult->number_of_poses; ++poseIndex) { + delete [] mPoseResult->landmarks[poseIndex]; + } delete [] mPoseResult->landmarks; delete mPoseResult; } @@ -1456,14 +1459,17 @@ namespace inference } mPoseResult->number_of_poses= number_of_poses; - mPoseResult->landmarks = new mv_inference_landmark_s[number_of_landmarks]; mPoseResult->number_of_landmarks_per_pose = number_of_landmarks; - for (int index = 0; index < number_of_landmarks; ++index) { - mPoseResult->landmarks[index].isAvailable = false; - mPoseResult->landmarks[index].point.x = -1; - mPoseResult->landmarks[index].point.y = -1; - mPoseResult->landmarks[index].label = -1; - mPoseResult->landmarks[index].score = -1.0f; + mPoseResult->landmarks = new mv_inference_landmark_s*[number_of_poses]; + for (int poseIndex = 0; poseIndex < number_of_poses; ++poseIndex) { + mPoseResult->landmarks[poseIndex] = new mv_inference_landmark_s[number_of_landmarks]; + for (int landmarkIndex = 0; landmarkIndex < number_of_landmarks; ++landmarkIndex) { + mPoseResult->landmarks[poseIndex][landmarkIndex].isAvailable = false; + mPoseResult->landmarks[poseIndex][landmarkIndex].point.x = -1; + mPoseResult->landmarks[poseIndex][landmarkIndex].point.y = -1; + mPoseResult->landmarks[poseIndex][landmarkIndex].label = -1; + mPoseResult->landmarks[poseIndex][landmarkIndex].score = -1.0f; + } } } @@ -1488,15 +1494,13 @@ namespace inference LOGI("landmarkIndex[%2d] - mapping to [%2d]: x[%.3f], y[%.3f], score[%.3f]", landmarkIndex, part, loc2f.x, loc2f.y, score); - mPoseResult->landmarks[landmarkIndex].isAvailable = true; - mPoseResult->landmarks[landmarkIndex].point.x = static_cast(static_cast(width) * loc2f.x); - mPoseResult->landmarks[landmarkIndex].point.y = static_cast(static_cast(height) * loc2f.y); - mPoseResult->landmarks[landmarkIndex].score = score; - mPoseResult->landmarks[landmarkIndex].label = -1; + mPoseResult->landmarks[poseIndex][landmarkIndex].isAvailable = true; + mPoseResult->landmarks[poseIndex][landmarkIndex].point.x = static_cast(static_cast(width) * loc2f.x); + mPoseResult->landmarks[poseIndex][landmarkIndex].point.y = static_cast(static_cast(height) * loc2f.y); + mPoseResult->landmarks[poseIndex][landmarkIndex].score = score; + mPoseResult->landmarks[poseIndex][landmarkIndex].label = -1; } } - mPoseResult->number_of_landmarks_per_pose = number_of_landmarks; - mPoseResult->number_of_poses = number_of_poses; *detectionResults = static_cast(mPoseResult); diff --git a/mv_inference/inference/src/mv_inference_open.cpp b/mv_inference/inference/src/mv_inference_open.cpp index 9a64555..c2c7f2b 100644 --- a/mv_inference/inference/src/mv_inference_open.cpp +++ b/mv_inference/inference/src/mv_inference_open.cpp @@ -833,9 +833,9 @@ int mv_inference_pose_landmark_detect_open( for (int pose = 0; pose < tmp->number_of_poses; ++pose) { for (int index = 0; index < tmp->number_of_landmarks_per_pose; ++index) { LOGI("PoseIdx[%2d]: x[%d], y[%d], score[%.3f]", index, - tmp->landmarks[index].point.x, - tmp->landmarks[index].point.y, - tmp->landmarks[index].score); + tmp->landmarks[pose][index].point.x, + tmp->landmarks[pose][index].point.y, + tmp->landmarks[pose][index].score); } } @@ -885,9 +885,9 @@ int mv_inference_pose_get_landmark_open( if (part_index < 0 || part_index >= handle->number_of_landmarks_per_pose) return MEDIA_VISION_ERROR_INVALID_PARAMETER; - *location = handle->landmarks[part_index].point; + *location = handle->landmarks[pose_index][part_index].point; - *score = handle->landmarks[part_index].score; + *score = handle->landmarks[pose_index][part_index].score; LOGI("[%d]:(%dx%d) - %.4f", pose_index, location->x, location->y, *score); @@ -904,7 +904,7 @@ int mv_inference_pose_get_label_open( if (pose_index < 0 || pose_index >= handle->number_of_poses) return MEDIA_VISION_ERROR_INVALID_PARAMETER; - *label = handle->landmarks[0].label; + *label = handle->landmarks[pose_index][0].label; LOGI("[%d]: label(%d)", pose_index, *label); @@ -981,13 +981,13 @@ int mv_pose_compare_open(mv_pose_h pose, mv_inference_pose_result_h action, int mv_inference_pose_s *pAction = static_cast(action); for (int k = 0; k < HUMAN_POSE_MAX_LANDMARKS; ++k) { - if (pAction->landmarks[k].point.x == -1 || pAction->landmarks[k].point.y == -1) { + if (pAction->landmarks[0][k].point.x == -1 || pAction->landmarks[0][k].point.y == -1) { actionParts.push_back(std::make_pair(false, cv::Point(-1,-1))); continue; } - actionParts.push_back(std::make_pair(true, cv::Point(pAction->landmarks[k].point.x, - pAction->landmarks[k].point.y))); + actionParts.push_back(std::make_pair(true, cv::Point(pAction->landmarks[0][k].point.x, + pAction->landmarks[0][k].point.y))); } -- 2.7.4 From 4145a87721bc0c1b38e731f8b83144a8f3b46386 Mon Sep 17 00:00:00 2001 From: Inki Dae Date: Wed, 28 Oct 2020 16:33:59 +0900 Subject: [PATCH 02/16] mv_inference: Call LoadConfigFile function This call updates default tensor filter type for MLAPI from /etc/inference/inference_engine_mlapi_backend.ini file. Change-Id: I024160aa01470c52dd579b0a84c9e0052dcd5b7f Signed-off-by: Inki Dae --- mv_inference/inference/src/Inference.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mv_inference/inference/src/Inference.cpp b/mv_inference/inference/src/Inference.cpp index 2847190..ffb16a2 100644 --- a/mv_inference/inference/src/Inference.cpp +++ b/mv_inference/inference/src/Inference.cpp @@ -839,8 +839,14 @@ namespace inference return MEDIA_VISION_ERROR_OUT_OF_MEMORY; } + // Load configuration file. + int ret = mBackend->LoadConfigFile(); + if (ret != INFERENCE_ENGINE_ERROR_NONE) { + return MEDIA_VISION_ERROR_INVALID_OPERATION; + } + // Bind a backend library. - int ret = mBackend->BindBackend(&config); + ret = mBackend->BindBackend(&config); if (ret != INFERENCE_ENGINE_ERROR_NONE) { LOGE("Fail to bind backend library.(%d)", mConfig.mBackedType); return MEDIA_VISION_ERROR_INVALID_OPERATION; -- 2.7.4 From 7e28570395f788893739601ea6309dbd23a09467 Mon Sep 17 00:00:00 2001 From: Inki Dae Date: Tue, 10 Nov 2020 11:54:02 +0900 Subject: [PATCH 03/16] mv_inference: Load mlapi specific ini file correctly inference_engine_mlapi_backend.ini file is specific to MLAPI backend. So load this file only in case that a given backend type is MLAPI. Change-Id: I385d73d8571b506f8ffa6937985436fe8e18f96a Signed-off-by: Inki Dae --- mv_inference/inference/src/Inference.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mv_inference/inference/src/Inference.cpp b/mv_inference/inference/src/Inference.cpp index ffb16a2..0c1de27 100644 --- a/mv_inference/inference/src/Inference.cpp +++ b/mv_inference/inference/src/Inference.cpp @@ -839,10 +839,14 @@ namespace inference return MEDIA_VISION_ERROR_OUT_OF_MEMORY; } - // Load configuration file. - int ret = mBackend->LoadConfigFile(); - if (ret != INFERENCE_ENGINE_ERROR_NONE) { - return MEDIA_VISION_ERROR_INVALID_OPERATION; + int ret = MEDIA_VISION_ERROR_NONE; + + // Load configuration file if a given backend type is mlapi. + if (config.backend_type == MV_INFERENCE_BACKEND_MLAPI) { + ret = mBackend->LoadConfigFile(); + if (ret != INFERENCE_ENGINE_ERROR_NONE) { + return MEDIA_VISION_ERROR_INVALID_OPERATION; + } } // Bind a backend library. -- 2.7.4 From dbd5e3a753a5865e76bbe77c075f24a8716d710b Mon Sep 17 00:00:00 2001 From: Inki Dae Date: Fri, 6 Nov 2020 15:21:13 +0900 Subject: [PATCH 04/16] mv_inference: Fix target device configuration Fixed an issue that target device type isn't updated correctly when binding a backend engine. This patch makes the target device configuration to be done before a backend engine binding is completed because actual target device configuration to the backend engine is done at binding time. Change-Id: I24b5779f294abdf8944d4ec0339f1c1282e2156b Signed-off-by: Inki Dae --- mv_inference/inference/src/mv_inference_open.cpp | 72 ++++++++++++------------ 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/mv_inference/inference/src/mv_inference_open.cpp b/mv_inference/inference/src/mv_inference_open.cpp index c2c7f2b..9231ee2 100644 --- a/mv_inference/inference/src/mv_inference_open.cpp +++ b/mv_inference/inference/src/mv_inference_open.cpp @@ -125,7 +125,6 @@ int mv_inference_configure_model_open(mv_inference_h infer, char *modelUserFilePath = NULL; double modelMeanValue = 0.0; int backendType = 0; - int targetTypes = 0; size_t userFileLength = 0; ret = mv_engine_config_get_string_attribute( @@ -166,13 +165,6 @@ int mv_inference_configure_model_open(mv_inference_h infer, goto _ERROR_; } - ret = mv_engine_config_get_int_attribute( - engine_config, MV_INFERENCE_TARGET_DEVICE_TYPE, &targetTypes); - if (ret != MEDIA_VISION_ERROR_NONE) { - LOGE("Fail to get inference target type"); - goto _ERROR_; - } - if (access(modelWeightFilePath, F_OK)) { LOGE("weightFilePath in [%s] ", modelWeightFilePath); ret = MEDIA_VISION_ERROR_INVALID_PATH; @@ -198,34 +190,6 @@ int mv_inference_configure_model_open(mv_inference_h infer, goto _ERROR_; } - bool is_new_version; - - // Check if new inference engine framework or old one. - // new inference engine framework has different mv_inference_target_type_e enumeration values - // to support multiple inference target devices. So in case of old version, - // enumeration value given by user should be converted to new value, which - // will be done at ConfigureTargetTypes callback internally. - // Ps. this function will be dropped with deprecated code version-after-next of Tizen. - ret = check_mv_inference_engine_version(engine_config, &is_new_version); - if (ret != MEDIA_VISION_ERROR_NONE) - goto _ERROR_; - - if (is_new_version) { - // Use new type. - if (pInfer->ConfigureTargetDevices(targetTypes) != - MEDIA_VISION_ERROR_NONE) { - LOGE("Tried to configure invalid target types."); - goto _ERROR_; - } - } else { - // Convert old type to new one and then use it. - if (pInfer->ConfigureTargetTypes(targetTypes) != - MEDIA_VISION_ERROR_NONE) { - LOGE("Tried to configure invalid target types."); - goto _ERROR_; - } - } - pInfer->ConfigureModelFiles(std::string(modelConfigFilePath), std::string(modelWeightFilePath), std::string(modelUserFilePath)); @@ -392,6 +356,7 @@ int mv_inference_configure_engine_open(mv_inference_h infer, Inference *pInfer = static_cast(infer); int backendType = 0; + int targetTypes = 0; int ret = MEDIA_VISION_ERROR_NONE; pInfer->SetEngineConfig(engine_config); @@ -403,6 +368,13 @@ int mv_inference_configure_engine_open(mv_inference_h infer, goto _ERROR_; } + ret = mv_engine_config_get_int_attribute( + engine_config, MV_INFERENCE_TARGET_DEVICE_TYPE, &targetTypes); + if (ret != MEDIA_VISION_ERROR_NONE) { + LOGE("Fail to get inference target type"); + goto _ERROR_; + } + ret = pInfer->ConfigureBackendType( (mv_inference_backend_type_e) backendType); if (ret != MEDIA_VISION_ERROR_NONE) { @@ -410,6 +382,34 @@ int mv_inference_configure_engine_open(mv_inference_h infer, goto _ERROR_; } + bool is_new_version; + + // Check if new inference engine framework or old one. + // new inference engine framework has different mv_inference_target_type_e enumeration values + // to support multiple inference target devices. So in case of old version, + // enumeration value given by user should be converted to new value, which + // will be done at ConfigureTargetTypes callback internally. + // Ps. this function will be dropped with deprecated code version-after-next of Tizen. + ret = check_mv_inference_engine_version(engine_config, &is_new_version); + if (ret != MEDIA_VISION_ERROR_NONE) + goto _ERROR_; + + if (is_new_version) { + // Use new type. + if (pInfer->ConfigureTargetDevices(targetTypes) != + MEDIA_VISION_ERROR_NONE) { + LOGE("Tried to configure invalid target types."); + goto _ERROR_; + } + } else { + // Convert old type to new one and then use it. + if (pInfer->ConfigureTargetTypes(targetTypes) != + MEDIA_VISION_ERROR_NONE) { + LOGE("Tried to configure invalid target types."); + goto _ERROR_; + } + } + // Create a inference-engine-common class object and load its corresponding library. ret = pInfer->Bind(); if (ret != MEDIA_VISION_ERROR_NONE) { -- 2.7.4 From 76bd620b63272ec3946d8f9e3e28e2477c10a1c0 Mon Sep 17 00:00:00 2001 From: Inki Dae Date: Mon, 30 Nov 2020 16:43:22 +0900 Subject: [PATCH 05/16] mv_inference: Fix seg. fault issue at ConfigureInputInfo() mBackendCapacity will be updated after Bind call so access to mBackendCapacity shoud be done after the completion of Binding. This patch makes the Bind callback to be called before calling ConfigureTargetDevices callback. Change-Id: If074e4005d03275272dfbce636d947c5d673802a Signed-off-by: Inki Dae --- mv_inference/inference/src/mv_inference_open.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mv_inference/inference/src/mv_inference_open.cpp b/mv_inference/inference/src/mv_inference_open.cpp index 9231ee2..57ec8fd 100644 --- a/mv_inference/inference/src/mv_inference_open.cpp +++ b/mv_inference/inference/src/mv_inference_open.cpp @@ -394,6 +394,14 @@ int mv_inference_configure_engine_open(mv_inference_h infer, if (ret != MEDIA_VISION_ERROR_NONE) goto _ERROR_; + // Create a inference-engine-common class object and load its corresponding library. + // Ps. Inference engine gets a capability from a given backend by Bind call + // so access to mBackendCapacity should be done after Bind. + ret = pInfer->Bind(); + if (ret != MEDIA_VISION_ERROR_NONE) { + LOGE("Fail to bind a backend engine."); + } + if (is_new_version) { // Use new type. if (pInfer->ConfigureTargetDevices(targetTypes) != @@ -410,12 +418,6 @@ int mv_inference_configure_engine_open(mv_inference_h infer, } } - // Create a inference-engine-common class object and load its corresponding library. - ret = pInfer->Bind(); - if (ret != MEDIA_VISION_ERROR_NONE) { - LOGE("Fail to bind a backend engine."); - } - LOGI("LEAVE"); _ERROR_: return ret; -- 2.7.4 From 58211e32fd023b0f40631ddf7c7a73ff0dc6e1e1 Mon Sep 17 00:00:00 2001 From: Kwang Son Date: Fri, 11 Dec 2020 09:08:18 +0900 Subject: [PATCH 06/16] Fix test result typo Facial -> Pose Change-Id: Idfa0cf10713005616b59cfd6f4e4287e8f62c7cb Signed-off-by: Kwang Son --- test/testsuites/inference/inference_test_suite.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/testsuites/inference/inference_test_suite.c b/test/testsuites/inference/inference_test_suite.c index 9904dcf..c2abbd5 100644 --- a/test/testsuites/inference/inference_test_suite.c +++ b/test/testsuites/inference/inference_test_suite.c @@ -2554,7 +2554,7 @@ int perform_pose_landmark_detection() while (sel_opt == 0) { sel_opt = show_menu( - "Run Facial Landmark Detection again?:", options_last, + "Run Pose Landmark Detection again?:", options_last, names_last, ARRAY_SIZE(options_last)); switch (sel_opt) { case 1: @@ -2602,8 +2602,8 @@ int main() const int options[] = { 1, 2, 3, 4, 5, 6 }; const char *names[] = { "Image Classification", "Object Detection", - "Face Detection", "Facial LandmarkDetection", - "Pose Detection", "Exit" }; + "Face Detection", "Facial Landmark Detection", + "Pose Landmark Detection", "Exit" }; int err = MEDIA_VISION_ERROR_NONE; while (sel_opt == 0) { -- 2.7.4 From 9bf593ba1735c09d9bde22dc7a08e6cb79852639 Mon Sep 17 00:00:00 2001 From: Kwang Son Date: Fri, 11 Dec 2020 08:56:12 +0900 Subject: [PATCH 07/16] Add Pose correction API mv_pose_subtract function is first part of correction API. With pose detection, they only get pose similarity score but hard to know differences between user and bvh skeleton line. Using mv_pose_subtract help how skeleton should be changed. Change-Id: I9296c00ae17ef45e3d5b86bafa913ad87974cfc6 Signed-off-by: Kwang Son --- include/mv_common.h | 11 +++++++++ include/mv_inference.h | 26 ++++++++++++++++++++++ mv_inference/inference/include/Posture.h | 13 ++++++++--- mv_inference/inference/include/mv_inference_open.h | 25 +++++++++++++++++++++ mv_inference/inference/src/Posture.cpp | 23 +++++++++++++++++++ mv_inference/inference/src/mv_inference.c | 18 +++++++++++++++ mv_inference/inference/src/mv_inference_open.cpp | 22 ++++++++++++++++++ 7 files changed, 135 insertions(+), 3 deletions(-) diff --git a/include/mv_common.h b/include/mv_common.h index b678894..9dbf58e 100644 --- a/include/mv_common.h +++ b/include/mv_common.h @@ -724,6 +724,17 @@ int mv_engine_config_foreach_supported_attribute( void *user_data); /** + * @brief The float vector array + * + * @since_tizen 6.5 + * + */ +typedef struct { + unsigned int dimension; /**< Size of vector */ + float *value; +} mv_vector_s; + +/** * @} */ diff --git a/include/mv_inference.h b/include/mv_inference.h index 6949592..ed62968 100644 --- a/include/mv_inference.h +++ b/include/mv_inference.h @@ -927,6 +927,32 @@ int mv_pose_set_from_file(mv_pose_h pose, const char *motion_capture_file_path, * @pre Detects the pose by using mv_inference_pose_landmark_detect() */ int mv_pose_compare(mv_pose_h pose, mv_inference_pose_result_h action, int parts, float *score); + +/** + * @brief Get vector subtraction(direction) between pose and action pose + * which is set by mv_pose_set_from_file(). + * @details Each pose and action vectors are selected using @a parts and return vector subtraction. + * @a parts contain two indices of user-defined pose 2d position. + * + * @since_tizen 6.5 + * @remarks If @a action contains multiple poses, the first pose is used for comparison. + * + * @param[in] pose The handle to the pose + * @param[in] action The action pose + * @param[in] parts The parts to be compared + * @param[out] direction two dimension vector + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation + * + * @pre Sets the pose by using mv_pose_set_from_file() + * @pre Detects the pose by using mv_inference_pose_landmark_detect() + */ +int mv_pose_subtract(mv_pose_h pose, mv_inference_pose_result_h action, mv_point_s* parts, mv_vector_s* direction); + /** * @} */ diff --git a/mv_inference/inference/include/Posture.h b/mv_inference/inference/include/Posture.h index 4c67fdc..ca100be 100644 --- a/mv_inference/inference/include/Posture.h +++ b/mv_inference/inference/include/Posture.h @@ -71,8 +71,15 @@ namespace inference int compare(int parts, std::vector> action, float* score); + /** + * @brief Get vector subtraction(direction) + * + * @since_tizen 6.5 + */ + int subtract(mv_point_s* parts, std::vector action, + mv_vector_s* direction); private: - cv::Vec2f getUnitVectors(cv::Point point1, cv::Point point2); + cv::Vec2f getUnitVectors(cv::Point point1, cv::Point point2); int getParts(int parts, std::vector>& pose, std::vector>>& posePart); @@ -82,8 +89,8 @@ namespace inference float cosineSimilarity(std::vector vec1, std::vector vec2, int size); private: - BvhParser mBvhParser; - Bvh mBvh; + BvhParser mBvhParser; + Bvh mBvh; std::map mMotionToPoseMap; /**< name, index */ std::vector> mPose; std::vector>> mPoseParts; diff --git a/mv_inference/inference/include/mv_inference_open.h b/mv_inference/inference/include/mv_inference_open.h index 7f22ac9..f210af3 100644 --- a/mv_inference/inference/include/mv_inference_open.h +++ b/mv_inference/inference/include/mv_inference_open.h @@ -699,6 +699,31 @@ extern "C" */ int mv_pose_compare_open(mv_pose_h pose, mv_inference_pose_result_h action, int parts, float *score); + /** + * @brief Get vector subtraction(direction) between pose and action pose + * which is set by mv_pose_set_from_file(). + * @details Each pose and action vectors are selected using @a parts and return vector subtraction. + * @a parts contain two indices of user-defined pose 2d position. + * + * @since_tizen 6.5 + * @remarks If @a action contains multiple poses, the first pose is used for comparison. + * + * @param[in] pose The handle to the pose + * @param[in] action The action pose + * @param[in] parts The parts to be compared + * @param[out] direction two dimension vector + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation + * + * @pre Sets the pose by using mv_pose_set_from_file() + * @pre Detects the pose by using mv_inference_pose_landmark_detect() + */ + int mv_pose_subtract_open(mv_pose_h pose, mv_inference_pose_result_h action, mv_point_s* parts, mv_vector_s* direction); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/mv_inference/inference/src/Posture.cpp b/mv_inference/inference/src/Posture.cpp index cd59464..3217f20 100644 --- a/mv_inference/inference/src/Posture.cpp +++ b/mv_inference/inference/src/Posture.cpp @@ -358,5 +358,28 @@ int Posture::compare(int parts, std::vector> action, return MEDIA_VISION_ERROR_NONE; } +int Posture::subtract(mv_point_s* parts, std::vector action, mv_vector_s* direction) +{ + LOGI("ENTER"); + + if(!(mPose[parts->x].first && mPose[parts->y].first && direction->dimension == 2)){ + LOGE("Invalid parameter"); + return MEDIA_VISION_ERROR_INVALID_PARAMETER; + } + + auto bvhVector = getUnitVectors(mPose[parts->x].second, mPose[parts->y].second); + auto userVector = getUnitVectors(action[0], action[1]); + LOGD("bvhVector (%f, %f), userVector (%f, %f)", bvhVector[0], bvhVector[1], userVector[0], userVector[1]); + + auto difference = bvhVector - userVector; + direction->value[0] = difference[0]; + direction->value[1] = difference[1]; + LOGD("direction (%f, %f)", direction->value[0], direction->value[1]); + + LOGI("LEAVE"); + + return MEDIA_VISION_ERROR_NONE; +} + } } // namespace diff --git a/mv_inference/inference/src/mv_inference.c b/mv_inference/inference/src/mv_inference.c index 454354e..6ca102b 100644 --- a/mv_inference/inference/src/mv_inference.c +++ b/mv_inference/inference/src/mv_inference.c @@ -497,3 +497,21 @@ int mv_pose_compare(mv_pose_h pose, mv_inference_pose_result_h action, int parts return ret; } + +int mv_pose_subtract(mv_pose_h pose, mv_inference_pose_result_h action, mv_point_s* parts, mv_vector_s* direction) +{ + MEDIA_VISION_SUPPORT_CHECK( + __mv_inference_check_system_info_feature_supported()); + MEDIA_VISION_INSTANCE_CHECK(pose); + MEDIA_VISION_INSTANCE_CHECK(action); + MEDIA_VISION_NULL_ARG_CHECK(parts); + MEDIA_VISION_NULL_ARG_CHECK(direction); + + MEDIA_VISION_FUNCTION_ENTER(); + + int ret = mv_pose_subtract_open(pose, action, parts, direction); + + MEDIA_VISION_FUNCTION_LEAVE(); + + return ret; +} diff --git a/mv_inference/inference/src/mv_inference_open.cpp b/mv_inference/inference/src/mv_inference_open.cpp index 57ec8fd..8186db6 100644 --- a/mv_inference/inference/src/mv_inference_open.cpp +++ b/mv_inference/inference/src/mv_inference_open.cpp @@ -1003,3 +1003,25 @@ int mv_pose_compare_open(mv_pose_h pose, mv_inference_pose_result_h action, int return MEDIA_VISION_ERROR_NONE; } + +int mv_pose_subtract_open(mv_pose_h pose, mv_inference_pose_result_h action, mv_point_s* parts, mv_vector_s* direction) +{ + auto pPose = static_cast(pose); + auto pAction = static_cast(action); + if (pAction->landmarks[0][parts->x].point.x == -1 || pAction->landmarks[0][parts->x].point.y == -1 || + pAction->landmarks[0][parts->y].point.x == -1 || pAction->landmarks[0][parts->y].point.y == -1) + return MEDIA_VISION_ERROR_INVALID_OPERATION; + + std::vector actionParts { + cv::Point(pAction->landmarks[0][parts->x].point.x, pAction->landmarks[0][parts->x].point.y), + cv::Point(pAction->landmarks[0][parts->y].point.x, pAction->landmarks[0][parts->y].point.y) + }; + + auto ret = pPose->subtract(parts, actionParts, direction); + if (ret != MEDIA_VISION_ERROR_NONE) { + LOGE("Fail to get direction"); + return ret; + } + + return MEDIA_VISION_ERROR_NONE; +} -- 2.7.4 From 7bc38c56d38de4aa18081b513c4dc86153627123 Mon Sep 17 00:00:00 2001 From: Hyunsoo Park Date: Thu, 17 Dec 2020 15:03:40 +0900 Subject: [PATCH 08/16] Removing unnecessary HTML link for feature/privilege Change-Id: I74e0ac0e0535f6bdcc794fdf77d1ecc3663b23fc Signed-off-by: Hyunsoo Park --- doc/mediavision_doc.h | 32 ++++++++++++++++---------------- include/mv_barcode_generate.h | 4 ++-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/doc/mediavision_doc.h b/doc/mediavision_doc.h index 135a291..371d227 100644 --- a/doc/mediavision_doc.h +++ b/doc/mediavision_doc.h @@ -59,13 +59,13 @@ * * @section CAPI_MEDIA_VISION_COMMON_MODULE_FEATURE Related Features * This API is related with the following features:\n - * - http://tizen.org/feature/vision.barcode_detection\n - * - http://tizen.org/feature/vision.barcode_generation\n - * - http://tizen.org/feature/vision.face_recognition\n - * - http://tizen.org/feature/vision.image_recognition\n - * - http://tizen.org/feature/vision.inference\n - * - http://tizen.org/feature/vision.inference.image\n - * - http://tizen.org/feature/vision.inference.face\n + * - %http://tizen.org/feature/vision.barcode_detection\n + * - %http://tizen.org/feature/vision.barcode_generation\n + * - %http://tizen.org/feature/vision.face_recognition\n + * - %http://tizen.org/feature/vision.image_recognition\n + * - %http://tizen.org/feature/vision.inference\n + * - %http://tizen.org/feature/vision.inference.image\n + * - %http://tizen.org/feature/vision.inference.face\n * * It is recommended to design feature related codes in your application for * reliability.\n @@ -88,7 +88,7 @@ * * @section CAPI_MEDIA_VISION_FACE_MODULE_FEATURE Related Features * This API is related with the following features:\n - * - http://tizen.org/feature/vision.face_recognition\n + * - %http://tizen.org/feature/vision.face_recognition\n * * It is recommended to design feature related codes in your application for * reliability.\n @@ -159,7 +159,7 @@ * * @section CAPI_MEDIA_VISION_IMAGE_MODULE_FEATURE Related Features * This API is related with the following features:\n - * - http://tizen.org/feature/vision.image_recognition\n + * - %http://tizen.org/feature/vision.image_recognition\n * * It is recommended to design feature related codes in your application for * reliability.\n @@ -208,8 +208,8 @@ * * @section CAPI_MEDIA_VISION_BARCODE_MODULE_FEATURE Related Features * This API is related with the following features:\n - * - http://tizen.org/feature/vision.barcode_detection\n - * - http://tizen.org/feature/vision.barcode_generation\n + * - %http://tizen.org/feature/vision.barcode_detection\n + * - %http://tizen.org/feature/vision.barcode_generation\n * * It is recommended to design feature related codes in your application for * reliability.\n @@ -262,8 +262,8 @@ * * @section CAPI_MEDIA_VISION_SURVEILLANCE_MODULE_FEATURE Related Features * This API is related with the following features:\n - * - http://tizen.org/feature/vision.image_recognition\n - * - http://tizen.org/feature/vision.face_recognition\n + * - %http://tizen.org/feature/vision.image_recognition\n + * - %http://tizen.org/feature/vision.face_recognition\n * * It is recommended to design feature related codes in your application for * reliability.\n @@ -381,9 +381,9 @@ * * @section CAPI_MEDIA_VISION_INFERECNE_MODULE_FEATURE Related Features * This API is related with the following features:\n - * - http://tizen.org/feature/vision.inference\n - * - http://tizen.org/feature/vision.inference.image\n - * - http://tizen.org/feature/vision.inference.face\n + * - %http://tizen.org/feature/vision.inference\n + * - %http://tizen.org/feature/vision.inference.image\n + * - %http://tizen.org/feature/vision.inference.face\n * * It is recommended to use features in your application for reliability.\n * You can check if the device supports the related features for this API by using diff --git a/include/mv_barcode_generate.h b/include/mv_barcode_generate.h index 15d9082..4a68a8b 100644 --- a/include/mv_barcode_generate.h +++ b/include/mv_barcode_generate.h @@ -138,9 +138,9 @@ int mv_barcode_generate_source( * #MEDIA_VISION_ERROR_INVALID_OPERATION will be returned * when @a type is MV_BARCODE_QR * - * @remarks The mediastorage privilege http://tizen.org/privilege/mediastorage is needed \n + * @remarks The mediastorage privilege %http://tizen.org/privilege/mediastorage is needed \n * if @a image_path is relevant to media storage.\n - * The externalstorage privilege http://tizen.org/privilege/externalstorage is needed \n + * The externalstorage privilege %http://tizen.org/privilege/externalstorage is needed \n * if @a image_path is relevant to external storage. * @param [in] engine_cfg The handle to the configuration of the engine * @param [in] message The message to be encoded in the barcode -- 2.7.4 From 1acdec169b90496b23cf18224e08516d8d1d3e3a Mon Sep 17 00:00:00 2001 From: Kwang Son Date: Thu, 17 Dec 2020 12:15:45 +0900 Subject: [PATCH 09/16] Add mv_pose_subtract test Change-Id: I5fe9047902737d1ca2582c886433e7a826c1ed8f Signed-off-by: Kwang Son --- test/testsuites/inference/inference_test_suite.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/test/testsuites/inference/inference_test_suite.c b/test/testsuites/inference/inference_test_suite.c index c2abbd5..e6c28b5 100644 --- a/test/testsuites/inference/inference_test_suite.c +++ b/test/testsuites/inference/inference_test_suite.c @@ -211,11 +211,25 @@ void _pose_landmark_detected_cb(mv_source_h source, &poseScore); if (ret != MEDIA_VISION_ERROR_NONE) { mv_pose_destroy(poser); - printf("Fail to mv_pose_compare"); + printf("Fail to mv_pose_compare\n"); return; } - printf("[Leg]:Left&Right - poseScore:[%1.4f]", poseScore); + printf("[Leg]:Left&Right - poseScore:[%1.4f]\n", poseScore); + + mv_point_s skeleton = {MV_INFERENCE_HUMAN_POSE_HEAD - 1, MV_INFERENCE_HUMAN_POSE_NECK - 1}; + float initf[] = {0.0, 0.0}; + mv_vector_s dir = {2, initf}; + + ret = mv_pose_subtract(poser, pose, &skeleton, &dir); + if (ret != MEDIA_VISION_ERROR_NONE) { + mv_pose_destroy(poser); + printf("Fail to mv_pose_subtract\n"); + return; + } + + printf("direction :(%1.4f, %1.4f)\n", dir.value[0], dir.value[1]); + ret = mv_pose_destroy(poser); if (ret != MEDIA_VISION_ERROR_NONE) { -- 2.7.4 From 416a5daedb75e11008beb99ab772bb8f9fd4872a Mon Sep 17 00:00:00 2001 From: kwang son Date: Thu, 17 Dec 2020 07:52:04 +0000 Subject: [PATCH 10/16] Revert "Add mv_pose_subtract test" This reverts commit 1acdec169b90496b23cf18224e08516d8d1d3e3a. Reason for revert: Change-Id: I98cb7a4d2e1f2cf3d23c02d3eec949476677bb01 --- test/testsuites/inference/inference_test_suite.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/test/testsuites/inference/inference_test_suite.c b/test/testsuites/inference/inference_test_suite.c index e6c28b5..c2abbd5 100644 --- a/test/testsuites/inference/inference_test_suite.c +++ b/test/testsuites/inference/inference_test_suite.c @@ -211,25 +211,11 @@ void _pose_landmark_detected_cb(mv_source_h source, &poseScore); if (ret != MEDIA_VISION_ERROR_NONE) { mv_pose_destroy(poser); - printf("Fail to mv_pose_compare\n"); + printf("Fail to mv_pose_compare"); return; } - printf("[Leg]:Left&Right - poseScore:[%1.4f]\n", poseScore); - - mv_point_s skeleton = {MV_INFERENCE_HUMAN_POSE_HEAD - 1, MV_INFERENCE_HUMAN_POSE_NECK - 1}; - float initf[] = {0.0, 0.0}; - mv_vector_s dir = {2, initf}; - - ret = mv_pose_subtract(poser, pose, &skeleton, &dir); - if (ret != MEDIA_VISION_ERROR_NONE) { - mv_pose_destroy(poser); - printf("Fail to mv_pose_subtract\n"); - return; - } - - printf("direction :(%1.4f, %1.4f)\n", dir.value[0], dir.value[1]); - + printf("[Leg]:Left&Right - poseScore:[%1.4f]", poseScore); ret = mv_pose_destroy(poser); if (ret != MEDIA_VISION_ERROR_NONE) { -- 2.7.4 From b7ff0963600e93c46a2f225a5afdf6fb5cf50d70 Mon Sep 17 00:00:00 2001 From: kwang son Date: Thu, 17 Dec 2020 07:53:40 +0000 Subject: [PATCH 11/16] Revert "Add Pose correction API" This reverts commit 9bf593ba1735c09d9bde22dc7a08e6cb79852639. Reason for revert: Change-Id: I8fa860433d69dc41b63fbe7193986109af1c7649 --- include/mv_common.h | 11 --------- include/mv_inference.h | 26 ---------------------- mv_inference/inference/include/Posture.h | 13 +++-------- mv_inference/inference/include/mv_inference_open.h | 25 --------------------- mv_inference/inference/src/Posture.cpp | 23 ------------------- mv_inference/inference/src/mv_inference.c | 18 --------------- mv_inference/inference/src/mv_inference_open.cpp | 22 ------------------ 7 files changed, 3 insertions(+), 135 deletions(-) diff --git a/include/mv_common.h b/include/mv_common.h index 9dbf58e..b678894 100644 --- a/include/mv_common.h +++ b/include/mv_common.h @@ -724,17 +724,6 @@ int mv_engine_config_foreach_supported_attribute( void *user_data); /** - * @brief The float vector array - * - * @since_tizen 6.5 - * - */ -typedef struct { - unsigned int dimension; /**< Size of vector */ - float *value; -} mv_vector_s; - -/** * @} */ diff --git a/include/mv_inference.h b/include/mv_inference.h index ed62968..6949592 100644 --- a/include/mv_inference.h +++ b/include/mv_inference.h @@ -927,32 +927,6 @@ int mv_pose_set_from_file(mv_pose_h pose, const char *motion_capture_file_path, * @pre Detects the pose by using mv_inference_pose_landmark_detect() */ int mv_pose_compare(mv_pose_h pose, mv_inference_pose_result_h action, int parts, float *score); - -/** - * @brief Get vector subtraction(direction) between pose and action pose - * which is set by mv_pose_set_from_file(). - * @details Each pose and action vectors are selected using @a parts and return vector subtraction. - * @a parts contain two indices of user-defined pose 2d position. - * - * @since_tizen 6.5 - * @remarks If @a action contains multiple poses, the first pose is used for comparison. - * - * @param[in] pose The handle to the pose - * @param[in] action The action pose - * @param[in] parts The parts to be compared - * @param[out] direction two dimension vector - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation - * - * @pre Sets the pose by using mv_pose_set_from_file() - * @pre Detects the pose by using mv_inference_pose_landmark_detect() - */ -int mv_pose_subtract(mv_pose_h pose, mv_inference_pose_result_h action, mv_point_s* parts, mv_vector_s* direction); - /** * @} */ diff --git a/mv_inference/inference/include/Posture.h b/mv_inference/inference/include/Posture.h index ca100be..4c67fdc 100644 --- a/mv_inference/inference/include/Posture.h +++ b/mv_inference/inference/include/Posture.h @@ -71,15 +71,8 @@ namespace inference int compare(int parts, std::vector> action, float* score); - /** - * @brief Get vector subtraction(direction) - * - * @since_tizen 6.5 - */ - int subtract(mv_point_s* parts, std::vector action, - mv_vector_s* direction); private: - cv::Vec2f getUnitVectors(cv::Point point1, cv::Point point2); + cv::Vec2f getUnitVectors(cv::Point point1, cv::Point point2); int getParts(int parts, std::vector>& pose, std::vector>>& posePart); @@ -89,8 +82,8 @@ namespace inference float cosineSimilarity(std::vector vec1, std::vector vec2, int size); private: - BvhParser mBvhParser; - Bvh mBvh; + BvhParser mBvhParser; + Bvh mBvh; std::map mMotionToPoseMap; /**< name, index */ std::vector> mPose; std::vector>> mPoseParts; diff --git a/mv_inference/inference/include/mv_inference_open.h b/mv_inference/inference/include/mv_inference_open.h index f210af3..7f22ac9 100644 --- a/mv_inference/inference/include/mv_inference_open.h +++ b/mv_inference/inference/include/mv_inference_open.h @@ -699,31 +699,6 @@ extern "C" */ int mv_pose_compare_open(mv_pose_h pose, mv_inference_pose_result_h action, int parts, float *score); - /** - * @brief Get vector subtraction(direction) between pose and action pose - * which is set by mv_pose_set_from_file(). - * @details Each pose and action vectors are selected using @a parts and return vector subtraction. - * @a parts contain two indices of user-defined pose 2d position. - * - * @since_tizen 6.5 - * @remarks If @a action contains multiple poses, the first pose is used for comparison. - * - * @param[in] pose The handle to the pose - * @param[in] action The action pose - * @param[in] parts The parts to be compared - * @param[out] direction two dimension vector - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation - * - * @pre Sets the pose by using mv_pose_set_from_file() - * @pre Detects the pose by using mv_inference_pose_landmark_detect() - */ - int mv_pose_subtract_open(mv_pose_h pose, mv_inference_pose_result_h action, mv_point_s* parts, mv_vector_s* direction); - #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/mv_inference/inference/src/Posture.cpp b/mv_inference/inference/src/Posture.cpp index 3217f20..cd59464 100644 --- a/mv_inference/inference/src/Posture.cpp +++ b/mv_inference/inference/src/Posture.cpp @@ -358,28 +358,5 @@ int Posture::compare(int parts, std::vector> action, return MEDIA_VISION_ERROR_NONE; } -int Posture::subtract(mv_point_s* parts, std::vector action, mv_vector_s* direction) -{ - LOGI("ENTER"); - - if(!(mPose[parts->x].first && mPose[parts->y].first && direction->dimension == 2)){ - LOGE("Invalid parameter"); - return MEDIA_VISION_ERROR_INVALID_PARAMETER; - } - - auto bvhVector = getUnitVectors(mPose[parts->x].second, mPose[parts->y].second); - auto userVector = getUnitVectors(action[0], action[1]); - LOGD("bvhVector (%f, %f), userVector (%f, %f)", bvhVector[0], bvhVector[1], userVector[0], userVector[1]); - - auto difference = bvhVector - userVector; - direction->value[0] = difference[0]; - direction->value[1] = difference[1]; - LOGD("direction (%f, %f)", direction->value[0], direction->value[1]); - - LOGI("LEAVE"); - - return MEDIA_VISION_ERROR_NONE; -} - } } // namespace diff --git a/mv_inference/inference/src/mv_inference.c b/mv_inference/inference/src/mv_inference.c index 6ca102b..454354e 100644 --- a/mv_inference/inference/src/mv_inference.c +++ b/mv_inference/inference/src/mv_inference.c @@ -497,21 +497,3 @@ int mv_pose_compare(mv_pose_h pose, mv_inference_pose_result_h action, int parts return ret; } - -int mv_pose_subtract(mv_pose_h pose, mv_inference_pose_result_h action, mv_point_s* parts, mv_vector_s* direction) -{ - MEDIA_VISION_SUPPORT_CHECK( - __mv_inference_check_system_info_feature_supported()); - MEDIA_VISION_INSTANCE_CHECK(pose); - MEDIA_VISION_INSTANCE_CHECK(action); - MEDIA_VISION_NULL_ARG_CHECK(parts); - MEDIA_VISION_NULL_ARG_CHECK(direction); - - MEDIA_VISION_FUNCTION_ENTER(); - - int ret = mv_pose_subtract_open(pose, action, parts, direction); - - MEDIA_VISION_FUNCTION_LEAVE(); - - return ret; -} diff --git a/mv_inference/inference/src/mv_inference_open.cpp b/mv_inference/inference/src/mv_inference_open.cpp index 8186db6..57ec8fd 100644 --- a/mv_inference/inference/src/mv_inference_open.cpp +++ b/mv_inference/inference/src/mv_inference_open.cpp @@ -1003,25 +1003,3 @@ int mv_pose_compare_open(mv_pose_h pose, mv_inference_pose_result_h action, int return MEDIA_VISION_ERROR_NONE; } - -int mv_pose_subtract_open(mv_pose_h pose, mv_inference_pose_result_h action, mv_point_s* parts, mv_vector_s* direction) -{ - auto pPose = static_cast(pose); - auto pAction = static_cast(action); - if (pAction->landmarks[0][parts->x].point.x == -1 || pAction->landmarks[0][parts->x].point.y == -1 || - pAction->landmarks[0][parts->y].point.x == -1 || pAction->landmarks[0][parts->y].point.y == -1) - return MEDIA_VISION_ERROR_INVALID_OPERATION; - - std::vector actionParts { - cv::Point(pAction->landmarks[0][parts->x].point.x, pAction->landmarks[0][parts->x].point.y), - cv::Point(pAction->landmarks[0][parts->y].point.x, pAction->landmarks[0][parts->y].point.y) - }; - - auto ret = pPose->subtract(parts, actionParts, direction); - if (ret != MEDIA_VISION_ERROR_NONE) { - LOGE("Fail to get direction"); - return ret; - } - - return MEDIA_VISION_ERROR_NONE; -} -- 2.7.4 From 6e85b1416a1ac37055382418234971a0f83278df Mon Sep 17 00:00:00 2001 From: Kwang Son Date: Wed, 13 Jan 2021 13:25:06 +0900 Subject: [PATCH 12/16] Replace gcc -w option to -Wall Gcc -Wall option enhance code quailty and delete -w option which is suppress warning. To clean code successfully follow bugs or warnings are fixed. - Cmake : -Wall -> -w and clean duplicate commands - Delete line : unused variables - strncpy : check null terminator and buffer size - exciplit header include - printf formatting, sprintf truncation - convert unmatched type - fix typo Change-Id: I049de491b2e832aa27900b046984306ea3aeb318 Signed-off-by: Kwang Son --- CMakeLists.txt | 10 +- include/mv_surveillance_private.h | 2 +- mv_barcode/barcode_detector/CMakeLists.txt | 4 - mv_barcode/barcode_generator/CMakeLists.txt | 4 - mv_common/CMakeLists.txt | 4 - mv_face/face/CMakeLists.txt | 4 - mv_face/face/src/mv_face.c | 111 ++++++++++----------- mv_image/image/CMakeLists.txt | 4 - mv_inference/inference/CMakeLists.txt | 4 - mv_surveillance/surveillance/src/mv_mask_buffer.c | 1 + mv_surveillance/surveillance/src/mv_surveillance.c | 3 +- test/testsuites/barcode/CMakeLists.txt | 4 - test/testsuites/barcode/barcode_test_suite.c | 22 ++-- test/testsuites/common/image_helper/CMakeLists.txt | 4 - .../common/testsuite_common/CMakeLists.txt | 3 - .../common/testsuite_common/mv_testsuite_common.c | 30 ++---- .../common/video_helper/mv_video_helper.c | 80 +++++++-------- test/testsuites/face/CMakeLists.txt | 4 - test/testsuites/face/face_test_suite.c | 27 ++--- test/testsuites/image/CMakeLists.txt | 4 - test/testsuites/image/image_test_suite.c | 19 ++-- test/testsuites/inference/CMakeLists.txt | 4 - test/testsuites/inference/inference_test_suite.c | 20 ++-- test/testsuites/surveillance/CMakeLists.txt | 4 - 24 files changed, 144 insertions(+), 232 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 081aee2..dcfeb03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -132,20 +132,14 @@ ELSE() ENDIF() ENDIF() -SET(CMAKE_C_FLAGS "-I./include -I./include/headers ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${NEON_CFLAGS} -fPIC -Wall -w") -SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") - -SET(CMAKE_CXX_FLAGS "-I./include -I./include/headers ${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS} ${NEON_CXXFLAGS} -fPIC") -SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -w") +SET(CMAKE_C_FLAGS "-I./include -I./include/headers ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${NEON_CFLAGS} -fPIC -Wall") +SET(CMAKE_CXX_FLAGS "-I./include -I./include/headers ${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS} ${NEON_CXXFLAGS} -fPIC -Wall") IF("${ARCH}" STREQUAL "arm") ADD_DEFINITIONS("-DTARGET") ENDIF("${ARCH}" STREQUAL "arm") ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") -ADD_DEFINITIONS("-DTIZEN_DEBUG") - -SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}") ADD_SUBDIRECTORY(mv_common) ADD_SUBDIRECTORY(mv_barcode) diff --git a/include/mv_surveillance_private.h b/include/mv_surveillance_private.h index 288a3be..1097370 100644 --- a/include/mv_surveillance_private.h +++ b/include/mv_surveillance_private.h @@ -35,7 +35,7 @@ extern "C" { */ typedef struct { unsigned int trigger_id; /**< Unique event trigger identifier */ - const char *event_type; /**< Type of the event */ + char *event_type; /**< Type of the event */ int number_of_roi_points; /**< Number of ROI (Region of interest) points */ mv_point_s *roi; /**< ROI points array */ } mv_surveillance_event_trigger_s; diff --git a/mv_barcode/barcode_detector/CMakeLists.txt b/mv_barcode/barcode_detector/CMakeLists.txt index d66a9e2..8ff4612 100644 --- a/mv_barcode/barcode_detector/CMakeLists.txt +++ b/mv_barcode/barcode_detector/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 2.6) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG _DEBUG) -if(NOT SKIP_WARNINGS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror") -endif() - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) diff --git a/mv_barcode/barcode_generator/CMakeLists.txt b/mv_barcode/barcode_generator/CMakeLists.txt index b9716ee..8c5112f 100644 --- a/mv_barcode/barcode_generator/CMakeLists.txt +++ b/mv_barcode/barcode_generator/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 2.6) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG _DEBUG) -if(NOT SKIP_WARNINGS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror") -endif() - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) diff --git a/mv_common/CMakeLists.txt b/mv_common/CMakeLists.txt index 10598cc..207df0e 100644 --- a/mv_common/CMakeLists.txt +++ b/mv_common/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 2.6) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG _DEBUG) -if(NOT SKIP_WARNINGS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror") -endif() - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) diff --git a/mv_face/face/CMakeLists.txt b/mv_face/face/CMakeLists.txt index 8aec2e3..9bb79cb 100644 --- a/mv_face/face/CMakeLists.txt +++ b/mv_face/face/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 2.6) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG _DEBUG) -if(NOT SKIP_WARNINGS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror") -endif() - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) diff --git a/mv_face/face/src/mv_face.c b/mv_face/face/src/mv_face.c index a8d2827..a92e387 100644 --- a/mv_face/face/src/mv_face.c +++ b/mv_face/face/src/mv_face.c @@ -36,71 +36,60 @@ static int check_source_roi_quadrangle(mv_quadrangle_s *roi, mv_source_h source) { - int ret = MEDIA_VISION_ERROR_NONE; - - if (roi) { - int src_w = 0; - int src_h = 0; - - ret = mv_source_get_width(source, &src_w); - if (ret != MEDIA_VISION_ERROR_NONE) { - LOGE("mv_source_get_width fail"); - return ret; - } - - ret = mv_source_get_height(source, &src_h); - if (ret != MEDIA_VISION_ERROR_NONE) { - LOGE("mv_source_get_height fail"); - return ret; - } - - int idx = 0; - while (idx < 4) { - if (roi->points[idx].x < 0 || roi->points[idx].y < 0 || - roi->points[idx].x > src_w || roi->points[idx].y > src_h) { - LOGE("roi is out of area on source"); - return MEDIA_VISION_ERROR_INVALID_PARAMETER; - } - ++idx; + int ret; + unsigned int src_w, src_h; + if (roi == NULL) { + LOGE("roi is null"); + return MEDIA_VISION_ERROR_INVALID_PARAMETER; + } + ret = mv_source_get_width(source, &src_w); + if (ret != MEDIA_VISION_ERROR_NONE) { + LOGE("mv_source_get_width fail"); + return ret; + } + ret = mv_source_get_height(source, &src_h); + if (ret != MEDIA_VISION_ERROR_NONE) { + LOGE("mv_source_get_height fail"); + return ret; + } + for (int idx = 0; idx < 4; idx++) { + if (roi->points[idx].x < 0 || roi->points[idx].y < 0 || + roi->points[idx].x > src_w || roi->points[idx].y > src_h) { + LOGE("roi is out of area on source"); + return MEDIA_VISION_ERROR_INVALID_PARAMETER; } } - return ret; } -static int check_source_roi(mv_rectangle_s *roi, mv_source_h source) +static int check_source_roi(const mv_rectangle_s *roi, mv_source_h source) { - int ret = MEDIA_VISION_ERROR_NONE; - - if (roi) { - int src_w = 0; - int src_h = 0; - - ret = mv_source_get_width(source, &src_w); - if (ret != MEDIA_VISION_ERROR_NONE) { - LOGE("mv_source_get_width fail"); - return ret; - } - - ret = mv_source_get_height(source, &src_h); - if (ret != MEDIA_VISION_ERROR_NONE) { - LOGE("mv_source_get_height fail"); - return ret; - } - - if (roi->width <= 0 || roi->height <= 0) { - LOGE("roi has negative width or height"); - return MEDIA_VISION_ERROR_INVALID_PARAMETER; - } - - if (roi->point.x < 0 || roi->point.y < 0 || - (roi->point.x + roi->width) > src_w || - (roi->point.y + roi->height) > src_h) { - LOGE("roi is out of area on source"); - return MEDIA_VISION_ERROR_INVALID_PARAMETER; - } + int ret; + unsigned int src_w, src_h; + if (roi == NULL) { + LOGE("roi is null"); + return MEDIA_VISION_ERROR_INVALID_PARAMETER; + } + if (roi->width <= 0 || roi->height <= 0) { + LOGE("roi width, height must be positive value"); + return MEDIA_VISION_ERROR_INVALID_PARAMETER; + } + ret = mv_source_get_width(source, &src_w); + if (ret != MEDIA_VISION_ERROR_NONE) { + LOGE("mv_source_get_width fail"); + return ret; + } + ret = mv_source_get_height(source, &src_h); + if (ret != MEDIA_VISION_ERROR_NONE) { + LOGE("mv_source_get_height fail"); + return ret; + } + if (roi->point.x < 0 || roi->point.y < 0 || + (roi->point.x + roi->width) > src_w || + (roi->point.y + roi->height) > src_h) { + LOGE("roi is out of area on source"); + return MEDIA_VISION_ERROR_INVALID_PARAMETER; } - return ret; } @@ -149,7 +138,7 @@ int mv_face_recognize( int ret = check_source_roi(face_location, source); if (MEDIA_VISION_ERROR_NONE != ret) { - LOGE("Errors occured when check source and ROI"); + LOGE("Errors occurred when check source and ROI"); return ret; } @@ -460,7 +449,7 @@ int mv_face_recognition_model_add( int ret = check_source_roi(example_location, source); if (MEDIA_VISION_ERROR_NONE != ret) { - LOGE("Errors occured when check source and ROI"); + LOGE("Errors occurred when check source and ROI"); return ret; } @@ -629,7 +618,7 @@ int mv_face_tracking_model_prepare( int ret = check_source_roi_quadrangle(location, source); if (MEDIA_VISION_ERROR_NONE != ret) { - LOGE("Errors occured when check source and tracking start location"); + LOGE("Errors occurred when check source and tracking start location"); return ret; } diff --git a/mv_image/image/CMakeLists.txt b/mv_image/image/CMakeLists.txt index acdb240..ae09259 100644 --- a/mv_image/image/CMakeLists.txt +++ b/mv_image/image/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 2.6) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG _DEBUG) -if(NOT SKIP_WARNINGS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror") -endif() - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) diff --git a/mv_inference/inference/CMakeLists.txt b/mv_inference/inference/CMakeLists.txt index 362bc9f..c7f4903 100644 --- a/mv_inference/inference/CMakeLists.txt +++ b/mv_inference/inference/CMakeLists.txt @@ -3,10 +3,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) SET_PROPERTY(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG _DEBUG) -if(NOT SKIP_WARNINGS) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -std=c++11") -endif() - SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR}) SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR}) SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) diff --git a/mv_surveillance/surveillance/src/mv_mask_buffer.c b/mv_surveillance/surveillance/src/mv_mask_buffer.c index af06e61..bef8bd0 100644 --- a/mv_surveillance/surveillance/src/mv_mask_buffer.c +++ b/mv_surveillance/surveillance/src/mv_mask_buffer.c @@ -20,6 +20,7 @@ #include "mv_private.h" #include +#include int mv_get_mask_buffer( unsigned int buffer_width, diff --git a/mv_surveillance/surveillance/src/mv_surveillance.c b/mv_surveillance/surveillance/src/mv_surveillance.c index 48ebc82..7557171 100644 --- a/mv_surveillance/surveillance/src/mv_surveillance.c +++ b/mv_surveillance/surveillance/src/mv_surveillance.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include "mv_surveillance.h" #include "mv_surveillance_private.h" @@ -118,7 +119,7 @@ int mv_surveillance_set_event_trigger_roi( MEDIA_VISION_FUNCTION_ENTER(); if (number_of_points <= 0) { - LOGE("number of points shoulde be larger than zero"); + LOGE("number of points should be larger than zero"); return MEDIA_VISION_ERROR_INVALID_PARAMETER; } diff --git a/test/testsuites/barcode/CMakeLists.txt b/test/testsuites/barcode/CMakeLists.txt index 12abcb2..114c354 100644 --- a/test/testsuites/barcode/CMakeLists.txt +++ b/test/testsuites/barcode/CMakeLists.txt @@ -5,10 +5,6 @@ PROJECT(${fw_name}) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG _DEBUG) -if(NOT SKIP_WARNINGS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror") -endif() - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) diff --git a/test/testsuites/barcode/barcode_test_suite.c b/test/testsuites/barcode/barcode_test_suite.c index e46f245..381944c 100644 --- a/test/testsuites/barcode/barcode_test_suite.c +++ b/test/testsuites/barcode/barcode_test_suite.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -282,7 +283,7 @@ bool _mv_engine_config_supported_attribute(mv_config_attribute_type_e attribute_ attribute_name); return false; } - mvprintw(current_y++, MINX, "Default interget attribute %s was set to %d in engine", + mvprintw(current_y++, MINX, "Default integer attribute %s was set to %d in engine", attribute_name, int_value); break; case MV_ENGINE_CONFIG_ATTR_TYPE_BOOLEAN: @@ -300,7 +301,7 @@ bool _mv_engine_config_supported_attribute(mv_config_attribute_type_e attribute_ if (MEDIA_VISION_ERROR_KEY_NOT_AVAILABLE == mv_engine_config_get_string_attribute( mv_engine_config, attribute_name, &str_value)) { - mvprintw(current_y++, MINX, "Default string ttribute %s wasn't set in engine", + mvprintw(current_y++, MINX, "Default string attribute %s wasn't set in engine", attribute_name); return false; } @@ -562,7 +563,7 @@ int generate_barcode_to_source(barcode_model_s model) MV_BARCODE_GENERATE_ATTR_COLOR_FRONT, model.front_color); if (MEDIA_VISION_ERROR_NONE != err) { - mvprintw(current_y++, MINX, "ERROR : Errors were occured during set string attribute to " + mvprintw(current_y++, MINX, "ERROR : Errors were occurred during set string attribute to " "media engine config : %i", err); goto clean_all; } @@ -571,7 +572,7 @@ int generate_barcode_to_source(barcode_model_s model) MV_BARCODE_GENERATE_ATTR_COLOR_BACK, model.back_color); if (MEDIA_VISION_ERROR_NONE != err) { - mvprintw(current_y++, MINX, "ERROR : Errors were occured during set string attribute to " + mvprintw(current_y++, MINX, "ERROR : Errors were occurred during set string attribute to " "media engine config : %i", err); goto clean_all; } @@ -627,27 +628,22 @@ int generate_barcode_to_source(barcode_model_s model) const image_data_s image_data = { image_width, image_height, image_colorspace }; - char *jpeg_file_name = ""; + char *jpeg_file_name; if (0 == strcmp(model.file_name + strlen(model.file_name) - 4, ".jpg") || 0 == strcmp(model.file_name + strlen(model.file_name) - 5, ".jpeg")) { - jpeg_file_name = (char*)malloc(strlen(model.file_name) + 1); + jpeg_file_name = strdup(model.file_name); if (jpeg_file_name == NULL) { err = MEDIA_VISION_ERROR_OUT_OF_MEMORY; goto clean_all; } - - strncpy(jpeg_file_name, model.file_name, strlen(model.file_name) + 1); - jpeg_file_name[strlen(model.file_name)] = '\0'; } else { jpeg_file_name = (char*)malloc(strlen(model.file_name) + 5); if (jpeg_file_name == NULL) { err = MEDIA_VISION_ERROR_OUT_OF_MEMORY; goto clean_all; } - - strncpy(jpeg_file_name, model.file_name, strlen(model.file_name) + 5); - strncpy(jpeg_file_name + strlen(model.file_name), ".jpg", 5); - jpeg_file_name[strlen(model.file_name) + 4] = '\0'; + strcpy(jpeg_file_name, model.file_name); + strcat(jpeg_file_name, ".jpg"); } err = save_image_from_buffer(jpeg_file_name, data_buffer, &image_data, 100); if (MEDIA_VISION_ERROR_NONE != err) { diff --git a/test/testsuites/common/image_helper/CMakeLists.txt b/test/testsuites/common/image_helper/CMakeLists.txt index 523bef7..25fd25f 100644 --- a/test/testsuites/common/image_helper/CMakeLists.txt +++ b/test/testsuites/common/image_helper/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 2.6) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG _DEBUG) -if(NOT SKIP_WARNINGS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror") -endif() - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) diff --git a/test/testsuites/common/testsuite_common/CMakeLists.txt b/test/testsuites/common/testsuite_common/CMakeLists.txt index b111347..193e634 100644 --- a/test/testsuites/common/testsuite_common/CMakeLists.txt +++ b/test/testsuites/common/testsuite_common/CMakeLists.txt @@ -8,9 +8,6 @@ INCLUDE_DIRECTORIES(${INC_DIR}) include_directories(${INC_IMAGE_HELPER}) include_directories(${INC_VIDEO_HELPER}) -SET(CMAKE_C_FLAGS "-I./include -I./include/headers ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall") -SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") - ADD_LIBRARY(${pkgname} SHARED "mv_testsuite_common.c" "mv_testsuite_common.h") TARGET_LINK_LIBRARIES(${pkgname} ${MV_COMMON_LIB_NAME} mv_image_helper) diff --git a/test/testsuites/common/testsuite_common/mv_testsuite_common.c b/test/testsuites/common/testsuite_common/mv_testsuite_common.c index c5fb3fc..d368ef8 100644 --- a/test/testsuites/common/testsuite_common/mv_testsuite_common.c +++ b/test/testsuites/common/testsuite_common/mv_testsuite_common.c @@ -21,6 +21,7 @@ #include #include +#include void print_fail_result( const char *action_name, @@ -81,23 +82,22 @@ int input_string(const char *prompt, size_t max_len, char **string) if (scanf("\n") != 0) return -1; - + if (max_len > 1024) { + printf("max_len is too large"); + return -1; + } char buffer[max_len]; - int last_char = 0; - buffer[last_char] = '\0'; - buffer[sizeof(buffer) - 1] = ~'\0'; if (NULL == fgets(buffer, sizeof(buffer), stdin)) return -1; - size_t real_string_len = strlen(buffer); - buffer[real_string_len - 1] = '\0'; - *string = (char*)malloc(real_string_len * sizeof(char)); + if (buffer[real_string_len - 1] == '\n') { //fgets read newline to buffer + buffer[real_string_len - 1] = '\0'; + real_string_len--; + } + *string = strdup(buffer); if (*string == NULL) return -1; - - strncpy(*string, buffer, real_string_len); - - return strlen(*string); + return real_string_len; } int input_size(const char *prompt, size_t max_size, size_t *size) @@ -113,8 +113,6 @@ int input_size(const char *prompt, size_t max_size, size_t *size) printf("ERROR: Incorrect input.\n"); return -1; } - scanf("%*[^\n]%*c"); - return (*size > max_size ? -1 : 0); } @@ -131,8 +129,6 @@ int input_int(const char *prompt, int min_value, int max_value, int *value) printf("ERROR: Incorrect input.\n"); return -1; } - scanf("%*[^\n]%*c"); - return (*value < min_value || *value > max_value ? -1 : 0); } @@ -153,8 +149,6 @@ int input_double( printf("ERROR: Incorrect input.\n"); return -1; } - scanf("%*[^\n]%*c"); - return (*value < min_value || *value > max_value ? -1 : 0); } @@ -240,8 +234,6 @@ int show_menu( printf("ERROR: Incorrect input.\n"); return -1; } - scanf("%*[^\n]%*c"); - return selection; } diff --git a/test/testsuites/common/video_helper/mv_video_helper.c b/test/testsuites/common/video_helper/mv_video_helper.c index 6771948..2eb7448 100644 --- a/test/testsuites/common/video_helper/mv_video_helper.c +++ b/test/testsuites/common/video_helper/mv_video_helper.c @@ -205,34 +205,32 @@ int mv_video_reader_load( image_data->image_width = info.width; image_data->image_height = info.height; - /* Look to : - * http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/gst-plugins-base-libs-gstvideo.html#GstVideoFormat */ switch (GST_VIDEO_FORMAT_INFO_FORMAT(info.finfo)) { - case(GST_VIDEO_FORMAT_GRAY8): + case GST_VIDEO_FORMAT_GRAY8: image_data->image_colorspace = MEDIA_VISION_COLORSPACE_Y800; break; - case(GST_VIDEO_FORMAT_I420): + case GST_VIDEO_FORMAT_I420: image_data->image_colorspace = MEDIA_VISION_COLORSPACE_I420; break; - case(GST_VIDEO_FORMAT_NV12): + case GST_VIDEO_FORMAT_NV12: image_data->image_colorspace = MEDIA_VISION_COLORSPACE_NV12; break; - case(GST_VIDEO_FORMAT_YV12): + case GST_VIDEO_FORMAT_YV12: image_data->image_colorspace = MEDIA_VISION_COLORSPACE_YV12; break; - case(GST_VIDEO_FORMAT_NV21): + case GST_VIDEO_FORMAT_NV21: image_data->image_colorspace = MEDIA_VISION_COLORSPACE_NV21; break; - case(GST_VIDEO_FORMAT_YUY2): + case GST_VIDEO_FORMAT_YUY2: image_data->image_colorspace = MEDIA_VISION_COLORSPACE_YUYV; break; - case(GST_VIDEO_FORMAT_UYVY): + case GST_VIDEO_FORMAT_UYVY: image_data->image_colorspace = MEDIA_VISION_COLORSPACE_UYVY; break; - case(GST_VIDEO_FORMAT_RGB): + case GST_VIDEO_FORMAT_RGB: image_data->image_colorspace = MEDIA_VISION_COLORSPACE_RGB888; break; - case(GST_VIDEO_FORMAT_RGBA): + case GST_VIDEO_FORMAT_RGBA: image_data->image_colorspace = MEDIA_VISION_COLORSPACE_RGBA; break; default: @@ -629,36 +627,36 @@ static int _mv_video_writer_link_internals( { GstVideoInfo vinfo; GstCaps *caps = NULL; - char format[6] = {0}; + const char *format = NULL; /* Convert from mv_colorspace to GstVideoFormat */ switch (writer->image_data.image_colorspace) { - case(MEDIA_VISION_COLORSPACE_Y800): - strncpy(format, "GRAY8", 5); + case MEDIA_VISION_COLORSPACE_Y800: + format = "GRAY8"; break; - case(MEDIA_VISION_COLORSPACE_I420): - strncpy(format, "I420", 4); + case MEDIA_VISION_COLORSPACE_I420: + format = "I420"; break; - case(MEDIA_VISION_COLORSPACE_NV12): - strncpy(format, "NV12", 4); + case MEDIA_VISION_COLORSPACE_NV12: + format = "NV12"; break; - case(MEDIA_VISION_COLORSPACE_YV12): - strncpy(format, "YV12", 4); + case MEDIA_VISION_COLORSPACE_YV12: + format = "YV12"; break; - case(MEDIA_VISION_COLORSPACE_NV21): - strncpy(format, "NV21", 4); + case MEDIA_VISION_COLORSPACE_NV21: + format = "NV21"; break; - case(MEDIA_VISION_COLORSPACE_YUYV): - strncpy(format, "YUY2", 4); + case MEDIA_VISION_COLORSPACE_YUYV: + format = "YUY2"; break; - case(MEDIA_VISION_COLORSPACE_UYVY): - strncpy(format, "UYVY", 4); + case MEDIA_VISION_COLORSPACE_UYVY: + format = "UYVY"; break; - case(MEDIA_VISION_COLORSPACE_RGB888): - strncpy(format, "RGB", 3); + case MEDIA_VISION_COLORSPACE_RGB888: + format = "RGB"; break; - case(MEDIA_VISION_COLORSPACE_RGBA): - strncpy(format, "RGBA", 4); + case MEDIA_VISION_COLORSPACE_RGBA: + format = "RGBA"; break; default: LOGE("Selected format %d is not supported", @@ -732,7 +730,6 @@ static int _mv_video_writer_state_change( { mv_video_writer_s *handle = (mv_video_writer_s *) writer; GstStateChangeReturn state_ret = GST_STATE_CHANGE_FAILURE; - GstState pipeline_state = GST_STATE_NULL; state_ret = gst_element_set_state(handle->pl, state); @@ -771,7 +768,6 @@ static GstFlowReturn appsink_newsample( GstCaps *caps = gst_sample_get_caps(sample); image_data_s im_data; char *buffer = NULL; - unsigned int buffer_size = 0; LOGD("Received sample from appsink"); @@ -784,34 +780,32 @@ static GstFlowReturn appsink_newsample( im_data.image_width = vinfo.width; im_data.image_height = vinfo.height; - /* Look to : - * http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/gst-plugins-base-libs-gstvideo.html#GstVideoFormat */ switch (GST_VIDEO_FORMAT_INFO_FORMAT(vinfo.finfo)) { - case(GST_VIDEO_FORMAT_GRAY8): + case GST_VIDEO_FORMAT_GRAY8: im_data.image_colorspace = MEDIA_VISION_COLORSPACE_Y800; break; - case(GST_VIDEO_FORMAT_I420): + case GST_VIDEO_FORMAT_I420: im_data.image_colorspace = MEDIA_VISION_COLORSPACE_I420; break; - case(GST_VIDEO_FORMAT_NV12): + case GST_VIDEO_FORMAT_NV12: im_data.image_colorspace = MEDIA_VISION_COLORSPACE_NV12; break; - case(GST_VIDEO_FORMAT_YV12): + case GST_VIDEO_FORMAT_YV12: im_data.image_colorspace = MEDIA_VISION_COLORSPACE_YV12; break; - case(GST_VIDEO_FORMAT_NV21): + case GST_VIDEO_FORMAT_NV21: im_data.image_colorspace = MEDIA_VISION_COLORSPACE_NV21; break; - case(GST_VIDEO_FORMAT_YUY2): + case GST_VIDEO_FORMAT_YUY2: im_data.image_colorspace = MEDIA_VISION_COLORSPACE_YUYV; break; - case(GST_VIDEO_FORMAT_UYVY): + case GST_VIDEO_FORMAT_UYVY: im_data.image_colorspace = MEDIA_VISION_COLORSPACE_UYVY; break; - case(GST_VIDEO_FORMAT_RGB): + case GST_VIDEO_FORMAT_RGB: im_data.image_colorspace = MEDIA_VISION_COLORSPACE_RGB888; break; - case(GST_VIDEO_FORMAT_RGBA): + case GST_VIDEO_FORMAT_RGBA: im_data.image_colorspace = MEDIA_VISION_COLORSPACE_RGBA; break; default: diff --git a/test/testsuites/face/CMakeLists.txt b/test/testsuites/face/CMakeLists.txt index d5aea7c..f083a52 100644 --- a/test/testsuites/face/CMakeLists.txt +++ b/test/testsuites/face/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 2.6) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG _DEBUG) -if(NOT SKIP_WARNINGS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror") -endif() - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) diff --git a/test/testsuites/face/face_test_suite.c b/test/testsuites/face/face_test_suite.c index a94737e..4dbf387 100644 --- a/test/testsuites/face/face_test_suite.c +++ b/test/testsuites/face/face_test_suite.c @@ -78,6 +78,8 @@ void face_expression_cb( case MV_FACE_UNKNOWN: printf("Face expression isn't recognized"); break; + default: + printf("Face expression number %u called", facial_expression); } } @@ -507,7 +509,7 @@ int perform_mv_face_recognition_model_add_face_example( "choose images with only faces. I.e. face has to cover\n" "approximately 95-100%% of the image (passport photos\n" "are the best example :)). Note that if this value is\n" - "less than 95%, accuracy can be significantly reduced.\n" + "less than 95%%, accuracy can be significantly reduced.\n" "In real code such images can be achieved by cropping\n" "faces from images with face detection functionality.\n" TEXT_RESET); @@ -743,9 +745,9 @@ int perform_mv_face_recognition_model_learn(mv_face_recognition_model_h model) int perform_mv_face_recognition_model_query_labels(mv_face_recognition_model_h model) { int *learned_labels = NULL; - int learned_labels_n = 0; + unsigned int learned_labels_n = 0; - const int err = mv_face_recognition_model_query_labels(model, &learned_labels, &learned_labels_n); + int err = mv_face_recognition_model_query_labels(model, &learned_labels, &learned_labels_n); if (MEDIA_VISION_ERROR_NONE != err) { free(learned_labels); @@ -753,10 +755,9 @@ int perform_mv_face_recognition_model_query_labels(mv_face_recognition_model_h m return err; } - int i = 0; printf(TEXT_YELLOW "Recognition model had been learned for the following labels: " TEXT_RESET "\n" TEXT_GREEN); - for (i = 0; i < learned_labels_n; ++i) + for (unsigned i = 0; i < learned_labels_n; ++i) printf("%i, ", learned_labels[i]); printf(TEXT_RESET "\n"); @@ -800,12 +801,11 @@ void evaluation_cb( int perform_model_evaluation(mv_face_recognition_model_h model) { int *learned_labels = NULL; - int learned_labels_n = 0; + unsigned learned_labels_n = 0; mv_face_recognition_model_query_labels(model, &learned_labels, &learned_labels_n); int i = 0; - printf(TEXT_YELLOW "Evaluating model had been learned for the following labels: " TEXT_RESET "\n" TEXT_GREEN); for (i = 0; i < learned_labels_n; ++i) @@ -1063,7 +1063,7 @@ int perform_recognize() err = mv_face_recognition_model_destroy(recognition_model); if (MEDIA_VISION_ERROR_NONE != err) { printf(TEXT_RED - "Error with code %i was occurred during destoy" + "Error with code %i was occurred during destroy" TEXT_RESET "\n", err); } } else { @@ -1205,7 +1205,7 @@ void face_detected_for_tracking_cb( void *user_data) { if (number_of_faces < 1) { - printf(TEXT_RED "Unfortunatly, no faces were detected on the\n" + printf(TEXT_RED "Unfortunately, no faces were detected on the\n" "preparation frame. You has to specify bounding\n" "quadrangles for tracking without advices." TEXT_RESET "\n"); @@ -1568,9 +1568,12 @@ void track_cb( } } else { char out_file_name[FILE_PATH_SIZE]; - snprintf(out_file_name, FILE_PATH_SIZE, "%s_%03d.jpg", + if(snprintf(out_file_name, FILE_PATH_SIZE, "%s_%03d.jpg", cb_data->out_file_path, - cb_data->frame_number); + cb_data->frame_number) < 0) + { + printf("Output file name truncated."); + } err = save_image_from_buffer(out_file_name, out_buffer, &image_data, 100); if (MEDIA_VISION_ERROR_NONE != err) { @@ -1815,8 +1818,6 @@ int process_image_file( if (track_target_file_name == NULL) return MEDIA_VISION_ERROR_INVALID_PARAMETER; - image_data_s image_info; - int frame_idx; int err = MEDIA_VISION_ERROR_NONE; int frames_counter = 0; diff --git a/test/testsuites/image/CMakeLists.txt b/test/testsuites/image/CMakeLists.txt index ff43730..ffdfe53 100644 --- a/test/testsuites/image/CMakeLists.txt +++ b/test/testsuites/image/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 2.6) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG _DEBUG) -if(NOT SKIP_WARNINGS) - set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror") -endif() - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) diff --git a/test/testsuites/image/image_test_suite.c b/test/testsuites/image/image_test_suite.c index f3a41cc..da2aa72 100644 --- a/test/testsuites/image/image_test_suite.c +++ b/test/testsuites/image/image_test_suite.c @@ -94,11 +94,8 @@ void testing_object_fill( "generated from \"%s\"", (char*)source); } else if (OBJECT_TYPE_IMAGE_TRACKING_MODEL == object_type) { - snprintf( - target->origin_label, - testing_object_maximum_label_length, - "generated from image object which is %s", - ((testing_object_h)source)->actual_label); + strcpy(target->origin_label, "generated from image object which is "); + strcat(target->origin_label, ((testing_object_h)source)->actual_label); } else { snprintf( target->origin_label, @@ -119,10 +116,10 @@ void testing_object_fill( strncpy(target->origin_label, source_object->origin_label, testing_object_maximum_label_length); target->cloning_counter = source_object->cloning_counter + 1; - char number_of_cloning[10]; + char number_of_cloning[20]; number_of_cloning[0] = '\0'; if (1 < target->cloning_counter) { - snprintf(number_of_cloning, 10, "%s%i%s", + snprintf(number_of_cloning, 20, "%s%i%s", "(x", target->cloning_counter, ")"); } @@ -135,10 +132,11 @@ void testing_object_fill( snprintf(type_name, 20, "unknown object"); snprintf(target->actual_label, testing_object_maximum_label_length, - "%s%s%s%s%s%s", + "%s%s%s%s%s", "cloned ", number_of_cloning, " from ", type_name, - " which is ", target->origin_label); + " which is "); + strcat(target->actual_label, target->origin_label); break; } case SOURCE_TYPE_EMPTY: { @@ -1224,7 +1222,6 @@ int perform_track_image(mv_image_tracking_model_h target) char *path_to_image = NULL; char *path_to_generated_image = NULL; - image_data_s image_data = {0}; while (input_string("Input path for tracking:", 1024, &path_to_image) == -1) { @@ -2063,8 +2060,6 @@ int main(void) "Tracking cases", "Exit" }; - mv_image_object_h current_object = NULL; - while (1) { char exit = 'n'; int sel_opt = show_menu("Select action:", options, names, 3); diff --git a/test/testsuites/inference/CMakeLists.txt b/test/testsuites/inference/CMakeLists.txt index 2862110..dcd1434 100644 --- a/test/testsuites/inference/CMakeLists.txt +++ b/test/testsuites/inference/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 2.6) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG _DEBUG) -if(NOT SKIP_WARNINGS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror") -endif() - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) diff --git a/test/testsuites/inference/inference_test_suite.c b/test/testsuites/inference/inference_test_suite.c index c2abbd5..e006c6a 100644 --- a/test/testsuites/inference/inference_test_suite.c +++ b/test/testsuites/inference/inference_test_suite.c @@ -1049,7 +1049,7 @@ int perform_image_classification() if (MEDIA_VISION_ERROR_NONE != err) { int err2 = mv_destroy_source(mvSource); if (err2 != MEDIA_VISION_ERROR_NONE) - printf("Fail to destroy mvSource.\n", err2); + printf("Fail to destroy mvSource. error code:%i\n", err2); mvSource = NULL; free(in_file_name); break; @@ -1103,7 +1103,7 @@ int perform_image_classification() int do_another = 0; if (err != MEDIA_VISION_ERROR_NONE) { - printf("ERROR: Action is finished with error code: %i\n"); + printf("ERROR: Action is finished with error code:%i\n", err); } sel_opt = 0; @@ -1536,7 +1536,7 @@ int perform_object_detection() int do_another = 0; if (err != MEDIA_VISION_ERROR_NONE) { - printf("ERROR: Action is finished with error code: %i\n"); + printf("ERROR: Action is finished with error code:%i\n", err); } sel_opt = 0; @@ -1897,7 +1897,7 @@ int perform_face_detection() if (err != MEDIA_VISION_ERROR_NONE) { int err2 = mv_destroy_source(mvSource); if (err2 != MEDIA_VISION_ERROR_NONE) - printf("Fail to destroy mvSource.\n", err2); + printf("Fail to destroy mvSource. error code:%i\n", err2); mvSource = NULL; free(in_file_name); break; @@ -1950,7 +1950,7 @@ int perform_face_detection() int do_another = 0; if (err != MEDIA_VISION_ERROR_NONE) { - printf("ERROR: Action is finished with error code: %i\n"); + printf("ERROR: Action is finished with error code:%i\n", err); } sel_opt = 0; @@ -2227,7 +2227,7 @@ int perform_facial_landmark_detection() if (err != MEDIA_VISION_ERROR_NONE) { int err2 = mv_destroy_source(mvSource); if (err2 != MEDIA_VISION_ERROR_NONE) - printf("Fail to destroy mvSource.\n", err2); + printf("Fail to destroy mvSource. error code:%i\n", err2); mvSource = NULL; free(in_file_name); break; @@ -2280,7 +2280,7 @@ int perform_facial_landmark_detection() int do_another = 0; if (err != MEDIA_VISION_ERROR_NONE) { - printf("ERROR: Action is finished with error code: %i\n"); + printf("ERROR: Action is finished with error code:%i\n", err); } sel_opt = 0; @@ -2401,7 +2401,7 @@ int perform_pose_landmark_detection() int sel_opt = 0; const int options[] = { 1, 2, 3, 4, 5 }; - const *names[] = { "Configuration", + const char *names[] = { "Configuration", "TFLITE(CPU) + CPM", "Prepare", "Run", @@ -2492,7 +2492,7 @@ int perform_pose_landmark_detection() if (err != MEDIA_VISION_ERROR_NONE) { int err2 = mv_destroy_source(mvSource); if (err2 != MEDIA_VISION_ERROR_NONE) - printf("Fail to destroy mvSource.\n", err2); + printf("Fail to destroy mvSource err: %d.\n", err2); mvSource = NULL; free(in_file_name); break; @@ -2545,7 +2545,7 @@ int perform_pose_landmark_detection() int do_another = 0; if (err != MEDIA_VISION_ERROR_NONE) { - printf("ERROR: Action is finished with error code: %i\n"); + printf("ERROR: Action is finished with error code: %i\n", err); } sel_opt = 0; diff --git a/test/testsuites/surveillance/CMakeLists.txt b/test/testsuites/surveillance/CMakeLists.txt index 74db9ed..e5d5e24 100644 --- a/test/testsuites/surveillance/CMakeLists.txt +++ b/test/testsuites/surveillance/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 2.6) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG _DEBUG) -if(NOT SKIP_WARNINGS) - set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror") -endif() - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -- 2.7.4 From eebd568722579f0ebae1c07ee278f74b1acab8d7 Mon Sep 17 00:00:00 2001 From: Kwang Son Date: Fri, 15 Jan 2021 14:41:01 +0900 Subject: [PATCH 13/16] Fix roi parameter handling roi for check_source_roi, check_source_roi_quadrangle is optional. Change-Id: If23a99f5b0b51edfa456476cadacfa875b942194 Signed-off-by: Kwang Son --- mv_face/face/src/mv_face.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mv_face/face/src/mv_face.c b/mv_face/face/src/mv_face.c index a92e387..0cad870 100644 --- a/mv_face/face/src/mv_face.c +++ b/mv_face/face/src/mv_face.c @@ -39,8 +39,8 @@ static int check_source_roi_quadrangle(mv_quadrangle_s *roi, mv_source_h source) int ret; unsigned int src_w, src_h; if (roi == NULL) { - LOGE("roi is null"); - return MEDIA_VISION_ERROR_INVALID_PARAMETER; + LOGI("roi is null, so whole source will be used."); + return MEDIA_VISION_ERROR_NONE; } ret = mv_source_get_width(source, &src_w); if (ret != MEDIA_VISION_ERROR_NONE) { @@ -67,8 +67,8 @@ static int check_source_roi(const mv_rectangle_s *roi, mv_source_h source) int ret; unsigned int src_w, src_h; if (roi == NULL) { - LOGE("roi is null"); - return MEDIA_VISION_ERROR_INVALID_PARAMETER; + LOGI("roi is null, so whole source will be used."); + return MEDIA_VISION_ERROR_NONE; } if (roi->width <= 0 || roi->height <= 0) { LOGE("roi width, height must be positive value"); -- 2.7.4 From 33f1ffe6e91151a8256bb6865efd39e06619c5d0 Mon Sep 17 00:00:00 2001 From: Kwang Son Date: Mon, 1 Feb 2021 17:43:42 +0900 Subject: [PATCH 14/16] Correct log level Change-Id: I802bd016c3c0ca20f31bd53f2552c935e8beb1ff Signed-off-by: Kwang Son --- mv_common/src/EngineConfig.cpp | 2 +- mv_inference/inference/src/Inference.cpp | 10 +++++----- mv_inference/inference/src/InferenceIni.cpp | 4 ++-- mv_inference/inference/src/Posture.cpp | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/mv_common/src/EngineConfig.cpp b/mv_common/src/EngineConfig.cpp index 566f072..686295d 100644 --- a/mv_common/src/EngineConfig.cpp +++ b/mv_common/src/EngineConfig.cpp @@ -43,7 +43,7 @@ EngineConfig::EngineConfig() DefConfigFilePath = MV_CONFIG_PATH; DefConfigFilePath += MV_ENGINE_CONFIG_FILE_NAME; - LOGE("Default Engine config file location is %s", DefConfigFilePath.c_str()); + LOGI("Default Engine config file location is %s", DefConfigFilePath.c_str()); /* Force load default attributes from configuration file */ cacheDictionaries(false); diff --git a/mv_inference/inference/src/Inference.cpp b/mv_inference/inference/src/Inference.cpp index 0c1de27..d359554 100644 --- a/mv_inference/inference/src/Inference.cpp +++ b/mv_inference/inference/src/Inference.cpp @@ -98,7 +98,7 @@ namespace inference for (int i = 0; i < MV_INFERENCE_BACKEND_MAX; ++i) { auto iter = mSupportedInferenceBackend.find(i); - LOGE("%d: %s: %s", i, (iter->second).first.c_str(), + LOGI("%d: %s: %s", i, (iter->second).first.c_str(), (iter->second).second ? "TRUE" : "FALSE"); } @@ -158,7 +158,7 @@ namespace inference void Inference::CheckSupportedInferenceBackend() { - LOGE("ENTER"); + LOGI("ENTER"); InferenceInI ini; ini.LoadInI(); @@ -166,13 +166,13 @@ namespace inference std::vector supportedBackend = ini.GetSupportedInferenceEngines(); for (std::vector::const_iterator it = supportedBackend.begin(); it != supportedBackend.end(); ++it) { - LOGE("engine: %d", *it); + LOGI("engine: %d", *it); auto iter = mSupportedInferenceBackend.find(*it); (iter->second).second = true; } - LOGE("LEAVE"); + LOGI("LEAVE"); } int Inference::ConvertEngineErrorToVisionError(int error) @@ -1062,7 +1062,7 @@ namespace inference .clone(); } - LOGE("Size: w:%u, h:%u", cvSource.size().width, cvSource.size().height); + LOGI("Size: w:%u, h:%u", cvSource.size().width, cvSource.size().height); if (mCh != 1 && mCh != 3) { LOGE("Channel not supported."); diff --git a/mv_inference/inference/src/InferenceIni.cpp b/mv_inference/inference/src/InferenceIni.cpp index a258cd8..7dc5fa5 100644 --- a/mv_inference/inference/src/InferenceIni.cpp +++ b/mv_inference/inference/src/InferenceIni.cpp @@ -61,7 +61,7 @@ namespace inference int InferenceInI::LoadInI() { - LOGE("ENTER"); + LOGI("ENTER"); dictionary *dict = iniparser_load(mIniDefaultPath.c_str()); if (dict == NULL) { LOGE("Fail to load ini"); @@ -86,7 +86,7 @@ namespace inference dict = NULL; } - LOGE("LEAVE"); + LOGI("LEAVE"); return 0; } diff --git a/mv_inference/inference/src/Posture.cpp b/mv_inference/inference/src/Posture.cpp index cd59464..14c0cec 100644 --- a/mv_inference/inference/src/Posture.cpp +++ b/mv_inference/inference/src/Posture.cpp @@ -234,7 +234,7 @@ int Posture::setPoseFromFile(const std::string motionCaptureFilePath, const std: iter->second.y = height - iter->second.y; - LOGE("(%d, %d)", iter->second.x, iter->second.y); + LOGI("(%d, %d)", iter->second.x, iter->second.y); } ret = getParts((MV_INFERENCE_HUMAN_BODY_PART_HEAD | -- 2.7.4 From 9ca55b70fa931757e18852e425809a1e088af841 Mon Sep 17 00:00:00 2001 From: Kwang Son Date: Fri, 15 Jan 2021 10:37:12 +0900 Subject: [PATCH 15/16] Barcode: Add internal unit test case (libcheck) Mediavision has interactive-based test under test directory but this patch introduce unit test. Change-Id: Ida43b9e90bab01ddad2e83e969a2751eedea2113 Signed-off-by: Kwang Son --- .gitignore | 1 + packaging/capi-media-vision.spec | 6 +- script/build.sh | 100 +++++++++++++++++++++++++++++++++ test/testsuites/barcode/CMakeLists.txt | 6 +- test/testsuites/barcode/test_barcode.c | 71 +++++++++++++++++++++++ 5 files changed, 180 insertions(+), 4 deletions(-) create mode 100755 script/build.sh create mode 100644 test/testsuites/barcode/test_barcode.c diff --git a/.gitignore b/.gitignore index 1d74e21..ad921a0 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .vscode/ +gbsbuild diff --git a/packaging/capi-media-vision.spec b/packaging/capi-media-vision.spec index 8eee284..0ff4ea8 100644 --- a/packaging/capi-media-vision.spec +++ b/packaging/capi-media-vision.spec @@ -1,7 +1,7 @@ Name: capi-media-vision Summary: Media Vision library for Tizen Native API -Version: 0.6.0 -Release: 4 +Version: 0.7.0 +Release: 0 Group: Multimedia/Framework License: Apache-2.0 and BSD-3-Clause Source0: %{name}-%{version}.tar.gz @@ -29,6 +29,7 @@ BuildRequires: pkgconfig(libtzplatform-config) BuildRequires: pkgconfig(iniparser) BuildRequires: pkgconfig(ncurses) BuildRequires: pkgconfig(inference-engine-interface-common) +BuildRequires: pkgconfig(check) Requires: %{name}-barcode Requires: %{name}-face Requires: %{name}-image @@ -168,6 +169,7 @@ Requires: %{name}-face Requires: %{name}-image Requires: %{name}-surveillance Requires: %{name}-inference +Requires: check %description testsuite Media Vision Test Suite. diff --git a/script/build.sh b/script/build.sh new file mode 100755 index 0000000..397d134 --- /dev/null +++ b/script/build.sh @@ -0,0 +1,100 @@ +#!/bin/bash -e + +SCRIPT_DIR=$(dirname $(readlink -f $0)) +BUILD_ROOT="gbsbuild" +BUILD_RPM="local/repos/tizen/armv7l/RPMS" + +cmd_usage() { + echo "Usage: $0 [command] [args]" + echo "Commands:" + echo " build Build rpm packages to $BUILD_ROOT" + echo " install [target] Install RPM packages to the target device" + echo " clean gbs build root" + echo " test_setup [target] Setup test resources to the target device" + echo " test_run [target] Run unit test on the target device" + echo " test_clean [target] Clean test resources on the target device" +} + +cmd_clean() { + echo "Clean gbsroot require sudo privilege, type" + echo "$(tput setaf 2)sudo rm -rf $PWD/$BUILD_ROOT$(tput setaf 0)" +} + +cmd_build() { + gbs build -A armv7l --include-all -B $PWD/$BUILD_ROOT +} + +check_target() { + + DEVICE_ID=$1 + device_cnt=$(sdb devices | grep -v "List" | wc -l) + + if [ $device_cnt -eq 0 ]; then + echo "No connected devices" + exit 1 + fi + + if [ $device_cnt -gt 1 ] && [ -z "$DEVICE_ID" ]; then + echo "Multiple devices are connected. Specify the device. (ex: ./build.sh install [device-id])" + sdb devices + exit 1 + fi + + SDB_OPTIONS="" + if [ -n "$DEVICE_ID" ]; then + SDB_OPTIONS="-s $DEVICE_ID" + fi + + sdb $SDB_OPTIONS root on + sdb $SDB_OPTIONS shell mount -o remount,rw / +} + +cmd_install() { + check_target $@ + + sdb $SDB_OPTIONS push $PWD/$BUILD_ROOT/$BUILD_RPM/* /root + + echo "$(tput setaf 2)Packages are copied to target /root $(tput setaf 0)" + echo "$(tput setaf 2)Install packages what you needed.$(tput setaf 0)" +} + +cmd_test_setup() { + check_target $@ + + sdb $SDB_OPTIONS shell mkdir -p /tmp/mvtest/ + + # check libcheck is installed + n_libcheck=$(sdb $SDB_OPTIONS shell ldconfig -p | grep libcheck | wc -l) + if [ $n_libcheck -eq 0 ]; then + echo "$(tput setaf 1)libcheck is not installed$(tput setaf 0)" + wget -r -nd --no-parent -A 'check-[0-9]*.armv7l.rpm' http://download.tizen.org/snapshots/tizen/unified/latest/repos/standard/packages/armv7l/ + sdb $SDB_OPTIONS push check*.rpm /root + sdb $SDB_OPTIONS shell rpm -iv check*.rpm + rm check*.rpm + fi +} + +cmd_test_run() { + check_target $@ + echo "$(tput setaf 2)Test mv_barcode_test_suite$(tput setaf 0)" + sdb $SDB_OPTIONS shell mv_barcode_test_suite +} + +cmd_test_clean() { + check_target $@ + + sdb $SDB_OPTIONS shell rm -rf /tmp/mvtest/ + sdb $SDB_OPTIONS shell rpm -e check +} + +cmd=$1 +[ $# -gt 0 ] && shift +case "$cmd" in +build | --build | -b) cmd_build ;; +install | --install | -i) cmd_install $@ ;; +clean | --clean | -c) cmd_clean ;; +test_setup | --test_setup | -ts) cmd_test_setup $@ ;; +test_run | --test_run | -tr) cmd_test_run $@ ;; +test_clean | --test_clean | -tc) cmd_test_clean $@ ;; +*) cmd_usage ;; +esac diff --git a/test/testsuites/barcode/CMakeLists.txt b/test/testsuites/barcode/CMakeLists.txt index 114c354..be8292d 100644 --- a/test/testsuites/barcode/CMakeLists.txt +++ b/test/testsuites/barcode/CMakeLists.txt @@ -23,7 +23,7 @@ ENDFOREACH(flag) FILE(GLOB MV_TEST_SUITE_INC_LIST "${PROJECT_SOURCE_DIR}/*.h") -FILE(GLOB MV_TEST_SUITE_SRC_LIST "${PROJECT_SOURCE_DIR}/*.c") +FILE(GLOB MV_TEST_SUITE_SRC_LIST "${PROJECT_SOURCE_DIR}/test_barcode.c") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE") @@ -38,7 +38,9 @@ TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${MV_BARCODE_DETECTOR_LIB_NAME} avformat avutil swscale - mv_image_helper) + mv_image_helper + check + ) INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${testbin_dir}) INSTALL(FILES mv_barcode_test_suite_auto PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ DESTINATION ${testbin_dir}) diff --git a/test/testsuites/barcode/test_barcode.c b/test/testsuites/barcode/test_barcode.c new file mode 100644 index 0000000..a34fdbd --- /dev/null +++ b/test/testsuites/barcode/test_barcode.c @@ -0,0 +1,71 @@ +#include +#include +#include +#include + +mv_engine_config_h mv_engine_config; + +void setup(void) +{ + ck_assert_int_eq(mv_create_engine_config(&mv_engine_config), + MEDIA_VISION_ERROR_NONE); +} +void teardown(void) +{ + ck_assert_int_eq(mv_destroy_engine_config(mv_engine_config), + MEDIA_VISION_ERROR_NONE); +} +START_TEST(barcode_generate_num) +{ + ck_assert_int_eq(mv_engine_config_set_string_attribute( + mv_engine_config, + MV_BARCODE_GENERATE_ATTR_COLOR_FRONT, "000000"), + MEDIA_VISION_ERROR_NONE); + ck_assert_int_eq(mv_engine_config_set_string_attribute( + mv_engine_config, + MV_BARCODE_GENERATE_ATTR_COLOR_BACK, "ffffff"), + MEDIA_VISION_ERROR_NONE); + ck_assert_int_eq(mv_barcode_generate_image( + mv_engine_config, "11234", 200, 200, MV_BARCODE_QR, + MV_BARCODE_QR_MODE_NUMERIC, MV_BARCODE_QR_ECC_HIGH, + 20, "/tmp/mvtest/gen.png", MV_BARCODE_IMAGE_FORMAT_PNG), + MEDIA_VISION_ERROR_NONE); +} +END_TEST +START_TEST(barcode_generate_utf8) +{ + ck_assert_int_eq(mv_engine_config_set_string_attribute( + mv_engine_config, + MV_BARCODE_GENERATE_ATTR_COLOR_FRONT, "000000"), + MEDIA_VISION_ERROR_NONE); + ck_assert_int_eq(mv_engine_config_set_string_attribute( + mv_engine_config, + MV_BARCODE_GENERATE_ATTR_COLOR_BACK, "ffffff"), + MEDIA_VISION_ERROR_NONE); + ck_assert_int_eq(mv_barcode_generate_image( + mv_engine_config, "qr_test1", 200, 200, + MV_BARCODE_QR, MV_BARCODE_QR_MODE_UTF8, + MV_BARCODE_QR_ECC_HIGH, 20, "/tmp/mvtest/gen2.png", + MV_BARCODE_IMAGE_FORMAT_PNG), + MEDIA_VISION_ERROR_NONE); +} +END_TEST +Suite *barcode_suite(void) +{ + Suite *s = suite_create("Barcode"); + TCase *tc_core = tcase_create("Core"); + tcase_add_checked_fixture(tc_core, setup, teardown); + tcase_add_test(tc_core, barcode_generate_num); + tcase_add_test(tc_core, barcode_generate_utf8); + suite_add_tcase(s, tc_core); + return s; +} +int main() +{ + Suite *s = barcode_suite(); + SRunner *sr = srunner_create(s); + srunner_run_all(sr, CK_NORMAL); + int number_failed = srunner_ntests_failed(sr); + srunner_free(sr); + return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; +} \ No newline at end of file -- 2.7.4 From fb92c37124c9c14d445207bee864ed1022467071 Mon Sep 17 00:00:00 2001 From: Kwang Son Date: Wed, 10 Feb 2021 11:02:58 +0900 Subject: [PATCH 16/16] Add test resource download instruction Change-Id: Ib16d40e224508a4b1f5385fba34cdace556e8a17 Signed-off-by: Kwang Son --- script/build.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/script/build.sh b/script/build.sh index 397d134..79d9c14 100755 --- a/script/build.sh +++ b/script/build.sh @@ -63,6 +63,14 @@ cmd_test_setup() { sdb $SDB_OPTIONS shell mkdir -p /tmp/mvtest/ + # check [test/tct/native/api.git] /src/utc/capi-media-vision/res/ is on target + res_exist=$(sdb $SDB_OPTIONS shell '[ -d "/tmp/mvtest/res" ] && echo 1') + if [ -z $res_exist ]; then + echo 'download https://review.tizen.org/gerrit/gitweb?p=test/tct/native/api.git;a=snapshot;h=1c301c79f082ac7a43f7f0791bbac609b1c34eb3;sf=tgz' + echo 'and copy to /tmp/mvtest/res on target' + sdb $SDB_OPTIONS shell mkdir -p /tmp/mvtest/res + fi + # check libcheck is installed n_libcheck=$(sdb $SDB_OPTIONS shell ldconfig -p | grep libcheck | wc -l) if [ $n_libcheck -eq 0 ]; then -- 2.7.4