Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Multimedia.Vision / MediaVision / ImageTrackingConfiguration.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     /// Represents a configuration of <see cref="ImageTracker"/>.
23     /// </summary>
24     /// <since_tizen> 3</since_tizen>
25     public class ImageTrackingConfiguration : ImageRecognitionConfiguration
26     {
27         private const string KeyHistoryAmount = "MV_IMAGE_TRACKING_HISTORY_AMOUNT";
28         private const string KeyExpectedOffset = "MV_IMAGE_TRACKING_EXPECTED_OFFSET";
29         private const string KeyUseStabilization = "MV_IMAGE_TRACKING_USE_STABLIZATION";
30         private const string KeyStabilizationTolerantShift = "MV_IMAGE_TRACKING_STABLIZATION_TOLERANT_SHIFT";
31         private const string KeyStabilizationSpeed = "MV_IMAGE_TRACKING_STABLIZATION_SPEED";
32         private const string KeyStabilizationAcceleration = "MV_IMAGE_TRACKING_STABLIZATION_ACCELERATION";
33
34         /// <summary>
35         /// A read-only field that represents the default value of <see cref="HistoryAmount"/>.
36         /// </summary>
37         /// <since_tizen> 3</since_tizen>
38         public static readonly int DefaultHistoryAmount = 3;
39
40         /// <summary>
41         /// A read-only field that represents the default value of <see cref="ExpectedOffset"/>.
42         /// </summary>
43         /// <since_tizen> 3</since_tizen>
44         public static readonly double DefaultExpectedOffset = 0;
45
46         /// <summary>
47         /// A read-only field that represents the default value of <see cref="IsStabilizationEnabled"/>.
48         /// </summary>
49         /// <since_tizen> 3</since_tizen>
50         public static readonly bool DefaultStabilizationEnabled = true;
51
52         /// <summary>
53         /// A read-only field that represents the default value of <see cref="StabilizationTolerantShift"/>.
54         /// </summary>
55         /// <since_tizen> 3</since_tizen>
56         public static readonly double DefaultStabilizationTolerantShift = 0.00006;
57
58         /// <summary>
59         /// A read-only field that represents the default value of <see cref="StabilizationSpeed"/>.
60         /// </summary>
61         /// <since_tizen> 3</since_tizen>
62         public static readonly double DefaultStabilizationSpeed = 0.3;
63
64         /// <summary>
65         /// A read-only field that represents the default value of <see cref="StabilizationAcceleration"/>.
66         /// </summary>
67         /// <since_tizen> 3</since_tizen>
68         public static readonly double DefaultStabilizationAcceleration = 0.1;
69
70         /// <summary>
71         /// Initializes a new instance of the <see cref="ImageTrackingConfiguration"/> class.
72         /// </summary>
73         /// <exception cref="NotSupportedException">The feature is not supported.</exception>
74         /// <since_tizen> 3</since_tizen>
75         public ImageTrackingConfiguration()
76         {
77         }
78
79         /// <summary>
80         /// Gets or sets the number of recognition results in the tracking history.
81         /// </summary>
82         /// <value>
83         /// The number of previous recognition results, which will influence the stabilization.\n
84         /// The default is 3.
85         /// </value>
86         /// <exception cref="ObjectDisposedException">The <see cref="ImageTrackingConfiguration"/> already has been disposed of.</exception>
87         /// <exception cref="ArgumentOutOfRangeException"><paramref name="value"/> is less than zero.</exception>
88         /// <since_tizen> 3</since_tizen>
89         public int HistoryAmount
90         {
91             get
92             {
93                 return GetInt(KeyHistoryAmount);
94             }
95             set
96             {
97                 if (value < 0)
98                 {
99                     throw new ArgumentOutOfRangeException(nameof(HistoryAmount), value,
100                         $"{nameof(HistoryAmount)} can't be less than zero.");
101                 }
102                 Set(KeyHistoryAmount, value);
103             }
104         }
105
106         /// <summary>
107         /// Gets or sets the expected tracking offset.
108         /// </summary>
109         /// <value>
110         /// Relative offset value, for which the object offset is expected (relative to the object size in the current frame).\n
111         /// The default is 0.
112         /// </value>
113         /// <exception cref="ObjectDisposedException">The <see cref="ImageTrackingConfiguration"/> already has been disposed of.</exception>
114         /// <since_tizen> 3</since_tizen>
115         public double ExpectedOffset
116         {
117             get
118             {
119                 return GetDouble(KeyExpectedOffset);
120             }
121             set
122             {
123                 Set(KeyExpectedOffset, value);
124             }
125         }
126
127         /// <summary>
128         /// Gets or sets the acceleration of the tracking stabilization.
129         /// </summary>
130         /// <value>
131         /// Acceleration will be used for image stabilization (relative to the distance from current location to stabilized location);
132         /// from 0 to 1, inclusive.\n
133         /// The default is 0.1.
134         /// </value>
135         /// <exception cref="ObjectDisposedException">The <see cref="ImageTrackingConfiguration"/> already has been disposed of.</exception>
136         /// <exception cref="ArgumentOutOfRangeException">
137         ///     <paramref name="value"/> is less than zero.\n
138         ///     -or-\n
139         ///     <paramref name="value"/> is greater than one.
140         /// </exception>
141         /// <since_tizen> 3</since_tizen>
142         public double StabilizationAcceleration
143         {
144             get
145             {
146                 return GetDouble(KeyStabilizationAcceleration);
147             }
148             set
149             {
150                 if (value < 0 || value > 1)
151                 {
152                     throw new ArgumentOutOfRangeException(nameof(value), value, "Valid range is 0 to 1 inclusive.");
153                 }
154
155                 Set(KeyStabilizationAcceleration, value);
156             }
157         }
158
159         /// <summary>
160         /// Gets or sets the speed of the tracking stabilization.
161         /// </summary>
162         /// <value>
163         /// The start speed value used for image stabilization.\n
164         /// The default is 0.3.
165         /// </value>
166         /// <exception cref="ObjectDisposedException">The <see cref="ImageTrackingConfiguration"/> already has been disposed of.</exception>
167         /// <since_tizen> 3</since_tizen>
168         public double StabilizationSpeed
169         {
170             get
171             {
172                 return GetDouble(KeyStabilizationSpeed);
173             }
174             set
175             {
176                 Set(KeyStabilizationSpeed, value);
177             }
178         }
179
180         /// <summary>
181         /// Gets or sets the relative tolerant shift for the tracking stabilization.
182         /// </summary>
183         /// <value>
184         /// It is component of tolerant shift which will be ignored by stabilization process.
185         /// (this value is relative to the object size in the current frame).
186         /// Tolerant shift will be computed like R * S + C, where R is the value set to <see cref="StabilizationTolerantShift"/>,
187         /// S is the area of object location on frame, C is a constant value 1.3.\n
188         /// \n
189         /// The default is 0.00006.
190         /// </value>
191         /// <exception cref="ObjectDisposedException">The <see cref="ImageTrackingConfiguration"/> already has been disposed of.</exception>
192         /// <since_tizen> 3</since_tizen>
193         public double StabilizationTolerantShift
194         {
195             get
196             {
197                 return GetDouble(KeyStabilizationTolerantShift);
198             }
199             set
200             {
201                 Set(KeyStabilizationTolerantShift, value);
202             }
203         }
204
205         /// <summary>
206         /// Gets or sets the state of the contour stabilization during tracking process.
207         /// </summary>
208         /// <value>
209         /// true if the contour stabilization is enabled; otherwise, false.\n
210         /// The default is true.
211         /// </value>
212         /// <exception cref="ObjectDisposedException">The <see cref="ImageTrackingConfiguration"/> already has been disposed of.</exception>
213         /// <since_tizen> 3</since_tizen>
214         public bool IsStabilizationEnabled
215         {
216             get
217             {
218                 return GetBool(KeyUseStabilization);
219             }
220             set
221             {
222                 Set(KeyUseStabilization, value);
223             }
224         }
225     }
226 }