forked from microsoft/Azure-Kinect-Sensor-SDK
-
Notifications
You must be signed in to change notification settings - Fork 7
/
k4a.h
2410 lines (2330 loc) · 89.4 KB
/
k4a.h
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
/** \file k4a.h
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
* Kinect For Azure SDK.
*/
#ifndef K4A_H
#define K4A_H
#ifdef __cplusplus
#include <cinttypes>
#else
#include <inttypes.h>
#endif
#include <k4a/k4aversion.h>
#include <k4a/k4atypes.h>
#include <k4a/k4a_export.h>
#ifdef __cplusplus
extern "C" {
#endif
#define WRAPPER_VERSION_MAJOR 1
#define WRAPPER_VERSION_MINOR 10
#define WRAPPER_VERSION_PATCH 2
/**
* \defgroup Functions Functions
* \ingroup csdk
*
* Public functions of the API
*
* @{
*/
/** get device pid
*
* \remarks This API is currently mainly used to get device pid
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT int k4a_device_get_pid(k4a_device_t device);
/** get device sync mode
*
* \remarks This API is currently mainly used to get device sync mode
*
* \remarks The device synchronization mode will change according to the mode configured in the start_cameras function
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT k4a_wired_sync_mode_t k4a_device_get_wired_sync_mode(k4a_device_t device);
/** enable/disable soft filter for depth camera
*
* \param device_handle
* Output parameter which on success will return a handle to the device.
*
* \param enable
* Device software filtering switch
*
* \remarks This API is used to set filtering.
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT k4a_result_t k4a_device_enable_soft_filter(k4a_device_t device_handle, bool enable);
/** switch device clock sync mode
*
* \param device_handle
* Output parameter which on success will return a handle to the device.
*
* \param timestamp_mode
* Device clock synchronization mode
*
* \param param
* If timestamp_mode is K4A_DEVICE_CLOCK_SYNC_MODE_RESET: The delay time of executing the timestamp reset function after receiving the command or signal in microseconds.
* If timestamp_mode is K4A_DEVICE_CLOCK_SYNC_MODE_SYNC: The interval for auto-repeated synchronization, in microseconds. If the value is 0, synchronization is performed only once.
*
* \remarks This API is used for device clock synchronization mode switching.
*
* \remarks It is necessary to ensure that the mode switching of all devices is completed before any device start_cameras.
*
* \remarks It is necessary to ensure that the master and slave devices are configured in the same mode.
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT k4a_result_t k4a_device_switch_device_clock_sync_mode(k4a_device_t device_handle, k4a_device_clock_sync_mode_t timestamp_mode, uint32_t param);
/** create depthengine helper
*
* \remarks This API is currently mainly used to initialize depthengine, This function only needs to be called when on the Linux platform
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT k4a_result_t k4a_depth_engine_helper_create(k4a_depthengine_t* handle);
/** release depthengine helper
*
* \remarks This API is currently mainly used to release depthengine
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT void k4a_depth_engine_helper_release(k4a_depthengine_t handle);
/** Gets the number of connected devices
*
* \returns Number of sensors connected to the PC.
*
* \relates k4a_device_t
*
* \remarks
* This API counts the number of Azure Kinect devices connected to the host PC.
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT uint32_t k4a_device_get_installed_count(void);
/** Sets and clears the callback function to receive debug messages from the Azure Kinect device.
*
* \param message_cb
* The callback function to receive messages from. Set to NULL to unregister the callback function.
*
* \param message_cb_context
* The callback functions context.
*
* \param min_level
* The least critical error the user wants to be notified about.
*
* \return ::K4A_RESULT_SUCCEEDED if the callback function was set or cleared successfully. ::K4A_RESULT_FAILED if an
* error is encountered or the callback function has already been set.
*
* \remarks
* Call this function to set or clear the callback function that is used to deliver debug messages to the caller. This
* callback may be called concurrently, it is up to the implementation of the callback function to ensure the
* parallelization is handled.
*
* \remarks
* Clearing the callback function will block until all pending calls to the callback function have completed.
*
* \remarks
* To update \p min_level, \p k4a_set_debug_message_handler can be called with the same value \p message_cb and by
* specifying a new \p min_level.
*
* \remarks
* Logging provided via this API is independent of the logging controlled by the environmental variable controls \p
* K4A_ENABLE_LOG_TO_STDOUT, \p K4A_ENABLE_LOG_TO_A_FILE, and \p K4A_LOG_LEVEL. However there is a slight change in
* default behavior when using this function. By default, when \p k4a_set_debug_message_handler() has not been used to
* register a message callback, the default for environmental variable controls is to send debug messages as if
* K4A_ENABLE_LOG_TO_STDOUT=1 were set. If \p k4a_set_debug_message_handler registers a callback function before
* k4a_device_open() is called, then the default for environmental controls is as if K4A_ENABLE_LOG_TO_STDOUT=0 was
* specified. Physically specifying the environmental control will override the default.
*
* \p min_level
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT k4a_result_t k4a_set_debug_message_handler(k4a_logging_message_cb_t *message_cb,
void *message_cb_context,
k4a_log_level_t min_level);
/** Sets the callback functions for the SDK allocator
*
* \attention For the Orbbec SDK K4A wrapper, this function is not yet supported.
*
* \param allocate
* The callback function to allocate memory. When the SDK requires memory allocation this callback will be
* called and the application can provide a buffer and a context.
*
* \param free
* The callback function to free memory. The SDK will call this function when memory allocated by \p allocate
* is no longer needed.
*
* \return ::K4A_RESULT_SUCCEEDED if the callback function was set or cleared successfully. ::K4A_RESULT_FAILED if an
* error is encountered or the callback function has already been set.
*
* \remarks
* Call this function to hook memory allocation by the SDK. Calling with both \p allocate and \p free as NULL will
* clear the hook and reset to the default allocator.
*
* \remarks
* If this function is called after memory has been allocated, the previous version of \p free function may still be
* called in the future. The SDK will always call the \p free function that was set at the time that the memory
* was allocated.
*
* \remarks
* Not all memory allocation by the SDK is performed by this allocate function. Small allocations or allocations
* from special pools may come from other sources.
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT k4a_result_t k4a_set_allocator(k4a_memory_allocate_cb_t allocate, k4a_memory_destroy_cb_t free);
/** Open an Azure Kinect device.
*
* \param index
* The index of the device to open, starting with 0. Optionally pass in #K4A_DEVICE_DEFAULT.
*
* \param device_handle
* Output parameter which on success will return a handle to the device.
*
* \relates k4a_device_t
*
* \return ::K4A_RESULT_SUCCEEDED if the device was opened successfully.
*
* \remarks
* If successful, k4a_device_open() will return a device handle in the device_handle parameter.
* This handle grants exclusive access to the device and may be used in the other Azure Kinect API calls.
*
* \remarks
* When done with the device, close the handle with k4a_device_close()
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT k4a_result_t k4a_device_open(uint32_t index, k4a_device_t *device_handle);
/** Closes an Azure Kinect device.
*
* \param device_handle
* Handle obtained by k4a_device_open().
*
* \relates k4a_device_t
*
* \remarks Once closed, the handle is no longer valid.
*
* \remarks Before closing the handle to the device, ensure that all \ref k4a_capture_t captures have been released with
* k4a_capture_release().
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT void k4a_device_close(k4a_device_t device_handle);
/** Reads a sensor capture.
*
* \param device_handle
* Handle obtained by k4a_device_open().
*
* \param capture_handle
* If successful this contains a handle to a capture object. Caller must call k4a_capture_release() when its done using
* this capture.
*
* \param timeout_in_ms
* Specifies the time in milliseconds the function should block waiting for the capture. If set to 0, the function will
* return without blocking. Passing a value of #K4A_WAIT_INFINITE will block indefinitely until data is available, the
* device is disconnected, or another error occurs.
*
* \returns
* ::K4A_WAIT_RESULT_SUCCEEDED if a capture is returned. If a capture is not available before the timeout elapses, the
* function will return ::K4A_WAIT_RESULT_TIMEOUT. All other failures will return ::K4A_WAIT_RESULT_FAILED.
*
* \relates k4a_device_t
*
* \remarks
* Gets the next capture in the streamed sequence of captures from the camera. If a new capture is not currently
* available, this function will block until the timeout is reached. The SDK will buffer at least two captures worth
* of data before dropping the oldest capture. Callers needing to capture all data need to ensure they read the data as
* fast as the data is being produced on average.
*
* \remarks
* Upon successfully reading a capture this function will return success and populate \p capture.
* If a capture is not available in the configured \p timeout_in_ms, then the API will return ::K4A_WAIT_RESULT_TIMEOUT.
*
* \remarks
* If the call is successful and a capture is returned, callers must call k4a_capture_release() to return the allocated
* memory.
*
* \remarks
* This function needs to be called while the device is in a running state;
* after k4a_device_start_cameras() is called and before k4a_device_stop_cameras() is called.
*
* \remarks
* This function returns an error when an internal problem is encountered; such as loss of the USB connection, inability
* to allocate enough memory, and other unexpected issues. Any error returned by this function signals the end of
* streaming data, and caller should stop the stream using k4a_device_stop_cameras().
*
* \remarks
* If this function is waiting for data (non-zero timeout) when k4a_device_stop_cameras() or k4a_device_close() is
* called on another thread, this function will return an error.
*
* \returns ::K4A_WAIT_RESULT_SUCCEEDED if a capture is returned. If a capture is not available before the timeout
* elapses, the function will return ::K4A_WAIT_RESULT_TIMEOUT. All other failures will return ::K4A_WAIT_RESULT_FAILED.
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*
*/
K4A_EXPORT k4a_wait_result_t k4a_device_get_capture(k4a_device_t device_handle,
k4a_capture_t *capture_handle,
int32_t timeout_in_ms);
/** Reads an IMU sample.
*
* \param device_handle
* Handle obtained by k4a_device_open().
*
* \param imu_sample
* Pointer to the location for the API to write the IMU sample.
*
* \param timeout_in_ms
* Specifies the time in milliseconds the function should block waiting for the sample. If set to 0, the function will
* return without blocking. Passing a value of #K4A_WAIT_INFINITE will block indefinitely until data is available, the
* device is disconnected, or another error occurs.
*
* \returns
* ::K4A_WAIT_RESULT_SUCCEEDED if a sample is returned. If a sample is not available before the timeout elapses, the
* function will return ::K4A_WAIT_RESULT_TIMEOUT. All other failures will return ::K4A_WAIT_RESULT_FAILED.
*
* \relates k4a_device_t
*
* \remarks
* Gets the next sample in the streamed sequence of IMU samples from the device. If a new sample is not currently
* available, this function will block until the timeout is reached. The API will buffer at least two camera capture
* intervals worth of samples before dropping the oldest sample. Callers needing to capture all data need to ensure they
* read the data as fast as the data is being produced on average.
*
* \remarks
* Upon successfully reading a sample this function will return success and populate \p imu_sample.
* If a sample is not available in the configured \p timeout_in_ms, then the API will return ::K4A_WAIT_RESULT_TIMEOUT.
*
* \remarks
* This function needs to be called while the device is in a running state;
* after k4a_device_start_imu() is called and before k4a_device_stop_imu() is called.
*
* \remarks
* This function returns an error when an internal problem is encountered; such as loss of the USB connection, inability
* to allocate enough memory, and other unexpected issues. Any error returned by this function signals the end of
* streaming data, and caller should stop the stream using k4a_device_stop_imu().
*
* \remarks
* If this function is waiting for data (non-zero timeout) when k4a_device_stop_imu() or k4a_device_close() is
* called on another thread, this function will return an error.
*
* \remarks
* The memory the IMU sample is written to is allocated and owned by the caller, so there is no need to call an Azure
* Kinect API to free or release the sample.
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT k4a_wait_result_t k4a_device_get_imu_sample(k4a_device_t device_handle,
k4a_imu_sample_t *imu_sample,
int32_t timeout_in_ms);
/** Create an empty capture object.
*
* \param capture_handle
* Pointer to a location to store the handle.
*
* \relates k4a_capture_t
*
* \remarks
* Call this function to create a \ref k4a_capture_t handle for a new capture. Release it with k4a_capture_release().
*
* The new capture is created with a reference count of 1.
*
* \returns
* Returns #K4A_RESULT_SUCCEEDED on success. Errors are indicated with #K4A_RESULT_FAILED and error specific data can be
* found in the log.
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT k4a_result_t k4a_capture_create(k4a_capture_t *capture_handle);
/** Release a capture.
*
* \param capture_handle
* Capture to release.
*
* \relates k4a_capture_t
*
* \remarks
* Call this function when finished using the capture.
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT void k4a_capture_release(k4a_capture_t capture_handle);
/** Add a reference to a capture.
*
* \param capture_handle
* Capture to add a reference to.
*
* \relates k4a_capture_t
*
* \remarks
* Call this function to add an additional reference to a capture. This reference must be removed with
* k4a_capture_release().
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT void k4a_capture_reference(k4a_capture_t capture_handle);
/** Get the color image associated with the given capture.
*
* \param capture_handle
* Capture handle containing the image.
*
* \relates k4a_capture_t
*
* \remarks
* Call this function to access the color image part of this capture. Release the \ref k4a_image_t with
* k4a_image_release();
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT k4a_image_t k4a_capture_get_color_image(k4a_capture_t capture_handle);
/** Get the depth image associated with the given capture.
*
* \param capture_handle
* Capture handle containing the image.
*
* \relates k4a_capture_t
*
* \remarks
* Call this function to access the depth image part of this capture. Release the \ref k4a_image_t with
* k4a_image_release();
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT k4a_image_t k4a_capture_get_depth_image(k4a_capture_t capture_handle);
/** Get the IR image associated with the given capture.
*
* \param capture_handle
* Capture handle containing the image.
*
* \relates k4a_capture_t
*
* \remarks
* Call this function to access the IR image part of this capture. Release the \ref k4a_image_t with
* k4a_image_release();
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT k4a_image_t k4a_capture_get_ir_image(k4a_capture_t capture_handle);
/** Set or add a color image to the associated capture.
*
* \param capture_handle
* Capture handle to hold the image.
*
* \param image_handle
* Image handle containing the image.
*
* \relates k4a_capture_t
*
* \remarks
* When a \ref k4a_image_t is added to a \ref k4a_capture_t, the \ref k4a_capture_t will automatically add a reference
* to the \ref k4a_image_t.
*
* \remarks
* If there is already a color image contained in the capture, the existing image will be dereferenced and replaced with
* the new image.
*
* \remarks
* To remove a color image to the capture without adding a new image, this function can be called with a NULL
* image_handle.
*
* \remarks
* Any \ref k4a_image_t contained in this \ref k4a_capture_t will automatically be dereferenced when all references to
* the \ref k4a_capture_t are released with k4a_capture_release().
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT void k4a_capture_set_color_image(k4a_capture_t capture_handle, k4a_image_t image_handle);
/** Set or add a depth image to the associated capture.
*
* \param capture_handle
* Capture handle to hold the image.
*
* \param image_handle
* Image handle containing the image.
*
* \relates k4a_capture_t
*
* \remarks
* When a \ref k4a_image_t is added to a \ref k4a_capture_t, the \ref k4a_capture_t will automatically add a reference
* to the \ref k4a_image_t.
*
* \remarks
* If there is already an image depth image contained in the capture, the existing image will be dereferenced and
* replaced with the new image.
*
* \remarks
* To remove a depth image to the capture without adding a new image, this function can be called with a NULL
* image_handle.
*
* \remarks
* Any \ref k4a_image_t contained in this \ref k4a_capture_t will automatically be dereferenced when all references to
* the \ref k4a_capture_t are released with k4a_capture_release().
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT void k4a_capture_set_depth_image(k4a_capture_t capture_handle, k4a_image_t image_handle);
/** Set or add an IR image to the associated capture.
*
* \param capture_handle
* Capture handle to hold the image.
*
* \param image_handle
* Image handle containing the image.
*
* \relates k4a_capture_t
*
* \remarks
* When a \ref k4a_image_t is added to a \ref k4a_capture_t, the \ref k4a_capture_t will automatically add a reference
* to the \ref k4a_image_t.
*
* \remarks
* If there is already an IR image contained in the capture, the existing image will be dereferenced and replaced with
* the new image.
*
* \remarks
* To remove a IR image to the capture without adding a new image, this function can be called with a NULL image_handle.
*
* \remarks
* Any \ref k4a_image_t contained in this \ref k4a_capture_t will automatically be dereferenced when all references to
* the \ref k4a_capture_t are released with k4a_capture_release().
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT void k4a_capture_set_ir_image(k4a_capture_t capture_handle, k4a_image_t image_handle);
/** Set the temperature associated with the capture.
*
* \attention For the Orbbec SDK K4A wrapper, this function is not yet supported.
*
* \param capture_handle
* Capture handle to set the temperature on.
*
* \param temperature_c
* Temperature in Celsius to store.
*
* \relates k4a_capture_t
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT void k4a_capture_set_temperature_c(k4a_capture_t capture_handle, float temperature_c);
/** Get the temperature associated with the capture.
*
* \attention For the Orbbec SDK K4A wrapper, this function is not yet supported.
*
* \param capture_handle
* Capture handle to retrieve the temperature from.
*
* \return
* This function returns the temperature of the device at the time of the capture in Celsius. If
* the temperature is unavailable, the function will return NAN.
*
* \relates k4a_capture_t
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT float k4a_capture_get_temperature_c(k4a_capture_t capture_handle);
/** Create an image.
*
* \param format
* The format of the image that will be stored in this image container.
*
* \param width_pixels
* Width in pixels.
*
* \param height_pixels
* Height in pixels.
*
* \param stride_bytes
* The number of bytes per horizontal line of the image.
* If set to 0, the stride will be set to the minimum size given the \p format and \p width_pixels.
*
* \param image_handle
* Pointer to store image handle in.
*
* \remarks
* This function is used to create images of formats that have consistent stride. The function is not suitable for
* compressed formats that may not be represented by the same number of bytes per line.
*
* \remarks
* For most image formats, the function will allocate an image buffer of size \p height_pixels * \p stride_bytes.
* Buffers #K4A_IMAGE_FORMAT_COLOR_NV12 format will allocate an additional \p height_pixels / 2 set of lines (each of \p
* stride_bytes). This function cannot be used to allocate #K4A_IMAGE_FORMAT_COLOR_MJPG buffers.
*
* \remarks
* To create an image object without the API allocating memory, or to represent an image that has a non-deterministic
* stride, use k4a_image_create_from_buffer().
*
* \remarks
* The \ref k4a_image_t is created with a reference count of 1.
*
* \remarks
* When finished using the created image, release it with k4a_image_release.
*
* \returns
* Returns #K4A_RESULT_SUCCEEDED on success. Errors are indicated with #K4A_RESULT_FAILED.
*
* \relates k4a_image_t
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT k4a_result_t k4a_image_create(k4a_image_format_t format,
int width_pixels,
int height_pixels,
int stride_bytes,
k4a_image_t *image_handle);
/** Create an image from a pre-allocated buffer.
*
* \param format
* The format of the image that will be stored in this image container.
*
* \param width_pixels
* Width in pixels.
*
* \param height_pixels
* Height in pixels.
*
* \param stride_bytes
* The number of bytes per horizontal line of the image.
*
* \param buffer
* Pointer to a pre-allocated image buffer.
*
* \param buffer_size
* Size in bytes of the pre-allocated image buffer.
*
* \param buffer_release_cb
* Callback to the buffer free function, called when all references to the buffer have been released. This parameter is
* optional.
*
* \param buffer_release_cb_context
* Context for the buffer free function. This value will be called as a parameter to \p buffer_release_cb when
* the callback is invoked.
*
* \param image_handle
* Pointer to store image handle in.
*
* \remarks
* This function creates a \ref k4a_image_t from a pre-allocated buffer. When all references to this object reach zero
* the provided \p buffer_release_cb callback function is called so that the memory can be released. If this function
* fails, the API will not use the memory provided in \p buffer, and the API will not call \p buffer_release_cb.
*
* \remarks
* The \ref k4a_image_t is created with a reference count of 1.
*
* \remarks
* Release the reference on this function with k4a_image_release().
*
* \returns
* Returns #K4A_RESULT_SUCCEEDED on success. Errors are indicated with #K4A_RESULT_FAILED and error specific data can be
* found in the log.
*
* \relates k4a_image_t
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT k4a_result_t k4a_image_create_from_buffer(k4a_image_format_t format,
int width_pixels,
int height_pixels,
int stride_bytes,
uint8_t *buffer,
size_t buffer_size,
k4a_memory_destroy_cb_t *buffer_release_cb,
void *buffer_release_cb_context,
k4a_image_t *image_handle);
/** Get the image buffer.
*
* \param image_handle
* Handle of the image for which the get operation is performed on.
*
* \remarks
* Use this buffer to access the raw image data.
*
* \returns
* The function will return NULL if there is an error, and will normally return a pointer to the image buffer.
* Since all \ref k4a_image_t instances are created with an image buffer, this function should only return NULL if the
* \p image_handle is invalid.
*
* \relates k4a_image_t
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT uint8_t *k4a_image_get_buffer(k4a_image_t image_handle);
/** Get the image buffer size.
*
* \param image_handle
* Handle of the image for which the get operation is performed on.
*
* \remarks
* Use this function to know what the size of the image buffer is returned by k4a_image_get_buffer().
*
* \returns
* The function will return 0 if there is an error, and will normally return the image size.
* Since all \ref k4a_image_t instances are created with an image buffer, this function should only return 0 if the
* \p image_handle is invalid.
*
* \relates k4a_image_t
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT size_t k4a_image_get_size(k4a_image_t image_handle);
/** Get the format of the image.
*
* \param image_handle
* Handle of the image for which the get operation is performed on.
*
* \remarks
* Use this function to determine the format of the image buffer.
*
* \returns
* This function is not expected to fail, all \ref k4a_image_t's are created with a known format. If the
* \p image_handle is invalid, the function will return ::K4A_IMAGE_FORMAT_CUSTOM.
*
* \relates k4a_image_t
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT k4a_image_format_t k4a_image_get_format(k4a_image_t image_handle);
/** Get the image width in pixels.
*
* \param image_handle
* Handle of the image for which the get operation is performed on.
*
* \returns
* This function is not expected to fail, all \ref k4a_image_t's are created with a known width. If the \p
* image_handle is invalid, the function will return 0.
*
* \relates k4a_image_t
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT int k4a_image_get_width_pixels(k4a_image_t image_handle);
/** Get the image height in pixels.
*
* \param image_handle
* Handle of the image for which the get operation is performed on.
*
* \returns
* This function is not expected to fail, all \ref k4a_image_t's are created with a known height. If the \p
* image_handle is invalid, the function will return 0.
*
* \relates k4a_image_t
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT int k4a_image_get_height_pixels(k4a_image_t image_handle);
/** Get the image stride in bytes.
*
* \param image_handle
* Handle of the image for which the get operation is performed on.
*
* \returns
* This function is not expected to fail, all \ref k4a_image_t's are created with a known stride. If the
* \p image_handle is invalid, or the image's format does not have a stride, the function will return 0.
*
* \relates k4a_image_t
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT int k4a_image_get_stride_bytes(k4a_image_t image_handle);
/** Get the image's device timestamp in microseconds.
*
* \param image_handle
* Handle of the image for which the get operation is performed on.
*
* \remarks
* Returns the device timestamp of the image. Timestamps are recorded by the device and represent the mid-point of
* exposure. They may be used for relative comparison, but their absolute value has no defined meaning.
*
* \returns
* If the \p image_handle is invalid or if no timestamp was set for the image,
* this function will return 0. It is also possible for 0 to be a valid timestamp originating from the beginning
* of a recording or the start of streaming.
*
* \deprecated
* Deprecated starting in 1.2.0. Please use k4a_image_get_device_timestamp_usec().
*
* \relates k4a_image_t
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_DEPRECATED_EXPORT uint64_t k4a_image_get_timestamp_usec(k4a_image_t image_handle);
/** Get the image's device timestamp in microseconds.
*
* \param image_handle
* Handle of the image for which the get operation is performed on.
*
* \remarks
* Returns the device timestamp of the image, as captured by the hardware. Timestamps are recorded by the device and
* represent the mid-point of exposure. They may be used for relative comparison, but their absolute value has no
* defined meaning.
*
* \returns