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