Fix SVACE defects
authorSeungbae Shin <seungbae.shin@samsung.com>
Fri, 6 May 2022 05:13:28 +0000 (14:13 +0900)
committerInki Dae <inki.dae@samsung.com>
Wed, 20 Jul 2022 05:16:40 +0000 (14:16 +0900)
[Version] 0.19.3-0
[Issue type] Svace

- SIGNED_TO_BIGGER_UNSIGNED
- INTEGER_OVERFLOW

Change-Id: I0bbc17a0a789071b226a1d3d843fdb540bf4686a

mv_image/image/include/ImageConfig.h
mv_image/image/src/ImageConfig.cpp
mv_image/image/src/Tracking/ImageContourStabilizator.cpp
mv_image/image/src/mv_image_open.cpp
mv_machine_learning/face_recognition/src/face_recognition.cpp
mv_machine_learning/face_recognition/src/nntrainer_dsm.cpp
mv_machine_learning/training/include/label_manager.h
mv_machine_learning/training/src/label_manager.cpp
mv_surveillance/surveillance/src/EventTriggerPersonAppearance.cpp
packaging/capi-media-vision.spec

index 5b037a4e0206d45193f69f04e5b6a24a6f5d3927..a29806b4dd15aac11ddc7b5ca68e5d3e5f39ba42 100644 (file)
@@ -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,
index d90330fc6021b64f34cfd9a1a6a3a9699341198d..de887d596f829a1112aec0c3c9e3aee6e530cf97 100644 (file)
@@ -46,7 +46,7 @@ RecognitionParams::RecognitionParams() :
 
 StabilizationParams::StabilizationParams(
                                        bool isEnabled,
-                                       int historyAmount,
+                                       size_t historyAmount,
                                        double tolerantShift,
                                        double tolerantShiftExtra,
                                        double stabilizationSpeed,
index cb1ad3ae328392271f21725e37751cc96a151320..87a6c2019f742d3676f46bde19a8556ce874f54a 100644 (file)
@@ -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();
        }
 
index 0b5b99d067ec5c40d7ab603abf0d0871018e23a3..25d19b20a55f9ff4b248afb89812323c8356a376 100644 (file)
@@ -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<size_t>(
+                       static_cast<unsigned int>(_history_amount)
+               );
 
        mv_engine_config_get_double_attribute_c(
                        working_cfg,
index c1d86b1b228f7f99f1923d439d43a5ec71d547fc..d225cc5861131416b67e7a3c25dd2b76ca04346c 100644 (file)
@@ -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");
 
index 381e5ffcf5cbb0ad6085ee23582568df0dbbb133..d686312089663894409cd1a23b2021a20150d7f9 100644 (file)
@@ -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<int>(sizeof(FeaVecHeader) * -1), ios::end);
+       openFile.seekg(static_cast<int>(sizeof(FeaVecHeader)) * -1, ios::end);
 
        FeaVecHeader fvh;
 
index 0ef4d6a2dd9c04cb5f21978dd64c5c22a6e20d97..082655d08c0be4b4a4f4da6ab70ab4e7109e6308 100644 (file)
@@ -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<float>& result);
 };
 
index 71890146bd67bb7213b97c4d2f2917ed093321f5..b72b3d6a1e44e53c341bab45fdd9df3216b2fc21 100644 (file)
@@ -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);
 }
index 1a9077f2e3232ba4cc3d089262105e2fdb98c55a..aecd86979efe95ca614d6f601f187541595de5e8 100644 (file)
@@ -434,7 +434,11 @@ std::vector<bool> EventTriggerPersonAppearance::reinforceTrackedPersons(
                        bool haveRes = false;
                        for (size_t apIdx = 0u; apIdx < hogRectsSize; ++apIdx) {
                                intersectionAreas[trIdx][apIdx] =
-                                               (appearedPersons[apIdx] & trackRectIter->rect).area();
+                                       static_cast<size_t>(
+                                               static_cast<unsigned int>(
+                                                       (appearedPersons[apIdx] & trackRectIter->rect).area()
+                                               )
+                                       );
 
                                if (intersectionAreas[trIdx][apIdx] > 0 &&
                                                (intersectionAreas[trIdx][apIdx] >
index af331a882783d6d1b7502fb6fa5b506b01eca164..e484813354150efea4ca78c3ff2a78769aaa43ee 100644 (file)
@@ -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