mv_machine_learning: use carnel notation
[platform/core/api/mediavision.git] / mv_machine_learning / training / include / label_manager.h
1 /**
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __LABEL_MANAGER_H__
18 #define __LABEL_MANAGER_H__
19
20 #include <string.h>
21 #include <iostream>
22 #include <fstream>
23 #include <istream>
24 #include <algorithm>
25 #include <vector>
26 #include <map>
27
28 #include "file_util.h"
29
30 class LabelManager
31 {
32 private:
33         std::map<std::string, std::string> _labels_and_files;
34         std::string _label_file;
35         float _decision_threshold;
36         static constexpr float _decision_weight = 0.01;
37
38 public:
39         LabelManager(std::string label_file, double decision_threshold);
40         ~LabelManager();
41         void clear();
42         float getDecisionThreshold();
43         float getDecisionWeight();
44         unsigned int getLabelIndex(const std::string given_label);
45         bool isExist(const std::string given_label);
46         unsigned int removeLabel(const std::string given_label);
47         int getLabelString(std::string &label, const int idx);
48         unsigned int addLabelToFile(std::string given_label);
49         int importLabel(void);
50         bool addLabelToMap(const std::string given_label, const std::string image_file);
51         size_t getMaxLabel(const std::string label_file);
52         size_t getMaxLabel();
53         std::string getLabelFromAnswer(const std::vector<float> &result);
54         void removeFile();
55 };
56
57 #endif