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="ImageRecognizer"/>.
24 /// <since_tizen> 3</since_tizen>
25 public class ImageRecognitionConfiguration : EngineConfiguration
27 private const string KeySceneScaleFactor = "MV_IMAGE_RECOGNITION_SCENE_SCALE_FACTOR";
28 private const string KeySceneMaxKeypoints = "MV_IMAGE_RECOGNITION_SCENE_MAX_KEYPOINTS_NUM";
30 private const string KeyMinKeypointsMatch = "MV_IMAGE_RECOGNITION_MIN_MATCH_NUM";
31 private const string KeyReqMatchPartKey = "MV_IMAGE_RECOGNITION_REQ_MATCH_PART";
32 private const string KeyTolerantPartMatchingError = "MV_IMAGE_RECOGNITION_TOLERANT_MATCH_PART_ERR";
35 /// A read-only field that represents the default value of <see cref="KeySceneScaleFactor"/>.
37 /// <since_tizen> 3</since_tizen>
38 public static readonly double DefaultSceneScaleFactor = 1.2;
41 /// A read-only field that represents the default value of <see cref="SceneMaxKeyPoints"/>.
43 /// <since_tizen> 3</since_tizen>
44 public static readonly int DefaultSceneMaxKeypoints = 5000;
47 /// A read-only field that represents the default value of <see cref="MinKeyPointMatches"/>.
49 /// <since_tizen> 3</since_tizen>
50 public static readonly int DefaultMinKeyPointMatches = 30;
53 /// A read-only field that represents the default value of <see cref="RequiredMatchingPart"/>.
55 /// <since_tizen> 3</since_tizen>
56 public static readonly double DefaultRequiredMatchPart = 0.05;
59 /// A read-only field that represents the default value of <see cref="TolerantPartMatchError"/>.
61 /// <since_tizen> 3</since_tizen>
62 public static readonly double DefaultTolerantPartMatchError = 0.1;
65 /// Initializes a new instance of the <see cref="ImageRecognitionConfiguration"/> class.
67 /// <exception cref="NotSupportedException">The feature is not supported.</exception>
68 /// <since_tizen> 3</since_tizen>
69 public ImageRecognitionConfiguration() : base("image_recognition")
74 /// Gets or sets the scene scale factor.
77 /// The value indicating the factor will be used for resizing of the scene including the images (objects) for recognition.
78 /// The default is 1.2.
80 /// <exception cref="ObjectDisposedException">The <see cref="ImageRecognitionConfiguration"/> already has been disposed of.</exception>
81 /// <since_tizen> 3</since_tizen>
82 public double SceneScaleFactor
86 return GetDouble(KeySceneScaleFactor);
90 Set(KeySceneScaleFactor, value);
95 /// Gets or sets the maximum key points that should be detected on the scene.
96 /// The maximal number of key points can be selected on the scene including the images (objects) to calculate descriptors.
99 /// The maximal key points for image recognition.
100 /// The default is 5000.
102 /// <exception cref="ObjectDisposedException">The <see cref="ImageRecognitionConfiguration"/> already has been disposed of.</exception>
103 /// <exception cref="ArgumentOutOfRangeException"><paramref name="value"/> is less than zero.</exception>
104 /// <since_tizen> 3</since_tizen>
105 public int SceneMaxKeyPoints
109 return GetInt(KeySceneMaxKeypoints);
115 throw new ArgumentOutOfRangeException(nameof(SceneMaxKeyPoints), value,
116 $"{nameof(SceneMaxKeyPoints)} can't be less than zero.");
118 Set(KeySceneMaxKeypoints, value);
123 /// Gets or sets the minimum number of key points matches required for recognition.
126 /// The minimal number of key points should be matched between an image and a scene for image objects recognition.
127 /// The default is 30.
129 /// <exception cref="ObjectDisposedException">The <see cref="ImageRecognitionConfiguration"/> already has been disposed of.</exception>
130 /// <exception cref="ArgumentOutOfRangeException"><paramref name="value"/> is less than zero.</exception>
131 /// <since_tizen> 3</since_tizen>
132 public int MinKeyPointMatches
136 return GetInt(KeyMinKeypointsMatch);
142 throw new ArgumentOutOfRangeException(nameof(MinKeyPointMatches), value,
143 $"{nameof(MinKeyPointMatches)} can't be less than zero.");
145 Set(KeyMinKeypointsMatch, value);
150 /// Gets or sets the required matching part for the image recognition.
151 /// To recognize occluded or hidden an image by other images, required relative part of the matches in respect to the total
152 /// amount of matching keypoints required for image recognition. Too low value will result in unsustainable behavior,
153 /// but effect of object overlapping will be reduced.
156 /// The value indicating required relative part of the matches; can be from 0 to 1, inclusive.
157 /// The default is 0.05.
159 /// <exception cref="ObjectDisposedException">The <see cref="ImageRecognitionConfiguration"/> already has been disposed of.</exception>
160 /// <exception cref="ArgumentOutOfRangeException">
161 /// <paramref name="value"/> is less than zero.\n
163 /// <paramref name="value"/> is greater than one.
165 /// <since_tizen> 3</since_tizen>
166 public double RequiredMatchingPart
170 return GetDouble(KeyReqMatchPartKey);
174 if (value < 0 || value > 1)
176 throw new ArgumentOutOfRangeException(nameof(value), value, "Valid range is 0 to 1 inclusive,");
178 Set(KeyReqMatchPartKey, value);
183 /// Gets or sets the part matching error for the image recognition.\n
184 /// Allowable error of matches number.
187 /// The value indicating allowable error of matches; can be from 0 to 1, inclusive.
188 /// The default is 0.1.
190 /// <exception cref="ObjectDisposedException">The <see cref="ImageRecognitionConfiguration"/> already has been disposed of.</exception>
191 /// <exception cref="ArgumentOutOfRangeException">
192 /// <paramref name="value"/> is less than zero.\n
194 /// <paramref name="value"/> is greater than one.
196 /// <since_tizen> 3</since_tizen>
197 public double TolerantPartMatchError
201 return GetDouble(KeyTolerantPartMatchingError);
205 if (value < 0 || value > 1)
207 throw new ArgumentOutOfRangeException(nameof(value), value, "Valid range is 0 to 1 inclusive.");
210 Set(KeyTolerantPartMatchingError, value);