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
22 /// Represents a configuration of <see cref="ImageTracker"/>.
24 public class ImageTrackingConfiguration : ImageRecognitionConfiguration
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";
34 /// A read-only field that represents the default value of <see cref="HistoryAmount"/>.
36 public static readonly int DefaultHistoryAmount = 3;
39 /// A read-only field that represents the default value of <see cref="ExpectedOffset"/>.
41 public static readonly double DefaultExpectedOffset = 0;
44 /// A read-only field that represents the default value of <see cref="IsStabilizationEnabled"/>.
46 public static readonly bool DefaultStabilizationEnabled = true;
49 /// A read-only field that represents the default value of <see cref="StabilizationTolerantShift"/>.
51 public static readonly double DefaultStabilizationTolerantShift = 0.00006;
54 /// A read-only field that represents the default value of <see cref="StabilizationSpeed"/>.
56 public static readonly double DefaultStabilizationSpeed = 0.3;
59 /// A read-only field that represents the default value of <see cref="StabilizationAccelaration"/>.
61 public static readonly double DefaultStabilizationAccelaration = 0.1;
64 /// Initializes a new instance of the <see cref="ImageTrackingConfiguration"/> class.
66 /// <exception cref="NotSupportedException">The feature is not supported.</exception>
67 public ImageTrackingConfiguration()
72 /// Gets or sets the number of recognition results in the tracking history.
75 /// The number of previous recognition results, which will influence the stabilization.\n
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
84 return GetInt(KeyHistoryAmount);
90 throw new ArgumentOutOfRangeException(nameof(HistoryAmount), value,
91 $"{nameof(HistoryAmount)} can't be less than zero.");
93 Set(KeyHistoryAmount, value);
98 /// Gets or sets the expected tracking offset.
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.
104 /// <exception cref="ObjectDisposedException">The <see cref="ImageTrackingConfiguration"/> already has been disposed of.</exception>
105 public double ExpectedOffset
109 return GetDouble(KeyExpectedOffset);
113 Set(KeyExpectedOffset, value);
118 /// Gets or sets the acceleration of the tracking stabilization.
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.
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
129 /// <paramref name="value"/> is greater than one.
131 public double StabilizationAccelaration
135 return GetDouble(KeyStabilizationAccelaration);
139 if (value < 0 || value > 1)
141 throw new ArgumentOutOfRangeException(nameof(value), value, "Valid range is 0 to 1 inclusive.");
144 Set(KeyStabilizationAccelaration, value);
149 /// Gets or sets the speed of the tracking stabilization.
152 /// The start speed value used for image stabilization.\n
153 /// The default is 0.3.
155 /// <exception cref="ObjectDisposedException">The <see cref="ImageTrackingConfiguration"/> already has been disposed of.</exception>
156 public double StabilizationSpeed
160 return GetDouble(KeyStabilizationSpeed);
164 Set(KeyStabilizationSpeed, value);
169 /// Gets or sets the relative tolerant shift for the tracking stabilization.
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
177 /// The default is 0.00006.
179 /// <exception cref="ObjectDisposedException">The <see cref="ImageTrackingConfiguration"/> already has been disposed of.</exception>
180 public double StabilizationTolerantShift
184 return GetDouble(KeyStabilizationTolerantShift);
188 Set(KeyStabilizationTolerantShift, value);
193 /// Gets or sets the state of the contour stabilization during tracking process.
196 /// true if the contour stabilization is enabled; otherwise, false.\n
197 /// The default is true.
199 /// <exception cref="ObjectDisposedException">The <see cref="ImageTrackingConfiguration"/> already has been disposed of.</exception>
200 public bool IsStabilizationEnabled
204 return GetBool(KeyUseStabilization);
208 Set(KeyUseStabilization, value);