mv_machine_learning: initialize class/structure member properly
authorSeungbae Shin <seungbae.shin@samsung.com>
Fri, 27 Oct 2023 08:49:30 +0000 (17:49 +0900)
committerInki Dae <inki.dae@samsung.com>
Tue, 14 Nov 2023 07:39:33 +0000 (16:39 +0900)
[Issue type] : code cleanup

Change-Id: I3bdc0c98836ea4adf0f840ce6e3290685c1d2b6d

17 files changed:
mv_machine_learning/image_classification/include/image_classification.h
mv_machine_learning/image_classification/include/image_classification_default.h
mv_machine_learning/image_classification/include/image_classification_type.h
mv_machine_learning/image_segmentation/include/iimage_segmentation.h
mv_machine_learning/image_segmentation/include/image_segmentation.h
mv_machine_learning/image_segmentation/include/image_segmentation_external.h
mv_machine_learning/image_segmentation/include/image_segmentation_type.h
mv_machine_learning/image_segmentation/src/selfie_segmentation_adapter.cpp
mv_machine_learning/landmark_detection/src/pose_landmark_adapter.cpp
mv_machine_learning/object_detection/include/iobject_detection.h
mv_machine_learning/object_detection/include/object_detection.h
mv_machine_learning/object_detection/include/object_detection_external.h
mv_machine_learning/object_detection/include/object_detection_type.h
mv_machine_learning/object_detection/src/face_detection_adapter.cpp
mv_machine_learning/object_detection/src/object_detection_adapter.cpp
mv_machine_learning/training/include/data_set_manager.h
mv_machine_learning/training/include/training_model.h

index 9130c57..306ee51 100644 (file)
@@ -37,7 +37,7 @@ class ImageClassification
 {
 private:
        std::unique_ptr<AsyncManager<ImageClassificationResult> > _async_manager;
-       ImageClassificationResult _current_result {};
+       ImageClassificationResult _current_result;
 
        void loadLabel();
        void getEngineList();
@@ -59,8 +59,8 @@ protected:
        std::vector<std::string> _labels;
        std::vector<std::string> _valid_backends;
        std::vector<std::string> _valid_devices;
-       int _backendType;
-       int _targetDeviceType;
+       int _backendType {};
+       int _targetDeviceType {};
 
        void getOutputNames(std::vector<std::string> &names);
        void getOutpuTensor(std::string &target_name, std::vector<float> &tensor);
@@ -71,6 +71,7 @@ protected:
 public:
        ImageClassification();
        virtual ~ImageClassification() = default;
+
        void preDestroy();
        void setUserModel(std::string model_file, std::string meta_file, std::string label_file);
        void setEngineInfo(std::string engine_type, std::string device_type);
index a873d32..23e6bd5 100644 (file)
@@ -37,6 +37,7 @@ private:
 public:
        ImageClassificationDefault();
        ~ImageClassificationDefault();
+
        ImageClassificationResult &result() override;
 };
 
