forked from SharpSenses/libpxcclr.cs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pxcmsceneperception.cs
1407 lines (1176 loc) · 60.9 KB
/
pxcmsceneperception.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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*******************************************************************************
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.Runtime.InteropServices;
#if RSSDK_IN_NAMESPACE
namespace intel.rssdk
{
#endif
/**
Instance of this interface class can be created using
PXCMScenePerception.CreatePXCSurfaceVoxelsData method. ExportSurfaceVoxels
function fills the data buffer. It's clients responsibility to
explicitly release the memory by calling Dispose() On PXCMSurfaceVoxelsData
*/
public partial class PXCMSurfaceVoxelsData : PXCMBase
{
new public const Int32 CUID = 0x56535053;
/**
@brief: Returns number of Surface Voxels present in the buffer.
This function is expected to be used after successful
call to ExportSurfaceVoxels()
*/
public Int32 QueryNumberOfSurfaceVoxels()
{
return PXCMSurfaceVoxelsData_QueryNumberOfSurfaceVoxels(instance);
}
/**
@brief: Returns an array to center of Surface Voxels extracted by
ExportSurfaceVoxels. This function is expected to be used after successful
call to ExportSurfaceVoxels(). Valid range is [0, 3*QueryNumberOfSurfaceVoxels())
*/
public Single[] QueryCenterOfSurfaceVoxels()
{
int nvoxels = QueryNumberOfSurfaceVoxels();
if (nvoxels <= 0) return null;
Single[] voxels = new Single[3 * nvoxels];
QueryCenterOfSurfaceVoxelsINT(instance, voxels, nvoxels);
return voxels;
}
/**
@brief: Returns an array of colors with length 3*QueryNumberOfSurfaceVoxels(). Three
color channels (RGB) per voxel. This Function will return null, if
PXCMSurfaceVoxelsData was created using PXCMScenePerception.CreatePXCSurfaceVoxelsData with bUseColor set to false.
*/
public Byte[] QuerySurfaceVoxelsColor()
{
int nvoxels = QueryNumberOfSurfaceVoxels();
if (nvoxels <= 0) return null;
Byte[] colors = new Byte[3 * nvoxels];
QuerySurfaceVoxelsColorINT(instance, colors, nvoxels);
return colors;
}
/**
@brief: Sets NumberOfSurfaceVoxels to 0. However it doesn't release memory.
It should be used when you reset ScenePerception using
PXCMScenePerception.Reset() client should Reset PXCMSurfaceVoxelsData
when Scene Perception is Reset to stay in Sync with the ScenePerception
*/
public pxcmStatus Reset()
{
return PXCMSurfaceVoxelsData_Reset(instance);
}
/* constructors & misc */
internal PXCMSurfaceVoxelsData(IntPtr instance, Boolean delete)
: base(instance, delete)
{
}
};
/**
An instance of this interface can be created using
PXCMScenePerception.CreatePXCBlockMeshingData method DoMeshingUpdate
function fills all the buffer with the data. It's clients responsibility to
explicitly release the memory by calling Dispose() On PXCMBlockMeshingData
*/
public partial class PXCMBlockMeshingData : PXCMBase
{
new public const Int32 CUID = 0x4d425053;
/**
@brief: Returns Number of PXCMBlockMesh present inside the buffer
returned by QueryBlockMeshes(). This function is expected to be used
after successful call to DoMeshingUpdate
*/
public Int32 QueryNumberOfBlockMeshes()
{
return PXCMBlockMeshingData_QueryNumberOfBlockMeshes(instance);
}
/**
@brief: Returns number of Vertices present in the buffer returned by
QueryVertices(). This function is expected to be used after successful
call to DoMeshingUpdate
*/
public Int32 QueryNumberOfVertices()
{
return PXCMBlockMeshingData_QueryNumberOfVertices(instance);
}
/**
@brief: Returns number of Faces in the buffer returned by
QueryFaces(). This function is expected to be used after successful
call to DoMeshingUpdate
*/
public Int32 QueryNumberOfFaces()
{
return PXCMBlockMeshingData_QueryNumberOfFaces(instance);
}
/**
@brief: Returns maximum number of BlockMeshes that can be returned by
DoMeshingUpdate. This value remains same throughout the lifetime of the
instance
*/
public Int32 QueryMaxNumberOfBlockMeshes()
{
return PXCMBlockMeshingData_QueryMaxNumberOfBlockMeshes(instance);
}
/**
@brief: Returns maximum number of vertices that can be returned by
PXCBlockMeshingData. This value remains same throughout the lifetime of
the instance
*/
public Int32 QueryMaxNumberOfVertices()
{
return PXCMBlockMeshingData_QueryMaxNumberOfVertices(instance);
}
/**
@brief: Returns maximum number of faces that can be returned by
PXCBlockMeshingData. This value remains same throughout the lifetime of
the instance
*/
public Int32 QueryMaxNumberOfFaces()
{
return PXCMBlockMeshingData_QueryMaxNumberOfFaces(instance);
}
/**
Describes each BlockMeshe present inside list returned by
QueryBlockMeshes()
*/
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public class PXCMBlockMesh
{
public Int32 meshId; // Unique ID to identify each PXCBlockMesh
public Int32 vertexStartIndex; // Starting index of the vertex inside Vertex Buffer obtained using QueryVertices()
public Int32 numVertices; // Total number of Vertices inside this PXC<BlockMesh
public Int32 faceStartIndex; // Starting index of the face list in a MeshFaces Buffer obtained using QueryFaces()
public Int32 numFaces; // Number of faces forming the mesh inside this PXCBlockMesh
public PXCMPoint3DF32 min3dPoint; // minimum point for the axis aligned bounding box containing the mesh piece
public PXCMPoint3DF32 max3dPoint; // maximum point for the axis aligned bounding box containing the mesh piece
public Single maxDistanceChange; // maximum change in the distance field due to accumulation since this block was last meshed
public Single avgDistanceChange; // average change in the distance field due to accumulation since this block was last meshed
};
/**
@brief: Returns an array of PXCBlockMesh objects with length same as
QueryNumberOfBlockMeshes()
*/
public PXCMBlockMesh[] QueryBlockMeshes(PXCMBlockMesh[] meshes)
{
int nmeshes = QueryNumberOfBlockMeshes();
if (nmeshes <= 0) return null;
if (meshes == null)
meshes = new PXCMBlockMesh[nmeshes];
QueryBlockMeshesINT(instance, meshes, nmeshes);
return meshes;
}
/**
@brief: Returns an array of PXCBlockMesh objects with length same as
QueryNumberOfBlockMeshes()
*/
public PXCMBlockMesh[] QueryBlockMeshes()
{
return QueryBlockMeshes(null);
}
/**
@brief: Returns an array of float points with length 4*QueryNumberOfVertices()
Each vertex consists of 4 float points: (x, y, z) coordinates in meter
unit + a confidence value. The confidence value is in the range [0, 1]
indicating how confident scene perception is about the presence of
the vertex.
*/
public Single[] QueryVertices(Single[] vertices)
{
int nvertices = QueryNumberOfVertices();
if (nvertices <= 0) return null;
if (vertices == null)
vertices=new Single[4*nvertices];
QueryVerticesINT(instance, vertices, nvertices);
return vertices;
}
/**
@brief: Returns an array of float points with length 4*QueryNumberOfVertices()
Each vertex is consist of 4 float points: (x, y, z) coordinates in meter
unit + a confidence value. The confidence value is in the range [0, 1]
indicating how confident scene perception is about the presence of
the vertex.
*/
public Single[] QueryVertices()
{
return QueryVertices(null);
}
/**
@brief: Returns an array of colors with length 3*QueryNumberOfVertices(). Three
color channels (RGB) per vertex. This Function will return NULL, if
PXCMBlockMeshingData was created using
PXCMScenePerception.CreatePXCBlockMeshingData with bUseColor set to false
*/
public Byte[] QueryVerticesColor(Byte[] colors)
{
int nvertices = QueryNumberOfVertices();
if (nvertices <= 0) return null;
if (colors == null)
colors = new Byte[3 * nvertices];
QueryVerticesColorINT(instance, colors, nvertices);
return colors;
}
/**
@brief: Returns an array of colors with length 3*QueryNumberOfVertices(). Three
color channels (RGB) per vertex. This Function will return NULL, if
PXCMBlockMeshingData was created using
PXCMScenePerception.CreatePXCBlockMeshingData with bUseColor set to false
*/
public Byte[] QueryVerticesColor()
{
return QueryVerticesColor(null);
}
/**
@brief: Returns an array of faces forming the mesh (3 Int32 indices
per triangle) valid range is from [0, 3*QueryNumberOfFaces()]
*/
public Int32[] QueryFaces(Int32[] faces)
{
int nfaces=QueryNumberOfFaces();
if (nfaces <= 0) return null;
if (faces == null)
faces = new Int32[3*nfaces];
QueryFacesINT(instance, faces, nfaces);
return faces;
}
/**
@brief: Returns an array of faces forming the mesh (3 Int32 indices
per triangle) valid range is from [0, 3*QueryNumberOfFaces()]
*/
public Int32[] QueryFaces()
{
return QueryFaces(null);
}
/**
@brief: Sets NumberOfBlockMeshes, NumberOfVertices and NumberOfFaces to
0. However it doesn't release memory. It should be used when you reset
ScenePerception using PXCMScenePerception.Reset() client should Reset
PXCMBlockMeshingData when Scene Perception is Reset to stay in Sync with
the ScenePerception
*/
public pxcmStatus Reset()
{
return PXCMBlockMeshingData_Reset(instance);
}
/* constructors & misc */
internal PXCMBlockMeshingData(IntPtr instance, Boolean delete)
: base(instance, delete)
{
}
};
public partial class PXCMScenePerception : PXCMBase
{
new public const Int32 CUID = 0x504e4353;
public enum TrackingAccuracy
{
HIGH,
LOW,
MED,
FAILED
};
public enum VoxelResolution
{
LOW_RESOLUTION = 0,
MED_RESOLUTION = 1,
HIGH_RESOLUTION = 2
};
public enum MeshResolution
{
LOW_RESOLUTION_MESH,
MED_RESOLUTION_MESH,
HIGH_RESOLUTION_MESH
};
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct MeshingUpdateInfo
{
public Boolean countOfBlockMeshesRequired;
public Boolean blockMeshesRequired;
public Boolean countOfVeticesRequired;
public Boolean verticesRequired;
public Boolean countOfFacesRequired;
public Boolean facesRequired;
public Boolean colorsRequired;
};
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct ScenePerceptionIntrinsics
{
public PXCMSizeI32 imageSize;
public PXCMPointF32 focalLength;
public PXCMPointF32 principalPoint;
};
/**
@brief: SetVoxelResolution sets volume resolution for the scene
perception The VoxelResolution is locked when
PXCMSenseManager.Init() or
SetCaptureProfile(PXCMVideoModule.DataDesc) is called,
Afterwards Value for VoxelResolution remains same throughout the
runtime of Scene Perception module
@param[in] voxelResolution: Resolution of the three dimensional
reconstruction.
Possible values are:
LOW_RESOLUTION: For room-sized scenario (4/256m)
MED_RESOLUTION: For table-top-sized scenario (2/256m)
HIGH_RESOLUTION: For object-sized scenario (1/256m)
Choosing HIGH_RESOLUTION in a room-size environment may degrade the
tracking robustness and quality. Choosing LOW_RESOLUTION in an
object-sized scenario may result in a reconstructed model missing
the fine details.
@returns: PXCM_STATUS_NO_ERROR if It succeeds, returns
PXCM_STATUS_ITEM_UNAVAILABLE If called after making call to
PXCMSenseManager.Init() or
SetCaptureProfile(PXCMVideoModule.DataDesc)
*/
public pxcmStatus SetVoxelResolution(VoxelResolution resolution)
{
return PXCMScenePerception_SetVoxelResolution(instance, resolution);
}
/**
@brief: To Query Voxel resolution used by the scene
perception module. Please refer to SetVoxelResolution for more details.
@returns: Returns current value of VoxelResolution used by the
Scene Perception module
*/
public VoxelResolution QueryVoxelResolution()
{
return PXCMScenePerception_QueryVoxelResolution(instance);
}
/**
@brief: Allows user to Enable/Disable integration of upcoming
camera stream into 3D volume. If disabled the volume will not be
updated However Scene Perception will still keep tracking the
camera. This is a control parameter which can be updated before
passing every frame to the module.
@param[in] enableFlag: Enable/Disable flag for integrating depth
data into the 3D volumetric representation
@returns: PXCM_STATUS_NO_ERROR if It succeeds, otherwise returns
the error code
*/
public pxcmStatus EnableSceneReconstruction(Boolean enabledFlag)
{
return PXCMScenePerception_EnableSceneReconstruction(instance, enabledFlag);
}
/**
@brief: Allows user to to check Whether integration of upcoming
camera stream into 3D volume is enabled or disabled.
@returns: True, If integrating depth data into the 3D volumetric
representation is enabled
*/
public Boolean IsSceneReconstructionEnabled()
{
return PXCMScenePerception_IsSceneReconstructionEnabled(instance);
}
/**
@brief: Allows user to set the initial camera pose.
This Function is only available before first frame is passed to the
module. Once the first frame is passed the Initial Camera Pose is
locked and this function will be unavailable. If this function is
not used then the module default pose as the
Initial Pose for tracking for the device with no platform IMU and
for device with platform IMU the tracking pose will be computed
using gravity vector to align 3D volume with gravity when the
first frame is passed to the module.
@param[in] pose: Array of 12 pxcF32 that stores initial camera pose
user wishes to set in row-major order. Camera pose is specified in a
3 by 4 matrix [R | T] = [Rotation Matrix | Translation Vector]
where R = [ r11 r12 r13 ]
[ r21 r22 r23 ]
[ r31 r32 r33 ]
T = [ tx ty tz ]
Pose Array Layout = [r11 r12 r13 tx r21 r22 r23 ty r31 r32 r33 tz]
Translation vector is in meters.
@returns: If successful it returns PXCM_STATUS_NO_ERROR,
otherwise returns error code If Invalid Pose is passed or the
function is called after passing the first frame
*/
public pxcmStatus SetInitialPose(Single[] pose)
{
if (pose == null || pose.Length != 12)
return pxcmStatus.PXCM_STATUS_PARAM_UNSUPPORTED;
return PXCMScenePerception_SetInitialPose(instance, pose);
}
/**
@brief: Allows user to check tracking accuracy of the last frame
processed by the module. We expect users to call this function
after successful PXCMSenseManager.AcquireFrame call and before
calling PXCMSenesManager.ReleaseFrame. If tracking accuracy is FAILED
the volume data and camera pose are not updated.
@returns: TrackingAccuracy which can be HIGH, LOW, MED or FAILED.
*/
public TrackingAccuracy QueryTrackingAccuracy()
{
return PXCMScenePerception_QueryTrackingAccuracy(instance);
}
/**
@brief: Allows users to access camera's latest pose. The
correctness of the pose depends on value obtained from
QueryTrackingAccuracy.
@param[out] pose: Array of 12 Single to store camera pose in
row-major order. Camera pose is specified in a 3 by 4 matrix
[R | T] = [Rotation Matrix | Translation Vector]
where R = [ r11 r12 r13 ]
[ r21 r22 r23 ]
[ r31 r32 r33 ]
T = [ tx ty tz ]
Pose Array Layout = [r11 r12 r13 tx r21 r22 r23 ty r31 r32 r33 tz]
Translation vector is in meters.
@returns: PXCM_STATUS_NO_ERROR, If the function succeeds.
Otherwise error code will be returned.
*/
public pxcmStatus GetCameraPose(Single[] pose)
{
if (pose == null || pose.Length != 12)
return pxcmStatus.PXCM_STATUS_PARAM_UNSUPPORTED;
return PXCMScenePerception_GetCameraPose(instance, pose);
}
/**
@brief: Allows user to check whether the 3D volume was updated
since last call to DoMeshingUpdate(...).
This function is useful for determining when to call
DoMeshingUpdate.
@returns: flag indicating that reconstruction was updated.
*/
public Boolean IsReconstructionUpdated()
{
return PXCMScenePerception_IsReconstructionUpdated(instance);
}
/**
@brief: Allows user to access 2D Projection image of reconstructed
volume from a given camera pose by ray-casting. This function is
optimized for real time performance. It is also useful for
visualizing progress of the Scene Reconstruction. User should
explicitly call Release on PXCMImage after copying the data.
or before making subsequent call to QueryVolumePreview.
@param[in] pose: Array of 12 Singles that stores initial camera pose
user wishes to set in row-major order. Camera pose is specified in a
3 by 4 matrix [R | T] = [Rotation Matrix | Translation Vector]
where R = [ r11 r12 r13 ]
[ r21 r22 r23 ]
[ r31 r32 r33 ]
T = [ tx ty tz ]
Pose Array Layout = [r11 r12 r13 tx r21 r22 r23 ty r31 r32 r33 tz]
Translation vector is in meters.
@returns: Instance of PXCMImage whose content can be used for volume
rendering. Returns null if there is an internal state error or when
the rendering is failed or When an Invalid Pose matrix is passed
*/
public PXCMImage QueryVolumePreview(Single[] pose)
{
if (pose == null || pose.Length != 12)
return null;
IntPtr imgInstance = PXCMScenePerception_QueryVolumePreview(instance, pose);
return new PXCMImage(imgInstance, true);
}
/**
@brief: Reset removes all reconstructed model (volume) information
and the Module will reinitialize the model when next Stream is
passed to the module. It also resets the camera pose to the one
provided. If the pose is not provided then the module will use
default pose if there is no platform IMU on the device and in case
of device with platform IMU the pose will be computed using gravity
vector to align 3D volume with gravity when the next frame is
passed to the module.
However it doesn't Reset instance of PXCMBlockMeshingData created using
PXCMScenePerception.CreatePXCMBlockMeshingData. User should
explicitly call PXCMBlockMeshingData.Reset to stay in sync with the
reconstruction model inside Scene Perception
@param[in] pose: Array of 12 Singles that stores initial camera pose
user wishes to set in row-major order. Camera pose is specified in a
3 by 4 matrix [R | T] = [Rotation Matrix | Translation Vector]
where R = [ r11 r12 r13 ]
[ r21 r22 r23 ]
[ r31 r32 r33 ]
T = [ tx ty tz ]
Pose Array Layout = [r11 r12 r13 tx r21 r22 r23 ty r31 r32 r33 tz]
Translation vector is in meters.
@returns: On success returns PXCM_STATUS_NO_ERROR. Otherwise returns
error code like When an invalid pose argument is passed.
*/
public pxcmStatus Reset(Single[] pose)
{
return PXCMScenePerception_Reset(instance, pose);
}
/**
@brief: Reset removes all reconstructed model (volume) information
and the Module will reinitializes the model when next Stream is
passed to the module. It also resets the camera pose to the one
provided or otherwise uses default initial pose. However If the
platform IMU is detected then the rotation matrix set by Reset will
be modified using gravity vector to align 3D volume with gravity
when the next frame frame is passed to the module And the
translation vector will be retained. If the reset is called without Pose
Platform with IMU then the module will use default translation and
rotation will be obtained based on value of gravity vector when the
next frame is passed.
However it doesn't Reset instance of PXCMBlockMeshingData created using
PXCMScenePerception.CreatePXCMBlockMeshingData. User should
explicitly call PXCMBlockMeshingData.Reset to stay in sync with the
reconstruction model inside Scene Perception
@param[in] pose: Array of 12 Singles that stores initial camera pose
user wishes to set in row-major order. Camera pose is specified in a
3 by 4 matrix [R | T] = [Rotation Matrix | Translation Vector]
where R = [ r11 r12 r13 ]
[ r21 r22 r23 ]
[ r31 r32 r33 ]
T = [ tx ty tz ]
Pose Array Layout = [r11 r12 r13 tx r21 r22 r23 ty r31 r32 r33 tz]
Translation vector is in meters.
@returns: On success returns PXCM_STATUS_NO_ERROR. Otherwise returns
error code like When an invalid pose is argument passed.
*/
public pxcmStatus Reset()
{
Single[] pose = new Single[12];
for (int idx = 0; idx < 12; idx++) pose[idx] = 0;
return Reset(pose);
}
/**
@brief: Is an optional function meant for Expert users. It allows
users to set meshing thresholds for DoMeshingUpdate
The values set by this function will be used by succeeding calls to
DoMeshingUpdate. Sets the thresholds indicating the magnitude of
changes occurring in any block that would be considered significant
for re-meshing.
@param[in] maxDistanceChangeThreshold: If the maximum change in a
block exceeds this value, then the block will be re-meshed. Setting
the value to zero will retrieve all blocks
@param[in] avgDistanceChange: If the average change in a block
exceeds this value, then the block will be re-meshed.
Setting the value to zero will retrieve all blocks
@returns: PXCM_STATUS_NO_ERROR, On success otherwise returns error code
*/
public pxcmStatus SetMeshingThresholds(Single maxDistanceChangeThreshold, Single avgDistanceChangeThreshold)
{
return PXCMScenePerception_SetMeshingThresholds(instance, maxDistanceChangeThreshold, avgDistanceChangeThreshold);
}
/**
@brief: Allows Users to allocate PXCMBlockMeshingData which can be
passed to DoMeshingUpdate. It's user's responsibility to explicitly
release the memory by calling Dispose()
@param[in] maxBlockMesh: Maximum number of Mesh Blocks client can
handle in one update from DoMeshingUpdate, If non-positive value is
passed then it uses the default value. Use
PXCBlockMeshingData::QueryMaxNumberOfBlockMeshes to check the value
@param[in] maxFaces: Maximum number of Faces that client can handle
in one update from DoMeshingUpdate, If non-positive value is passed
then it uses the default value. Use
PXCBlockMeshingData::QueryMaxNumberOfFaces to check the value
@param[in] maxVertices: Maximum number of Vertices that client can
handle in one update from DoMeshingUpdate. If non-positive value is
passed then it uses the default value. Use
PXCBlockMeshingData::QueryMaxNumberOfVertices to check the value
@param[in] bUseColor: Flag Indicating whether user wants
ScenePerception to return Color per vertex in the mesh update. If
set the Color buffer will be created in PXCBlockMeshingData
Otherwise Color Buffer will not be created and any calls made to
PXCBlockMeshingData::QueryVerticesColor() will return NULL
@returns: on success returns valid handle to the instance otherwise returns NULL
*/
public PXCMBlockMeshingData CreatePXCMBlockMeshingData(Int32 maxBlockMesh, Int32 maxVertices, Int32 maxFaces, Boolean useColor)
{
IntPtr mdInstance = PXCMScenePerception_CreatePXCBlockMeshingData(instance, maxBlockMesh, maxVertices, maxFaces, useColor);
return new PXCMBlockMeshingData(mdInstance, true);
}
/**
@brief: Allows Users to allocate PXCMBlockMeshingData which can be
passed to DoMeshingUpdate. It's user's responsibility to explicitly
release the memory by calling Dispose()
@param[in] maxBlockMesh: Maximum number of Mesh Blocks client can
handle in one update from DoMeshingUpdate, If non-positive value is
passed then it uses the default value. Use
PXCBlockMeshingData::QueryMaxNumberOfBlockMeshes to check the value
@param[in] maxFaces: Maximum number of Faces that client can handle
in one update from DoMeshingUpdate, If non-positive value is passed
then it uses the default value. Use
PXCBlockMeshingData::QueryMaxNumberOfFaces to check the value
@param[in] maxVertices: Maximum number of Vertices that client can
handle in one update from DoMeshingUpdate. If non-positive value is
passed then it uses the default value. Use
PXCBlockMeshingData::QueryMaxNumberOfVertices to check the value
@param[in] bUseColor: Flag Indicating whether user wants
ScenePerception to return Color per vertex in the mesh update. If
set the Color buffer will be created in PXCBlockMeshingData
Otherwise Color Buffer will not be created and any calls made to
PXCBlockMeshingData::QueryVerticesColor() will return NULL
@returns: on success returns valid handle to the instance otherwise returns NULL
*/
public PXCMBlockMeshingData CreatePXCMBlockMeshingData(Int32 maxBlockMesh, Int32 maxVertices, Int32 maxFaces)
{
return CreatePXCMBlockMeshingData(maxBlockMesh, maxFaces, maxVertices, true);
}
/**
@brief: Allows Users to allocate PXCMBlockMeshingData which can be
passed to DoMeshingUpdate. It's user's responsibility to explicitly
release the memory by calling Dispose()
@param[in] maxBlockMesh: Maximum number of Mesh Blocks client can
handle in one update from DoMeshingUpdate, If non-positive value is
passed then it uses the default value. Use
PXCBlockMeshingData::QueryMaxNumberOfBlockMeshes to check the value
@param[in] maxFaces: Maximum number of Faces that client can handle
in one update from DoMeshingUpdate, If non-positive value is passed
then it uses the default value. Use
PXCBlockMeshingData::QueryMaxNumberOfFaces to check the value
@param[in] maxVertices: Maximum number of Vertices that client can
handle in one update from DoMeshingUpdate. If non-positive value is
passed then it uses the default value. Use
PXCBlockMeshingData::QueryMaxNumberOfVertices to check the value
@param[in] bUseColor: Flag indicating whether user wants
ScenePerception to return Color per vertex in the mesh update. If
set the Color buffer will be created in PXCBlockMeshingData
Otherwise Color Buffer will not be created and any calls made to
PXCBlockMeshingData::QueryVerticesColor() will return NULL
@returns: on success returns valid handle to the instance otherwise returns NULL
*/
public PXCMBlockMeshingData CreatePXCMBlockMeshingData()
{
return CreatePXCMBlockMeshingData(-1, -1, -1, true);
}
/**
@brief: Performs meshing and hole filling if requested. This
function can be slow if there is a lot of data to be meshed. For
Efficiency reason we recommend running this function on a separate
thread. This call is designed to be thread safe if called in
parallel with ProcessImageAsync.
@param[in] blockMeshingData: Instance of Pre-allocated
PXCBlockMeshingData. Refer
PXCScenePerception::CreatePXCBlockMeshingData For how to allocate
PXCBlockMeshingData
@param[in] fillHoles: Argument to indicate whether to fill holes in
mesh blocks. If set, it will fill missing details in each mesh blocks
that are visible from Scene Perception's camera current pose and
completely surrounded by closed surface(holes) by smooth linear
interpolation of adjacent mesh data.
@param[in] meshingUpdateInfo: Argument to indicate which mesh
data you wish to use
-countOfBlockMeshesRequired: If set, on successful call
this function will set number of block meshes available for
meshing which can be retrieved using QueryNumberOfBlockMeshes()
-blockMeshesRequired: Can only be set to true If
countOfBlockMeshesRequired is set to true otherwise the value is
ignored, If set, on successful call to this function It
will update block meshes array in pBlockMeshingUpdateInfo which can
be retrieved using QueryBlockMeshes()
-countOfVeticesRequired: If set, on successful call this
function, It will set number of Vertices available for meshing
which can be retrieved using QueryNumberOfVertices()
-verticesRequired: Can only be set If
countOfVeticesRequired is set to true otherwise the value is ignored,
If set, on successful call to this function It will update vertices
array in pBlockMeshingUpdateInfo which can be retrieved using
QueryVertices()
-countOfFacesRequired: If set, on successful call this
function, It will set number of Faces available for meshing which
can be retrieved using QueryNumberOfFaces()
-facesRequired: Can only be set, If countOfFacesRequired
is set to true otherwise the value is ignored, If set, on
successful call to this function It will update Faces array in
pBlockMeshingUpdateInfo which can be retrieved using QueryFaces()
-colorsRequired: If set and PXCMBlockMeshingData was created with color, On
success function will fill in colors array which can be accessed using
QueryVerticesColor()
+NOTE: Set Meshing Threshold to (0, 0) prior to calling DoMeshingUpdate
with hole filling enabled to fill mesh regions that are not changed.
@returns: On success PXCM_STATUS_NO_ERROR otherwise error code will
be returned
*/
public pxcmStatus DoMeshingUpdate(PXCMBlockMeshingData pBlockMeshingUpdateInfo, Boolean bFillHoles)
{
return PXCMScenePerception_DoMeshingUpdate(instance, pBlockMeshingUpdateInfo.instance, bFillHoles);
}
/**
@brief: Performs meshing and hole filling if requested. This
function can be slow if there is a lot of data to be meshed. For
Efficiency reason we recommend running this function on a separate
thread. This call is designed to be thread safe if called in
parallel with ProcessImageAsync.
@param[in] blockMeshingData: Instance of Pre-allocated
PXCBlockMeshingData. Refer
PXCScenePerception::CreatePXCBlockMeshingData For how to allocate
PXCBlockMeshingData
@param[in] fillHoles: Argument to indicate whether to fill holes in
mesh blocks
@param[in] meshingUpdateInfo: Argument to indicate which mesh
data you wish to use
-countOfBlockMeshesRequired: If set, on successful call
this function will set number of block meshes available for
meshing which can be retrieved using QueryNumberOfBlockMeshes()
-blockMeshesRequired: Can only be set to true If
countOfBlockMeshesRequired is set to true otherwise the value is
ignored, If set, on successful call to this function It
will update block meshes array in pBlockMeshingUpdateInfo which can
be retrieved using QueryBlockMeshes()
-countOfVeticesRequired: If set, on successful call this
function, It will set number of Vertices available for meshing
which can be retrieved using QueryNumberOfVertices()
-verticesRequired: Can only be set If
countOfVeticesRequired is set to true otherwise the value is ignored,
If set, on successful call to this function It will update vertices
array in pBlockMeshingUpdateInfo which can be retrieved using
QueryVertices()
-countOfFacesRequired: If set, on successful call this
function, It will set number of Faces available for meshing which
can be retrieved using QueryNumberOfFaces()
-facesRequired: Can only be set, If countOfFacesRequired
is set to true otherwise the value is ignored, If set, on
successful call to this function It will update Faces array in
pBlockMeshingUpdateInfo which can be retrieved using QueryFaces()
-colorsRequired: If set and PXCMBlockMeshingData was created with color, On
success function will fill in colors array which can be accessed using
QueryVerticesColor()
@returns: On success PXCM_STATUS_NO_ERROR otherwise error code will
be returned
*/
public pxcmStatus DoMeshingUpdate(PXCMBlockMeshingData pBlockMeshingUpdateInfo)
{
return DoMeshingUpdate(pBlockMeshingUpdateInfo, false);
}
/**
@brief: Allow users to save mesh in an ASCII obj file in
MeshResolution::HIGH_RESOLUTION_MESH.
@param[in] pFile: the path of the file to use for saving the mesh
@param[in] bFillHoles: Indicates whether to fill holes in mesh
before saving the mesh
@returns: On success PXCM_STATUS_NO_ ERROR, Otherwise error code is
returned on failure
*/
public pxcmStatus SaveMesh(String fileName, Boolean fillHoles)
{
return PXCMScenePerception_SaveMesh(instance, fileName, fillHoles);
}
/**
@brief: Allow users to save mesh in an ASCII obj file in
MeshResolution::HIGH_RESOLUTION_MESH.
@param[in] pFile: the path of the file to use for saving the mesh
@param[in] bFillHoles: Indicates whether to fill holes in mesh
before saving the mesh
@returns: On success PXCM_STATUS_NO_ ERROR, Otherwise error code is
returned on failure
*/
public pxcmStatus SaveMesh(String fileName)
{
return SaveMesh(fileName, false);
}
/**
@brief: Allows user to check whether the input Stream is suitable
for starting Scene Perception or not. We recommend using this
function when ScenePerceptin module is paused. User can pause
Scene Perception module using PXCMSenseManager.PauseScenePerception().
This function should only be used as initializer to help user to determine
When to start or reset scene Perception.
@param[in] PXCMCapture.Sample: Input stream sample required by
Scene Perception module.
@returns: Returns a value between 0.0 and 1.0 where:
1.0 - represents ideal Scene for starting Scene Perception.
0.0 - represents unsuitable Scene for
starting Scene Perception.
*/
public Single CheckSceneQuality(PXCMCapture.Sample sample)
{
return PXCMScenePerception_CheckSceneQuality(instance, sample);
}
/**
@brief: Fills holes in the supplied depth image.
@param[in] depthImage: Instance of depth image to be filled.
Pixels with depth value equal to zero will be linearly interpolated
with adjacent depth pixels. The image resolution should be 320X240
@returns: On Success PXCM_STATUS_NO_ERROR,
Otherwise error code will be returned on failure
*/
public pxcmStatus FillDepthImage(PXCMImage depthImage)
{
return PXCMScenePerception_FillDepthImage(instance, depthImage.instance);
}
/**
@brief: Allows users to access normals of surface that are within
view from the camera's current pose.
@param[out] normals: Array of pre-allocated PXCMPoint3DF32 to store
normal vectors. Each normal vector has three components namely x, y
and z. The size in pixels must be QVGA and hence the array size in
bytes should be: (PXCMPoint3DF32's byte size) x (320 x 240)
@returns: On success PXCM_STATUS_NO_ERROR,
Otherwise error code will be returned on failure
*/
public pxcmStatus GetNormals(PXCMPoint3DF32[] normals)
{
return PXCMScenePerception_GetNormals(instance, normals);
}
/**
@brief: Allows Users to access the surface's vertices
that are within view from camera's current pose.
@param[out] vertices: Array of pre-allocated PXCMPoint3DF32 to store
vertices. Each element is a vector of x, y and z components. The
image size in pixels must be QVGA and hence the array
size in bytes should be: (PXCMPoint3DF32's byte size) x (320 x 240)
@returns: On success PXCM_STATUS_NO_ERROR,
Otherwise error code will be returned on failure
*/
public pxcmStatus GetVertices(PXCMPoint3DF32[] vertices)
{
return PXCMScenePerception_GetVertices(instance, vertices);
}
/**
@brief: Allows user to Save the current scene perception's state to
a file and later supply the file to LoadState() to restore Scene
Perception to the saved state.
@param[in] fileName: The path of the file to use for saving the
scene perception state
@returns: On success PXCM_STATUS_NO_ERROR,
Otherwise error code will be returned on failure
*/
public pxcmStatus SaveCurrentState(String fileName)
{
return PXCMScenePerception_SaveCurrentState(instance, fileName);
}
/**
@brief: Allows user to load the current scene perception's state
from the file that has been created using SaveCurrentState.
This function is only available before calling
PXCSenseManager::Init(). The PXCMSenseManager.Init() would fail
If you use different camera than what was used when SaveCurrentState
was called.
@param[in] fileName: The path of the file to load Scene Perception
state from.
@returns: On success PXCM_STATUS_NO_ERROR,
Otherwise error code will be returned on failure
*/
public pxcmStatus LoadState(String fileName)
{
return PXCMScenePerception_LoadState(instance, fileName);
}