/
ImageRecognitionConfiguration.cs
executable file
·215 lines (200 loc) · 8.72 KB
/
ImageRecognitionConfiguration.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
namespace Tizen.Multimedia.Vision
{
/// <summary>
/// Represents a configuration of <see cref="ImageRecognizer"/>.
/// </summary>
/// <feature>http://tizen.org/feature/vision.image_recognition</feature>
/// <since_tizen> 4 </since_tizen>
public class ImageRecognitionConfiguration : EngineConfiguration
{
private const string KeySceneScaleFactor = "MV_IMAGE_RECOGNITION_SCENE_SCALE_FACTOR";
private const string KeySceneMaxKeypoints = "MV_IMAGE_RECOGNITION_SCENE_MAX_KEYPOINTS_NUM";
private const string KeyMinKeypointsMatch = "MV_IMAGE_RECOGNITION_MIN_MATCH_NUM";
private const string KeyReqMatchPartKey = "MV_IMAGE_RECOGNITION_REQ_MATCH_PART";
private const string KeyTolerantPartMatchingError = "MV_IMAGE_RECOGNITION_TOLERANT_MATCH_PART_ERR";
/// <summary>
/// A read-only field that represents the default value of <see cref="SceneScaleFactor"/>.
/// </summary>
/// <since_tizen> 4 </since_tizen>
public static readonly double DefaultSceneScaleFactor = 1.2;
/// <summary>
/// A read-only field that represents the default value of <see cref="SceneMaxKeyPoints"/>.
/// </summary>
/// <since_tizen> 4 </since_tizen>
public static readonly int DefaultSceneMaxKeypoints = 5000;
/// <summary>
/// A read-only field that represents the default value of <see cref="MinKeyPointMatches"/>.
/// </summary>
/// <since_tizen> 4 </since_tizen>
public static readonly int DefaultMinKeyPointMatches = 30;
/// <summary>
/// A read-only field that represents the default value of <see cref="RequiredMatchingPart"/>.
/// </summary>
/// <since_tizen> 4 </since_tizen>
public static readonly double DefaultRequiredMatchPart = 0.05;
/// <summary>
/// A read-only field that represents the default value of <see cref="TolerantPartMatchError"/>.
/// </summary>
/// <since_tizen> 4 </since_tizen>
public static readonly double DefaultTolerantPartMatchError = 0.1;
/// <summary>
/// Initializes a new instance of the <see cref="ImageRecognitionConfiguration"/> class.
/// </summary>
/// <exception cref="NotSupportedException">The feature is not supported.</exception>
/// <since_tizen> 4 </since_tizen>
public ImageRecognitionConfiguration() : base("image_recognition")
{
}
/// <summary>
/// Gets or sets the scene scale factor.
/// </summary>
/// <value>
/// The value indicating the factor will be used for resizing of the scene including the images (objects) for recognition.
/// The default is 1.2.
/// </value>
/// <exception cref="ObjectDisposedException">The <see cref="ImageRecognitionConfiguration"/> already has been disposed of.</exception>
/// <since_tizen> 4 </since_tizen>
public double SceneScaleFactor
{
get
{
return GetDouble(KeySceneScaleFactor);
}
set
{
Set(KeySceneScaleFactor, value);
}
}
/// <summary>
/// Gets or sets the maximum key points that should be detected on the scene.
/// The maximal number of key points can be selected on the scene including the images (objects) to calculate descriptors.
/// </summary>
/// <value>
/// The maximal key points for image recognition.
/// The default is 5000.
/// </value>
/// <exception cref="ObjectDisposedException">The <see cref="ImageRecognitionConfiguration"/> already has been disposed of.</exception>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value"/> is less than zero.</exception>
/// <since_tizen> 4 </since_tizen>
public int SceneMaxKeyPoints
{
get
{
return GetInt(KeySceneMaxKeypoints);
}
set
{
if (value < 0)
{
throw new ArgumentOutOfRangeException(nameof(SceneMaxKeyPoints), value,
$"{nameof(SceneMaxKeyPoints)} can't be less than zero.");
}
Set(KeySceneMaxKeypoints, value);
}
}
/// <summary>
/// Gets or sets the minimum number of key points matches required for recognition.
/// </summary>
/// <value>
/// The minimal number of key points should be matched between an image and a scene for image objects recognition.
/// The default is 30.
/// </value>
/// <exception cref="ObjectDisposedException">The <see cref="ImageRecognitionConfiguration"/> already has been disposed of.</exception>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value"/> is less than zero.</exception>
/// <since_tizen> 4 </since_tizen>
public int MinKeyPointMatches
{
get
{
return GetInt(KeyMinKeypointsMatch);
}
set
{
if (value < 0)
{
throw new ArgumentOutOfRangeException(nameof(MinKeyPointMatches), value,
$"{nameof(MinKeyPointMatches)} can't be less than zero.");
}
Set(KeyMinKeypointsMatch, value);
}
}
/// <summary>
/// Gets or sets the required matching part for the image recognition.
/// To recognize occluded or hidden an image by other images, required relative part of the matches in respect to the total
/// amount of matching keypoints required for image recognition. Too low value will result in unsustainable behavior,
/// but the effect of object overlapping will be reduced.
/// </summary>
/// <value>
/// The value indicating required relative part of the matches; can be from 0 to 1, inclusive.
/// The default is 0.05.
/// </value>
/// <exception cref="ObjectDisposedException">The <see cref="ImageRecognitionConfiguration"/> already has been disposed of.</exception>
/// <exception cref="ArgumentOutOfRangeException">
/// <paramref name="value"/> is less than zero.<br/>
/// -or-<br/>
/// <paramref name="value"/> is greater than one.
/// </exception>
/// <since_tizen> 4 </since_tizen>
public double RequiredMatchingPart
{
get
{
return GetDouble(KeyReqMatchPartKey);
}
set
{
if (value < 0 || value > 1)
{
throw new ArgumentOutOfRangeException(nameof(value), value, "Valid range is 0 to 1 inclusive,");
}
Set(KeyReqMatchPartKey, value);
}
}
/// <summary>
/// Gets or sets the part matching error for the image recognition.<br/>
/// Allowable error of matches number.
/// </summary>
/// <value>
/// The value indicating allowable error of matches; can be from 0 to 1, inclusive.
/// The default is 0.1.
/// </value>
/// <exception cref="ObjectDisposedException">The <see cref="ImageRecognitionConfiguration"/> already has been disposed of.</exception>
/// <exception cref="ArgumentOutOfRangeException">
/// <paramref name="value"/> is less than zero.<br/>
/// -or-<br/>
/// <paramref name="value"/> is greater than one.
/// </exception>
/// <since_tizen> 4</since_tizen>
public double TolerantPartMatchError
{
get
{
return GetDouble(KeyTolerantPartMatchingError);
}
set
{
if (value < 0 || value > 1)
{
throw new ArgumentOutOfRangeException(nameof(value), value, "Valid range is 0 to 1 inclusive.");
}
Set(KeyTolerantPartMatchingError, value);
}
}
}
}