index 280f00c..2cee348 100644 (file)
@@ -27,7 +27,7 @@ namespace mediavision
 namespace machine_learning
 {
 struct ImageClassificationInput {
-       mv_source_h inference_src;
+       mv_source_h inference_src {};
        // TODO.
 };
 
@@ -36,7 +36,7 @@ struct ImageClassificationInput {
  * @details Contains object detection 3d result.
  */
 struct ImageClassificationResult {
-       unsigned long frame_number;
+       unsigned long frame_number {};
        std::string label;
 };
 
index 62d6c9a..1acf9df 100644 (file)
@@ -29,6 +29,7 @@ class IImageSegmentation
 {
 public:
        virtual ~IImageSegmentation() {};
+
        virtual void preDestroy() = 0;
        virtual ImageSegmentationTaskType getTaskType() = 0;
        virtual void setUserModel(std::string model_file, std::string meta_file, std::string label_file) = 0;
index 89d7bd3..ac5d14f 100644 (file)
@@ -42,7 +42,7 @@ namespace machine_learning
 class ImageSegmentation : public IImageSegmentation
 {
 private:
-       ImageSegmentationTaskType _task_type;
+       ImageSegmentationTaskType _task_type { ImageSegmentationTaskType::IMAGE_SEGMENTATION_TASK_NONE };
        std::unique_ptr<AsyncManager<ImageSegmentationResult> > _async_manager;
        ImageSegmentationResult _current_result {};
 
@@ -67,8 +67,8 @@ protected:
        std::string _modelMetaFilePath;
        std::string _modelDefaultPath;
        std::string _modelLabelFilePath;
-       int _backendType;
-       int _targetDeviceType;
+       int _backendType {};
+       int _targetDeviceType {};
 
        void getOutputNames(std::vector<std::string> &names);
        void getOutputTensor(std::string target_name, std::vector<float> &tensor);
@@ -77,8 +77,9 @@ protected:
        virtual ImageSegmentationResult &result() = 0;
 
 public:
-       ImageSegmentation(ImageSegmentationTaskType task_type);
+       explicit ImageSegmentation(ImageSegmentationTaskType task_type);
        virtual ~ImageSegmentation() = default;
+
        void preDestroy() override;
        ImageSegmentationTaskType getTaskType() override;
        void setUserModel(std::string model_file, std::string meta_file, std::string label_file) override;
index bdedf9a..08c391e 100644 (file)
@@ -33,14 +33,15 @@ namespace machine_learning
 class ImageSegmentationExternal : public IImageSegmentation
 {
 private:
-       void *_plugin_handle;
-       IImageSegmentation *_image_segmentation_plugin;
-       ImageSegmentationTaskType _task_type {};
-       ImageSegmentationResult _current_result {};
+       void *_plugin_handle {};
+       IImageSegmentation *_image_segmentation_plugin {};
+       ImageSegmentationTaskType _task_type { ImageSegmentationTaskType::IMAGE_SEGMENTATION_TASK_NONE };
+       ImageSegmentationResult _current_result;
 
 public:
-       ImageSegmentationExternal(ImageSegmentationTaskType task_type);
+       explicit ImageSegmentationExternal(ImageSegmentationTaskType task_type);
        virtual ~ImageSegmentationExternal();
+
        void preDestroy() override;
        ImageSegmentationTaskType getTaskType() override;
        void setUserModel(std::string model_file, std::string meta_file, std::string label_file) override;
index b468932..0029f64 100644 (file)
@@ -27,7 +27,7 @@ namespace mediavision
 namespace machine_learning
 {
 struct ImageSegmentationInput {
-       mv_source_h inference_src;
+       mv_source_h inference_src {};
 };
 
 /**
@@ -35,10 +35,10 @@ struct ImageSegmentationInput {
  * @details Contains object detection result.
  */
 struct ImageSegmentationResult {
-       unsigned long frame_number;
-       unsigned int width;
-       unsigned int height;
-       unsigned int pixel_size;
+       unsigned long frame_number {};
+       unsigned int width {};
+       unsigned int height {};
+       unsigned int pixel_size {};
        std::vector<unsigned char> data;
 };
 
index b02584c..f920df9 100644 (file)
@@ -70,8 +70,6 @@ ImageSegmentationTaskType ImageSegmentationAdapter<T, V>::convertToTaskType(stri
 
        transform(model_name.begin(), model_name.end(), model_name.begin(), ::toupper);
 
-       ImageSegmentationTaskType task_type = ImageSegmentationTaskType::IMAGE_SEGMENTATION_TASK_NONE;
-
        if (model_name == "SELFIE_SEGMENTATION_PLUGIN")
                return ImageSegmentationTaskType::SELFIE_SEGMENTATION_PLUGIN;
 
index 91c142d..92f361d 100644 (file)
@@ -65,8 +65,6 @@ LandmarkDetectionTaskType PoseLandmarkAdapter<T, V>::convertToTaskType(string mo
 
        transform(model_name.begin(), model_name.end(), model_name.begin(), ::toupper);
 
-       LandmarkDetectionTaskType task_type = LandmarkDetectionTaskType::LANDMARK_DETECTION_TASK_NONE;
-
        if (model_name == "PLD_CPM")
                return LandmarkDetectionTaskType::PLD_CPM;
 
@@ -159,4 +157,4 @@ template<typename T, typename V> V &PoseLandmarkAdapter<T, V>::getOutputCache()
 
 template class PoseLandmarkAdapter<LandmarkDetectionInput, LandmarkDetectionResult>;
 }
-}
\ No newline at end of file
+}
index c1c3c6b..72381a3 100644 (file)
@@ -29,6 +29,7 @@ class IObjectDetection
 {
 public:
        virtual ~IObjectDetection() {};
+
        virtual void preDestroy() = 0;
        virtual ObjectDetectionTaskType getTaskType() = 0;
        virtual void setUserModel(std::string model_file, std::string meta_file, std::string label_file) = 0;
index 93d46d0..22c0323 100644 (file)
@@ -42,9 +42,9 @@ namespace machine_learning
 class ObjectDetection : public IObjectDetection
 {
 private:
-       ObjectDetectionTaskType _task_type;
+       ObjectDetectionTaskType _task_type { ObjectDetectionTaskType::OBJECT_DETECTION_TASK_NONE };
        std::unique_ptr<AsyncManager<ObjectDetectionResult> > _async_manager;
-       ObjectDetectionResult _current_result {};
+       ObjectDetectionResult _current_result;
 
        void loadLabel();
        void getEngineList();
@@ -67,8 +67,8 @@ protected:
        std::string _modelMetaFilePath;
        std::string _modelDefaultPath;
        std::string _modelLabelFilePath;
-       int _backendType;
-       int _targetDeviceType;
+       int _backendType {};
+       int _targetDeviceType {};
 
        void getOutputNames(std::vector<std::string> &names);
        void getOutputTensor(std::string target_name, std::vector<float> &tensor);
@@ -77,8 +77,9 @@ protected:
        virtual ObjectDetectionResult &result() = 0;
 
 public:
-       ObjectDetection(ObjectDetectionTaskType task_type);
+       explicit ObjectDetection(ObjectDetectionTaskType task_type);
        virtual ~ObjectDetection() = default;
+
        void preDestroy() override;
        ObjectDetectionTaskType getTaskType() override;
        void setUserModel(std::string model_file, std::string meta_file, std::string label_file) override;
index 9034af7..72a0b5a 100644 (file)
@@ -33,14 +33,15 @@ namespace machine_learning
 class ObjectDetectionExternal : public IObjectDetection
 {
 private:
-       void *_plugin_handle;
-       IObjectDetection *_object_detection_plugin;
-       ObjectDetectionTaskType _task_type {};
-       ObjectDetectionResult _current_result {};
+       void *_plugin_handle {};
+       IObjectDetection *_object_detection_plugin {};
+       ObjectDetectionTaskType _task_type { ObjectDetectionTaskType::OBJECT_DETECTION_TASK_NONE };
+       ObjectDetectionResult _current_result;
 
 public:
-       ObjectDetectionExternal(ObjectDetectionTaskType task_type);
+       explicit ObjectDetectionExternal(ObjectDetectionTaskType task_type);
        virtual ~ObjectDetectionExternal();
+
        void preDestroy() override;
        ObjectDetectionTaskType getTaskType() override;
        void setUserModel(std::string model_file, std::string meta_file, std::string label_file) override;
index 2844dfd..023621b 100644 (file)
@@ -28,7 +28,7 @@ namespace mediavision
 namespace machine_learning
 {
 struct ObjectDetectionInput {
-       mv_source_h inference_src;
+       mv_source_h inference_src {};
        // TODO.
 };
 
@@ -37,7 +37,7 @@ struct ObjectDetectionInput {
  * @details Contains object detection result.
  */
 struct ObjectDetectionResult {
-       unsigned long frame_number;
+       unsigned long frame_number {};
        unsigned int number_of_objects {};
        std::vector<unsigned int> indices;
        std::vector<std::string> names;
index 1efa783..fd4d98c 100644 (file)
@@ -169,4 +169,4 @@ template<typename T, typename V> V &FaceDetectionAdapter<T, V>::getOutputCache()
 
 template class FaceDetectionAdapter<ObjectDetectionInput, ObjectDetectionResult>;
 }
-}
\ No newline at end of file
+}
index bb86362..16c4d9f 100644 (file)
@@ -75,8 +75,6 @@ ObjectDetectionTaskType ObjectDetectionAdapter<T, V>::convertToTaskType(string m
 
        transform(model_name.begin(), model_name.end(), model_name.begin(), ::toupper);
 
-       ObjectDetectionTaskType task_type = ObjectDetectionTaskType::OBJECT_DETECTION_TASK_NONE;
-
        if (model_name == "OD_PLUGIN")
                return ObjectDetectionTaskType::OD_PLUGIN;
        else if (model_name == "FD_PLUGIN")
index 19384b7..9d8c8bb 100644 (file)
@@ -30,8 +30,8 @@ protected:
        std::vector<std::vector<float> > _data;
        std::vector<std::vector<float> > _labels;
        std::vector<unsigned int> _label_index;
-       size_t _feature_vector_size;
-       size_t _label_count;
+       size_t _feature_vector_size {};
+       size_t _label_count {};
 
 public:
        DataSetManager();
index 3d2bbc6..b19d745 100644 (file)
@@ -33,8 +33,8 @@ struct TrainingEngineBackendInfo {
        std::vector<std::string> output_layer_names;
        std::vector<inference_engine_tensor_info> input_tensor_info;
        std::vector<inference_engine_tensor_info> output_tensor_info;
-       training_engine_optimizer_property optimizer_property;
-       training_engine_compile_property compile_property;
+       training_engine_optimizer_property optimizer_property {};
+       training_engine_compile_property compile_property {};
 };
 
 class TrainingModel