From: Seungbae Shin Date: Fri, 6 May 2022 05:13:28 +0000 (+0900) Subject: Fix SVACE defects X-Git-Tag: submit/tizen/20220720.053259~41 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=96173f16d5e0c20912b8230106de095af10d0422;p=platform%2Fcore%2Fapi%2Fmediavision.git Fix SVACE defects [Version] 0.19.3-0 [Issue type] Svace - SIGNED_TO_BIGGER_UNSIGNED - INTEGER_OVERFLOW Change-Id: I0bbc17a0a789071b226a1d3d843fdb540bf4686a --- diff --git a/mv_image/image/include/ImageConfig.h b/mv_image/image/include/ImageConfig.h index 5b037a4e..a29806b4 100644 --- a/mv_image/image/include/ImageConfig.h +++ b/mv_image/image/include/ImageConfig.h @@ -118,7 +118,7 @@ struct RecognitionParams { struct StabilizationParams { StabilizationParams( bool isEnabled, - int historyAmount, + size_t historyAmount, double tolerantShift, double tolerantShiftExtra, double stabilizationSpeed, @@ -128,7 +128,7 @@ struct StabilizationParams { bool mIsEnabled; /**< Flag that specifies whether to use the stabilization. */ - int mHistoryAmount; /**< Number of previous recognition results, which + size_t mHistoryAmount; /**< Number of previous recognition results, which will influence the stabilization. */ double mTolerantShift; /**< Relative value of maximum shift per one frame, diff --git a/mv_image/image/src/ImageConfig.cpp b/mv_image/image/src/ImageConfig.cpp index d90330fc..de887d59 100644 --- a/mv_image/image/src/ImageConfig.cpp +++ b/mv_image/image/src/ImageConfig.cpp @@ -46,7 +46,7 @@ RecognitionParams::RecognitionParams() : StabilizationParams::StabilizationParams( bool isEnabled, - int historyAmount, + size_t historyAmount, double tolerantShift, double tolerantShiftExtra, double stabilizationSpeed, diff --git a/mv_image/image/src/Tracking/ImageContourStabilizator.cpp b/mv_image/image/src/Tracking/ImageContourStabilizator.cpp index cb1ad3ae..87a6c201 100644 --- a/mv_image/image/src/Tracking/ImageContourStabilizator.cpp +++ b/mv_image/image/src/Tracking/ImageContourStabilizator.cpp @@ -151,8 +151,8 @@ bool ImageContourStabilizator::updateSettings(const StabilizationParams& params) __tolerantShift = (float)params.mTolerantShift; __tolerantShiftExtra = (float)params.mTolerantShiftExtra; - if (__historyAmount != (size_t)params.mHistoryAmount) { - __historyAmount = (size_t)params.mHistoryAmount; + if (__historyAmount != params.mHistoryAmount) { + __historyAmount = params.mHistoryAmount; __priorities.resize(__historyAmount); @@ -164,16 +164,16 @@ bool ImageContourStabilizator::updateSettings(const StabilizationParams& params) } } - while (__historyAmount > (size_t)params.mHistoryAmount) { + while (__historyAmount > params.mHistoryAmount) { __movingHistory.pop_front(); --__historyAmount; } - if ((size_t)params.mHistoryAmount > __historyAmount) { + if (params.mHistoryAmount > __historyAmount) { /* TODO: save current moving history */ __tempContourIndex = -1; - __historyAmount = (size_t)params.mHistoryAmount; + __historyAmount = params.mHistoryAmount; __movingHistory.clear(); } diff --git a/mv_image/image/src/mv_image_open.cpp b/mv_image/image/src/mv_image_open.cpp index 0b5b99d0..25d19b20 100644 --- a/mv_image/image/src/mv_image_open.cpp +++ b/mv_image/image/src/mv_image_open.cpp @@ -219,6 +219,7 @@ void extractStabilizationParams( MediaVision::Image::StabilizationParams& stabilizationParams) { mv_engine_config_h working_cfg = NULL; + int _history_amount = 0; if (NULL == engine_cfg) { mv_create_engine_config(&working_cfg); @@ -237,7 +238,11 @@ void extractStabilizationParams( mv_engine_config_get_int_attribute_c( working_cfg, MV_IMAGE_TRACKING_HISTORY_AMOUNT, - &stabilizationParams.mHistoryAmount); + &_history_amount); + stabilizationParams.mHistoryAmount = + static_cast( + static_cast(_history_amount) + ); mv_engine_config_get_double_attribute_c( working_cfg, diff --git a/mv_machine_learning/face_recognition/src/face_recognition.cpp b/mv_machine_learning/face_recognition/src/face_recognition.cpp index c1d86b1b..d225cc58 100644 --- a/mv_machine_learning/face_recognition/src/face_recognition.cpp +++ b/mv_machine_learning/face_recognition/src/face_recognition.cpp @@ -440,7 +440,7 @@ int FaceRecognition::DeleteLabel(string label_name) // Get label count after removing a given label from the label file. _label_manager->RemoveLabel(label_name); - int label_cnt = _label_manager->GetMaxLabel(); + auto label_cnt = _label_manager->GetMaxLabel(); auto fvm = CreateFVM(_config.training_engine_backend_type, _config.feature_vector_file_path); auto fvm_new = CreateFVM(_config.training_engine_backend_type, _config.feature_vector_file_path + ".new"); diff --git a/mv_machine_learning/face_recognition/src/nntrainer_dsm.cpp b/mv_machine_learning/face_recognition/src/nntrainer_dsm.cpp index 381e5ffc..d6863120 100644 --- a/mv_machine_learning/face_recognition/src/nntrainer_dsm.cpp +++ b/mv_machine_learning/face_recognition/src/nntrainer_dsm.cpp @@ -50,7 +50,7 @@ void NNTrainerDSM::LoadDataSet(const string file_name) // Feature vector file header is written at the end of the data file // So read feature vector header from the end of the file. - openFile.seekg(static_cast(sizeof(FeaVecHeader) * -1), ios::end); + openFile.seekg(static_cast(sizeof(FeaVecHeader)) * -1, ios::end); FeaVecHeader fvh; diff --git a/mv_machine_learning/training/include/label_manager.h b/mv_machine_learning/training/include/label_manager.h index 0ef4d6a2..082655d0 100644 --- a/mv_machine_learning/training/include/label_manager.h +++ b/mv_machine_learning/training/include/label_manager.h @@ -47,8 +47,8 @@ public: unsigned int AddLabelToFile(std::string given_label); int ImportLabel(void); bool AddLabelToMap(const std::string given_label, const std::string image_file); - int GetMaxLabel(const std::string label_file); - int GetMaxLabel(); + size_t GetMaxLabel(const std::string label_file); + size_t GetMaxLabel(); std::string GetLabelFromAnswer(const std::vector& result); }; diff --git a/mv_machine_learning/training/src/label_manager.cpp b/mv_machine_learning/training/src/label_manager.cpp index 71890146..b72b3d6a 100644 --- a/mv_machine_learning/training/src/label_manager.cpp +++ b/mv_machine_learning/training/src/label_manager.cpp @@ -231,7 +231,7 @@ bool LabelManager::AddLabelToMap(const string given_label, const string image_fi return false; } -int LabelManager::GetMaxLabel(const string label_file) +size_t LabelManager::GetMaxLabel(const string label_file) { // label count is 0 if lael file doesn't exist. @@ -242,7 +242,7 @@ int LabelManager::GetMaxLabel(const string label_file) readFile.open(label_file.c_str()); - int label_cnt = 0; + size_t label_cnt = 0; if (readFile.fail()) throw InvalidOperation("Fail to open " + label_file + " file."); @@ -257,7 +257,7 @@ int LabelManager::GetMaxLabel(const string label_file) return label_cnt; } -int LabelManager::GetMaxLabel() +size_t LabelManager::GetMaxLabel() { return GetMaxLabel(_label_file); } diff --git a/mv_surveillance/surveillance/src/EventTriggerPersonAppearance.cpp b/mv_surveillance/surveillance/src/EventTriggerPersonAppearance.cpp index 1a9077f2..aecd8697 100644 --- a/mv_surveillance/surveillance/src/EventTriggerPersonAppearance.cpp +++ b/mv_surveillance/surveillance/src/EventTriggerPersonAppearance.cpp @@ -434,7 +434,11 @@ std::vector EventTriggerPersonAppearance::reinforceTrackedPersons( bool haveRes = false; for (size_t apIdx = 0u; apIdx < hogRectsSize; ++apIdx) { intersectionAreas[trIdx][apIdx] = - (appearedPersons[apIdx] & trackRectIter->rect).area(); + static_cast( + static_cast( + (appearedPersons[apIdx] & trackRectIter->rect).area() + ) + ); if (intersectionAreas[trIdx][apIdx] > 0 && (intersectionAreas[trIdx][apIdx] > diff --git a/packaging/capi-media-vision.spec b/packaging/capi-media-vision.spec index af331a88..e4848133 100644 --- a/packaging/capi-media-vision.spec +++ b/packaging/capi-media-vision.spec @@ -1,6 +1,6 @@ Name: capi-media-vision Summary: Media Vision library for Tizen Native API -Version: 0.19.2 +Version: 0.19.3 Release: 0 Group: Multimedia/Framework License: Apache-2.0 and BSD-3-Clause