2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 namespace Tizen.Multimedia.Vision
22 /// Represents a configuration of <see cref="ImageTracker"/>.
24 /// <since_tizen> 3</since_tizen>
25 public class ImageTrackingConfiguration : ImageRecognitionConfiguration
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";
35 /// A read-only field that represents the default value of <see cref="HistoryAmount"/>.
37 /// <since_tizen> 3</since_tizen>
38 public static readonly int DefaultHistoryAmount = 3;
41 /// A read-only field that represents the default value of <see cref="ExpectedOffset"/>.
43 /// <since_tizen> 3</since_tizen>
44 public static readonly double DefaultExpectedOffset = 0;
47 /// A read-only field that represents the default value of <see cref="IsStabilizationEnabled"/>.
49 /// <since_tizen> 3</since_tizen>
50 public static readonly bool DefaultStabilizationEnabled = true;
53 /// A read-only field that represents the default value of <see cref="StabilizationTolerantShift"/>.
55 /// <since_tizen> 3</since_tizen>
56 public static readonly double DefaultStabilizationTolerantShift = 0.00006;
59 /// A read-only field that represents the default value of <see cref="StabilizationSpeed"/>.
61 /// <since_tizen> 3</since_tizen>
62 public static readonly double DefaultStabilizationSpeed = 0.3;
65 /// A read-only field that represents the default value of <see cref="StabilizationAcceleration"/>.
67 /// <since_tizen> 3</since_tizen>
68 public static readonly double DefaultStabilizationAcceleration = 0.1;
71 /// Initializes a new instance of the <see cref="ImageTrackingConfiguration"/> class.
73 /// <exception cref="NotSupportedException">The feature is not supported.</exception>
74 /// <since_tizen> 3</since_tizen>
75 public ImageTrackingConfiguration()
80 /// Gets or sets the number of recognition results in the tracking history.
83 /// The number of previous recognition results, which will influence the stabilization.\n
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
93 return GetInt(KeyHistoryAmount);
99 throw new ArgumentOutOfRangeException(nameof(HistoryAmount), value,
100 $"{nameof(HistoryAmount)} can't be less than zero.");
102 Set(KeyHistoryAmount, value);
107 /// Gets or sets the expected tracking offset.
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.
113 /// <exception cref="ObjectDisposedException">The <see cref="ImageTrackingConfiguration"/> already has been disposed of.</exception>
114 /// <since_tizen> 3</since_tizen>
115 public double ExpectedOffset
119 return GetDouble(KeyExpectedOffset);
123 Set(KeyExpectedOffset, value);
128 /// Gets or sets the acceleration of the tracking stabilization.
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.
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
139 /// <paramref name="value"/> is greater than one.
141 /// <since_tizen> 3</since_tizen>
142 public double StabilizationAcceleration
146 return GetDouble(KeyStabilizationAcceleration);
150 if (value < 0 || value > 1)
152 throw new ArgumentOutOfRangeException(nameof(value), value, "Valid range is 0 to 1 inclusive.");
155 Set(KeyStabilizationAcceleration, value);
160 /// Gets or sets the speed of the tracking stabilization.
163 /// The start speed value used for image stabilization.\n
164 /// The default is 0.3.
166 /// <exception cref="ObjectDisposedException">The <see cref="ImageTrackingConfiguration"/> already has been disposed of.</exception>
167 /// <since_tizen> 3</since_tizen>
168 public double StabilizationSpeed
172 return GetDouble(KeyStabilizationSpeed);
176 Set(KeyStabilizationSpeed, value);
181 /// Gets or sets the relative tolerant shift for the tracking stabilization.
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
189 /// The default is 0.00006.
191 /// <exception cref="ObjectDisposedException">The <see cref="ImageTrackingConfiguration"/> already has been disposed of.</exception>
192 /// <since_tizen> 3</since_tizen>
193 public double StabilizationTolerantShift
197 return GetDouble(KeyStabilizationTolerantShift);
201 Set(KeyStabilizationTolerantShift, value);
206 /// Gets or sets the state of the contour stabilization during tracking process.
209 /// true if the contour stabilization is enabled; otherwise, false.\n
210 /// The default is true.
212 /// <exception cref="ObjectDisposedException">The <see cref="ImageTrackingConfiguration"/> already has been disposed of.</exception>
213 /// <since_tizen> 3</since_tizen>
214 public bool IsStabilizationEnabled
218 return GetBool(KeyUseStabilization);
222 Set(KeyUseStabilization, value);