forked from SharpSenses/libpxcclr.cs
/
pxcmblobdata.cs
356 lines (290 loc) · 14 KB
/
pxcmblobdata.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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
/*******************************************************************************
INTEL CORPORATION PROPRIETARY INFORMATION
This software is supplied under the terms of a license agreement or nondisclosure
agreement with Intel Corporation and may not be copied or disclosed except in
accordance with the terms of that agreement
Copyright(c) 2014 Intel Corporation. All Rights Reserved.
*******************************************************************************/
using System;
using System.Text;
using System.Runtime.InteropServices;
using System.Collections.Generic;
#if RSSDK_IN_NAMESPACE
namespace intel.rssdk
{
#endif
/**
@Class PXCMBlobData
@brief A class that contains extracted blob and contour line data.
The extracted data refers to the sensor's frame image at the time PXCBlobModule.CreateOutput() was called.
*/
public partial class PXCMBlobData : PXCMBase
{
new public const Int32 CUID = 0x54444d42;
public const Int32 NUMBER_OF_EXTREMITIES = 6;
/* Enumerations */
/* Enumerations */
/**
@enum AccessOrderType
@brief Each AccessOrderType value indicates the order in which the extracted blobs can be accessed.
Use one of these values when calling QueryBlobByAccessOrder().
*/
public enum AccessOrderType
{
ACCESS_ORDER_NEAR_TO_FAR = 0, /// From the nearest to the farthest blob in the scene
ACCESS_ORDER_LARGE_TO_SMALL, /// From the largest to the smallest blob in the scene
ACCESS_ORDER_RIGHT_TO_LEFT /// From the right-most to the left-most blob in the scene
};
/**
@enum ExtremityType
@brief The identifier of an extremity point of the extracted blob.
6 extremity points are identified (see values below).\n
Use one of the extremity types when calling IBlob.QueryExtremityPoint().
*/
public enum ExtremityType
{
EXTREMITY_CLOSEST = 0, /// The closest point to the sensor in the tracked blob
EXTREMITY_LEFT_MOST, /// The left-most point of the tracked blob
EXTREMITY_RIGHT_MOST, /// The right-most point of the tracked blob
EXTREMITY_TOP_MOST, /// The top-most point of the tracked blob
EXTREMITY_BOTTOM_MOST, /// The bottom-most point of the tracked blob
EXTREMITY_CENTER /// The center point of the tracked blob
};
/**
@enum SegmentationImageType
@brief Each SegmentationImageType value indicates the extracted blobs data mapping.
Use one of these values when calling QueryBlob().
*/
public enum SegmentationImageType
{
SEGMENTATION_IMAGE_DEPTH = 0, /// The blob data mapped to depth image
SEGMENTATION_IMAGE_COLOR /// The blob data mapped to color image
};
/* Interfaces */
/**
@class IContour
@brief An interface that provides access to the contour line data.
A contour is represented by an array of 2D points, which are the vertices of the contour's polygon.
*/
public partial class IContour
{
/**
@brief Get the point array representing a contour line.
@param[in] maxSize - the size of the array allocated for the contour points.
@param[out] contour - the contour points stored in the user-allocated array.
@return PXCM_STATUS_NO_ERROR - successful operation.
*/
public pxcmStatus QueryPoints(out PXCMPointI32[] contour)
{
return QueryDataINT(instance, out contour);
}
/**
@brief Return true for the blob's outer contour; false for inner contours.
@return true for the blob's outer contour; false for inner contours.
*/
public Boolean IsOuter()
{
return PXCMBlobData_IContour_IsOuter(instance);
}
/**
@brief Get the contour size (number of points in the contour line).
This is the size of the points array that you should allocate.
@return The contour size (number of points in the contour line).
*/
public Int32 QuerySize()
{
return PXCMBlobData_IContour_QuerySize(instance);
}
private IntPtr instance;
internal IContour(IntPtr instance)
{
this.instance = instance;
}
};
/**
@class IBlob
@brief An interface that provides access to the blob and contour line data.
*/
public partial class IBlob
{
/**
@brief Retrieves the 2D segmentation image of a tracked blob.
In the segmentation image, each pixel occupied by the blob is white (value of 255) and all other pixels are black (value of 0).
@param[out] image - the segmentation image of the tracked blob.
@return PXCM_STATUS_NO_ERROR - successful operation.
@return PXCM_STATUS_DATA_UNAVAILABLE - the segmentation image is not available.
*/
public pxcmStatus QuerySegmentationImage(out PXCMImage image)
{
IntPtr image2;
pxcmStatus sts = PXCMBlobData_IBlob_QuerySegmentationImage(instance, out image2);
image = (sts >= pxcmStatus.PXCM_STATUS_NO_ERROR) ? new PXCMImage(image2, false) : null;
return sts;
}
/**
@brief Get an extremity point location using a specific ExtremityType.
@param[in] extremityLabel - the extremity type to be retrieved.
@return The extremity point location data.
@see ExtremityType
*/
public PXCMPoint3DF32 QueryExtremityPoint(ExtremityType extremityLabel)
{
return QueryExtremityPointINT(instance, extremityLabel);
}
/**
@brief Get the number of pixels in the blob.
@return The number of pixels in the blob.
*/
public Int32 QueryPixelCount()
{
return PXCMBlobData_IBlob_QueryPixelCount(instance);
}
/**
@brief Get the number of contour lines extracted (both external and internal).
@return The number of contour lines extracted.
*/
public Int32 QueryNumberOfContours()
{
return PXCMBlobData_IBlob_QueryNumberOfContours(instance);
}
/**
@brief Get the point array representing a contour line.
A contour is represented by an array of 2D points, which are the vertices of the contour's polygon.
@param[in] index - the zero-based index of the requested contour line (the maximal value is QueryNumberOfContours()-1).
@param[in] maxSize - the size of the array allocated for the contour points.
@param[out] contour - the contour points stored in the user-allocated array.
@return PXCM_STATUS_NO_ERROR - successful operation.
@return PXCM_STATUS_PARAM_UNSUPPORTED - the given index or the user-allocated array is invalid.
@return PXCM_STATUS_ITEM_UNAVAILABLE - processImage() is running.
*/
public pxcmStatus QueryContourPoints(Int32 index, out PXCMPointI32[] contour)
{
return QueryContourDataINT(instance, index, out contour);
}
/**
@brief Return true for the blob's outer contour; false for inner contours.
@param[in] index - the zero-based index of the requested contour.
@return true for the blob's outer contour; false for inner contours.
*/
public Boolean IsContourOuter(Int32 index)
{
return PXCMBlobData_IBlob_IsContourOuter(instance, index);
}
/**
@brief Get the contour size (number of points in the contour line).
This is the size of the points array that you should allocate.
@param[in] index - the zero-based index of the requested contour line.
@return The contour size (number of points in the contour line).
*/
public Int32 QueryContourSize(Int32 index)
{
return PXCMBlobData_IBlob_QueryContourSize(instance, index);
}
/**
@brief Retrieve an IContour object using index (that relates to the given order).
@param[in] index - the zero-based index of the requested contour (between 0 and QueryNumberOfContours()-1 ).
@param[out] contourData - contains the extracted contour line data.
@return PXCM_STATUS_NO_ERROR - successful operation.
@return PXCM_STATUS_DATA_UNAVAILABLE - index >= number of detected contours.
@see IContour
*/
public pxcmStatus QueryContour(Int32 index, out IContour contourData)
{
IntPtr cd2;
pxcmStatus sts = PXCMBlobData_IBlob_QueryContour(instance, index, out cd2);
contourData = (sts >= pxcmStatus.PXCM_STATUS_NO_ERROR) ? new IContour(cd2) : null;
return sts;
}
/**
@brief Return the location and dimensions of the blob, represented by a 2D bounding box (defined in pixels).
@return The location and dimensions of the 2D bounding box.
*/
public PXCMRectI32 QueryBoundingBoxImage()
{
PXCMRectI32 rect = new PXCMRectI32();
PXCMBlobData_IBlob_QueryBoundingBoxImage(instance, ref rect);
return rect;
}
/**
@brief Return the location and dimensions of the blob, represented by a 3D bounding box.
@return The location and dimensions of the 3D bounding box.
*/
public PXCMBox3DF32 QueryBoundingBoxWorld()
{
PXCMBox3DF32 rect = new PXCMBox3DF32();
PXCMBlobData_IBlob_QueryBoundingBoxWorld(instance, ref rect);
return rect;
}
public override int GetHashCode()
{
return instance.GetHashCode();
}
private IntPtr instance;
internal IBlob(IntPtr instance)
{
this.instance = instance;
}
};
/* General */
/**
@brief Updates the extracted blob data to the latest available output.
@return PXCM_STATUS_NO_ERROR - successful operation.
@return PXCM_STATUS_DATA_NOT_INITIALIZED - when the BlobData is not available.
*/
public pxcmStatus Update()
{
return PXCMBlobData_Update(instance);
}
/* Blob module's Outputs */
/**
@brief Get the number of extracted blobs.
@return The number of extracted blobs.
*/
public Int32 QueryNumberOfBlobs()
{
return PXCMBlobData_QueryNumberOfBlobs(instance);
}
/**
@brief Retrieve an IBlob object using a specific AccessOrder and index (that relates to the given order).
@param[in] index - the zero-based index of the requested blob (between 0 and QueryNumberOfBlobs()-1 ).
@param[in] accessOrder - the order in which the blobs are enumerated.
@param[out] blobData - contains the extracted blob and contour line data.
@return PXCM_STATUS_NO_ERROR - successful operation.
@return PXCM_STATUS_PARAM_UNSUPPORTED - index >= configured maxBlobs.
@return PXCM_STATUS_DATA_UNAVAILABLE - index >= number of detected blobs.
@see AccessOrderType
*/
public pxcmStatus QueryBlobByAccessOrder(Int32 index, AccessOrderType accessOrderType, out IBlob blobData)
{
IntPtr bd2;
pxcmStatus sts = PXCMBlobData_QueryBlobByAccessOrder(instance, index, accessOrderType, out bd2);
blobData = (sts >= pxcmStatus.PXCM_STATUS_NO_ERROR) ? new IBlob(bd2) : null;
return sts;
}
/**
@brief Retrieve an IBlob object using a specific AccessOrder and index (that relates to the given order).
@param[in] index - the zero-based index of the requested blob (between 0 and QueryNumberOfBlobs()-1 ).
@param[in] segmentationImageType - the image type which the blob will be mapped to. To get data mapped to color see PXCBlobConfiguration::EnableColorMapping.
@param[in] accessOrder - the order in which the blobs are enumerated.
@param[out] blobData - contains the extracted blob data.
@return PXCM_STATUS_NO_ERROR - successful operation.
@return PXCM_STATUS_PARAM_UNSUPPORTED - index >= configured maxBlobs.
@return PXCM_STATUS_DATA_UNAVAILABLE - index >= number of detected blobs or blob data is invalid.
@see AccessOrderType
@see SegmentationImageType
*/
public pxcmStatus QueryBlob(Int32 index,SegmentationImageType segmentationImageType, AccessOrderType accessOrderType, out IBlob blobData)
{
IntPtr bd2;
pxcmStatus sts = PXCMBlobData_QueryBlob(instance, index,segmentationImageType, accessOrderType, out bd2);
blobData = (sts >= pxcmStatus.PXCM_STATUS_NO_ERROR) ? new IBlob(bd2) : null;
return sts;
}
internal PXCMBlobData(IntPtr instance, Boolean delete)
: base(instance, delete)
{
}
};
#if RSSDK_IN_NAMESPACE
}
#endif