b5b4b6670c655b40449e085ae8cca8fa58b671fe
[platform/core/csapi/tizenfx.git] / src / Tizen.Multimedia / MediaVision / FaceEngineConfiguration.cs
1 /*
2  * Copyright (c) 2016 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 using System;
18
19 namespace Tizen.Multimedia
20 {
21     /// <summary>
22     /// This class represents concrete EngineConfig for Face detection and recognition
23     /// </summary>
24     public class FaceEngineConfiguration : EngineConfiguration
25     {
26         // List of predefined keys
27         private const string _faceDetectionModelFilePathKey = "MV_FACE_DETECTION_MODEL_FILE_PATH";
28         private const string _faceRecognitionModelTypeKey = "MV_FACE_RECOGNITION_MODEL_TYPE";
29         private const string _faceDetectionRoiXKey = "MV_FACE_DETECTION_ROI_X";
30         private const string _faceDetectionRoiYKey = "MV_FACE_DETECTION_ROI_Y";
31         private const string _faceDetectionRoiWidthKey = "MV_FACE_DETECTION_ROI_WIDTH";
32         private const string _faceDetectionRoiHeightKey = "MV_FACE_DETECTION_ROI_HEIGHT";
33         private const string _faceDetectionMinWidthKey = "MV_FACE_DETECTION_MIN_SIZE_WIDTH";
34         private const string _faceDetectionMinHeightKey = "MV_FACE_DETECTION_MIN_SIZE_HEIGHT";
35         // Values are cached below to prevent interop calls for get operation
36         private string _faceDetectionModelFilePathValue;
37         private FaceRecognitionModelType _faceRecognitionModelTypeValue = FaceRecognitionModelType.LBPH;
38         private int _faceDetectionRoiXValue = -1;
39         private int _faceDetectionRoiYValue = -1;
40         private int _faceDetectionRoiWidthValue = -1;
41         private int _faceDetectionRoiHeightValue = -1;
42         private int _faceDetectionMinWidthValue = -1;
43         private int _faceDetectionMinHeightValue = -1;
44
45         /// <summary>
46         /// The default constructor of FaceEngineConfig class
47         /// </summary>
48         /// <code>
49         /// 
50         /// </code>
51         public FaceEngineConfiguration()
52             : base()
53         {
54             ModelFilePath = _faceDetectionModelFilePathValue;
55             ModelType = _faceRecognitionModelTypeValue; ;
56             MinimumHeight = _faceDetectionMinHeightValue;
57             MinimumWidth = _faceDetectionMinWidthValue;
58             RoiHeight = _faceDetectionRoiHeightValue;
59             RoiWidth = _faceDetectionRoiWidthValue;
60             RoiX = _faceDetectionRoiXValue;
61             RoiY = _faceDetectionRoiYValue;
62         }
63
64         /// <summary>
65         /// Sets and gets face detection haarcascade xml file attribute of the engine configuration.
66         /// </summary>
67         public string ModelFilePath
68         {
69             get
70             {
71                 return _faceDetectionModelFilePathValue;
72             }
73
74             set
75             {
76                 Add<string>(_faceDetectionModelFilePathKey, value);
77                 _faceDetectionModelFilePathValue = value;
78             }
79         }
80
81         /// <summary>
82         /// Sets and gets the method used for face recognition model learning attribute of the engine configuration.
83         /// </summary>
84         public FaceRecognitionModelType ModelType
85         {
86             get
87             {
88                 return _faceRecognitionModelTypeValue;
89             }
90
91             set
92             {
93                 if (value == FaceRecognitionModelType.Unknown)
94                 {
95                     throw new ArgumentException("ModelType value is invalid");
96                 }
97
98                 Add<int>(_faceRecognitionModelTypeKey, (int)value);
99                 _faceRecognitionModelTypeValue = value;
100             }
101         }
102
103         /// <summary>
104         /// Sets and gets minimum height of face which will be detected as attribute of the engine configuration.
105         /// </summary>
106         /// <remarks>
107         /// Default value is -1 (all detected faces will be applied) can be changed to specify the minimum face height.
108         /// </remarks>
109         public int MinimumHeight
110         {
111             get
112             {
113                 return _faceDetectionMinHeightValue;
114             }
115
116             set
117             {
118                 Add<int>(_faceDetectionMinHeightKey, value);
119                 _faceDetectionMinHeightValue = value;
120             }
121         }
122
123         /// <summary>
124         /// Sets and gets minimum width of face which will be detected as attribute of the engine configuration.
125         /// </summary>
126         /// <remarks>
127         /// Default value is -1 (all detected faces will be applied) can be changed to specify the minimum face width.
128         /// </remarks>
129         public int MinimumWidth
130         {
131             get
132             {
133                 return _faceDetectionMinWidthValue;
134             }
135
136             set
137             {
138                 Add<int>(_faceDetectionMinWidthKey, value);
139                 _faceDetectionMinWidthValue = value;
140             }
141         }
142
143         /// <summary>
144         /// Sets and gets height of face detection roi as attribute of the engine configuration.
145         /// </summary>
146         /// <remarks>
147         /// Default value is -1 (the roi will be a full image) can be changed to specify the roi for face detection.
148         /// </remarks>
149         public int RoiHeight
150         {
151             get
152             {
153                 return _faceDetectionRoiHeightValue;
154             }
155
156             set
157             {
158                 Add<int>(_faceDetectionRoiHeightKey, value);
159                 _faceDetectionRoiHeightValue = value;
160             }
161         }
162
163         /// <summary>
164         /// Sets and gets width of face detection roi as attribute of the engine configuration.
165         /// </summary>
166         /// <remarks>
167         /// Default value is -1 (the roi will be a full image) can be changed to specify the roi for face detection
168         /// </remarks>
169         public int RoiWidth
170         {
171             get
172             {
173                 return _faceDetectionRoiWidthValue;
174             }
175
176             set
177             {
178                 Add<int>(_faceDetectionRoiWidthKey, value);
179                 _faceDetectionRoiWidthValue = value;
180             }
181         }
182
183         /// <summary>
184         /// Sets and gets X coordinate of face detection roi as attribute of the engine configuration.
185         /// </summary>
186         /// <remarks>
187         /// Default value is -1 (the roi will be a full image) can be changed to specify the roi for face detection
188         /// </remarks>
189         public int RoiX
190         {
191             get
192             {
193                 return _faceDetectionRoiXValue;
194             }
195
196             set
197             {
198                 Add<int>(_faceDetectionRoiXKey, value);
199                 _faceDetectionRoiXValue = value;
200             }
201         }
202
203         /// <summary>
204         /// Sets and gets Y coordinate of face detection roi as attribute of the engine configuration.
205         /// </summary>
206         /// <remarks>
207         /// Default value is -1 (the roi will be a full image) can be changed to specify the roi for face detection
208         /// </remarks>
209         public int RoiY
210         {
211             get
212             {
213                 return _faceDetectionRoiYValue;
214             }
215
216             set
217             {
218                 Add<int>(_faceDetectionRoiYKey, value);
219                 _faceDetectionRoiYValue = value;
220             }
221         }
222     }
223 }