OrbbecSDK 2.5.5
OrbbecSDK: Software-Development-Kit for Orbbec 3D Cameras
Loading...
Searching...
No Matches
Frame.hpp
Go to the documentation of this file.
1// Copyright (c) Orbbec Inc. All Rights Reserved.
2// Licensed under the MIT License.
3
9#pragma once
10
11#include "Types.hpp"
12#include "libobsensor/h/Frame.h"
15#include <memory>
16#include <iostream>
17#include <typeinfo>
18#include <functional>
19
36
37namespace ob {
38class Device;
39class Sensor;
40
45class Frame : public std::enable_shared_from_this<Frame> {
46protected:
50 const ob_frame *impl_ = nullptr;
51
52public:
62 explicit Frame(const ob_frame *impl) : impl_(impl) {}
63
69 const ob_frame *getImpl() const {
70 return impl_;
71 }
72
76 virtual ~Frame() noexcept {
77 if(impl_) {
78 ob_error *error = nullptr;
79 ob_delete_frame(impl_, &error);
80 Error::handle(&error, false);
81 impl_ = nullptr;
82 }
83 }
84
90 virtual OBFrameType getType() const {
91 ob_error *error = nullptr;
92 auto type = ob_frame_get_type(impl_, &error);
93 Error::handle(&error);
94
95 return type;
96 }
97
103 virtual OBFormat getFormat() const {
104 ob_error *error = nullptr;
105 auto format = ob_frame_get_format(impl_, &error);
106 Error::handle(&error);
107
108 return format;
109 }
110
118 virtual uint64_t getIndex() const {
119 ob_error *error = nullptr;
120 auto index = ob_frame_get_index(impl_, &error);
121 Error::handle(&error);
122
123 return index;
124 }
125
131 virtual uint8_t *getData() const {
132 ob_error *error = nullptr;
133 auto data = ob_frame_get_data(impl_, &error);
134 Error::handle(&error);
135
136 return data;
137 }
138
146 virtual uint32_t getDataSize() const {
147 ob_error *error = nullptr;
148 auto dataSize = ob_frame_get_data_size(impl_, &error);
149 Error::handle(&error);
150
151 return dataSize;
152 }
153
160 uint64_t getTimeStampUs() const {
161 ob_error *error = nullptr;
163 Error::handle(&error);
164
165 return timeStampUs;
166 }
167
174 uint64_t getSystemTimeStampUs() const {
175 ob_error *error = nullptr;
177 Error::handle(&error);
178
179 return systemTimeStampUs;
180 }
181
193 uint64_t getGlobalTimeStampUs() const {
194 ob_error *error = nullptr;
196 Error::handle(&error);
197
198 return globalTimeStampUs;
199 }
200
206 uint8_t *getMetadata() const {
207 ob_error *error = nullptr;
208 auto metadata = ob_frame_get_metadata(impl_, &error);
209 Error::handle(&error);
210
211 return metadata;
212 }
213
219 uint32_t getMetadataSize() const {
220 ob_error *error = nullptr;
222 Error::handle(&error);
223
224 return metadataSize;
225 }
226
234 ob_error *error = nullptr;
235 auto result = ob_frame_has_metadata(impl_, type, &error);
236 Error::handle(&error);
237
238 return result;
239 }
240
248 ob_error *error = nullptr;
249 auto value = ob_frame_get_metadata_value(impl_, type, &error);
250 Error::handle(&error);
251
252 return value;
253 }
254
260 std::shared_ptr<StreamProfile> getStreamProfile() const {
261 ob_error *error = nullptr;
262 auto profile = ob_frame_get_stream_profile(impl_, &error);
263 Error::handle(&error);
264 return StreamProfileFactory::create(profile);
265 }
266
272 std::shared_ptr<Sensor> getSensor() const {
273 ob_error *error = nullptr;
274 auto sensor = ob_frame_get_sensor(impl_, &error);
275 Error::handle(&error);
276
277 return std::make_shared<Sensor>(sensor);
278 }
279
285 std::shared_ptr<Device> getDevice() const {
286 ob_error *error = nullptr;
287 auto device = ob_frame_get_device(impl_, &error);
288 Error::handle(&error);
289
290 return std::make_shared<Device>(device);
291 }
292
299 template <typename T> bool is() const;
300
307 template <typename T> std::shared_ptr<T> as() {
308 if(!is<T>()) {
309 throw std::runtime_error("unsupported operation, object's type is not require type");
310 }
311
312 ob_error *error = nullptr;
313 ob_frame_add_ref(impl_, &error);
314 Error::handle(&error);
315
316 return std::make_shared<T>(impl_);
317 }
318
325 template <typename T> std::shared_ptr<const T> as() const {
326 if(!is<const T>()) {
327 throw std::runtime_error("unsupported operation, object's type is not require type");
328 }
329
330 ob_error *error = nullptr;
331 ob_frame_add_ref(impl_, &error);
332 Error::handle(&error);
333
334 return std::make_shared<const T>(impl_);
335 }
336
337public:
338 // The following interfaces are deprecated and are retained here for compatibility purposes.
340 return getType();
341 }
342
343 virtual OBFormat format() const {
344 return getFormat();
345 }
346
347 virtual uint64_t index() const {
348 return getIndex();
349 }
350
351 virtual void *data() const {
352 auto data = getData();
353 return reinterpret_cast<void *>(data);
354 }
355
356 virtual uint32_t dataSize() const {
357 return getDataSize();
358 }
359
360 uint64_t timeStamp() const {
361 return getTimeStampUs() / 1000;
362 }
363
364 uint64_t timeStampUs() const {
365 return getTimeStampUs();
366 }
367
368 uint64_t systemTimeStamp() const {
369 return getSystemTimeStampUs() / 1000;
370 }
371
372 uint64_t systemTimeStampUs() const {
373 return getSystemTimeStampUs();
374 }
375
376 uint64_t globalTimeStampUs() const {
377 return getGlobalTimeStampUs();
378 }
379
380 uint8_t *metadata() const {
381 return getMetadata();
382 }
383
384 uint32_t metadataSize() const {
385 return getMetadataSize();
386 }
387};
388
392class VideoFrame : public Frame {
393public:
403 explicit VideoFrame(const ob_frame *impl) : Frame(impl) {};
404
405 ~VideoFrame() noexcept override = default;
406
412 uint32_t getWidth() const {
413 ob_error *error = nullptr;
414 auto width = ob_video_frame_get_width(impl_, &error);
415 Error::handle(&error);
416
417 return width;
418 }
419
425 uint32_t getHeight() const {
426 ob_error *error = nullptr;
427 auto height = ob_video_frame_get_height(impl_, &error);
428 Error::handle(&error);
429
430 return height;
431 }
432
442 ob_error *error = nullptr;
443 auto pixelType = ob_video_frame_get_pixel_type(impl_, &error);
444 Error::handle(&error);
445
446 return pixelType;
447 }
448
455 uint8_t getPixelAvailableBitSize() const {
456 ob_error *error = nullptr;
458 Error::handle(&error);
459
460 return bitSize;
461 }
462
463public:
464 // The following interfaces are deprecated and are retained here for compatibility purposes.
465 uint32_t width() const {
466 return getWidth();
467 }
468
469 uint32_t height() const {
470 return getHeight();
471 }
472
473 uint8_t pixelAvailableBitSize() const {
475 }
476};
477
481class ColorFrame : public VideoFrame {
482public:
493 explicit ColorFrame(const ob_frame *impl) : VideoFrame(impl) {};
494
495 ~ColorFrame() noexcept override = default;
496};
497
501class DepthFrame : public VideoFrame {
502
503public:
514 explicit DepthFrame(const ob_frame *impl) : VideoFrame(impl) {};
515
516 ~DepthFrame() noexcept override = default;
517
525 float getValueScale() const {
526 ob_error *error = nullptr;
527 auto scale = ob_depth_frame_get_value_scale(impl_, &error);
528 Error::handle(&error);
529
530 return scale;
531 }
532};
533
538class IRFrame : public VideoFrame {
539
540public:
551 explicit IRFrame(const ob_frame *impl) : VideoFrame(impl) {};
552
553 ~IRFrame() noexcept override = default;
554};
555
561
562public:
573 explicit ConfidenceFrame(const ob_frame *impl) : VideoFrame(impl) {};
574
575 ~ConfidenceFrame() noexcept override = default;
576};
577
586class PointsFrame : public Frame {
587
588public:
599 explicit PointsFrame(const ob_frame *impl) : Frame(impl) {};
600
601 ~PointsFrame() noexcept override = default;
602
611 ob_error *error = nullptr;
613 Error::handle(&error);
614
615 return scale;
616 }
617
623 uint32_t getWidth() const {
624 ob_error *error = nullptr;
625 // TODO
626 auto width = ob_point_cloud_frame_get_width(impl_, &error);
627 Error::handle(&error);
628
629 return width;
630 }
631
637 uint32_t getHeight() const {
638 ob_error *error = nullptr;
639 auto height = ob_point_cloud_frame_get_height(impl_, &error);
640 Error::handle(&error);
641
642 return height;
643 }
644
645public:
646 // The following interfaces are deprecated and are retained here for compatibility purposes.
647#define getPositionValueScale getCoordinateValueScale
648};
649
654class AccelFrame : public Frame {
655
656public:
657 explicit AccelFrame(const ob_frame *impl) : Frame(impl) {};
658
659 ~AccelFrame() noexcept override = default;
660
667 ob_error *error = nullptr;
668 auto value = ob_accel_frame_get_value(impl_, &error);
669 Error::handle(&error);
670
671 return value;
672 }
673
679 float getTemperature() const {
680 ob_error *error = nullptr;
681 auto temp = ob_accel_frame_get_temperature(impl_, &error);
682 Error::handle(&error);
683
684 return temp;
685 }
686
687public:
688 // The following interfaces are deprecated and are retained here for compatibility purposes.
690 return getValue();
691 }
692
693 float temperature() {
694 return getTemperature();
695 }
696};
697
701class GyroFrame : public Frame {
702
703public:
704 explicit GyroFrame(const ob_frame *impl) : Frame(impl) {};
705
706 ~GyroFrame() noexcept override = default;
707
714 ob_error *error = nullptr;
715 auto value = ob_gyro_frame_get_value(impl_, &error);
716 Error::handle(&error);
717
718 return value;
719 }
720
726 float getTemperature() const {
727 ob_error *error = nullptr;
729 Error::handle(&error);
730
731 return temperature;
732 }
733
734public:
735 // The following interfaces are deprecated and are retained here for compatibility purposes.
737 return getValue();
738 }
739
740 float temperature() {
741 return getTemperature();
742 }
743};
744
749class FrameSet : public Frame {
750
751public:
752 explicit FrameSet(const ob_frame *impl) : Frame(impl) {};
753
754 ~FrameSet() noexcept override = default;
755
761 uint32_t getCount() const {
762 ob_error *error = nullptr;
763 auto count = ob_frameset_get_count(impl_, &error);
764 Error::handle(&error);
765 return count;
766 }
767
774 std::shared_ptr<Frame> getFrame(OBFrameType frameType) const {
775 ob_error *error = nullptr;
776 auto frame = ob_frameset_get_frame(impl_, frameType, &error);
777 if(!frame) {
778 return nullptr;
779 }
780 Error::handle(&error);
781 return std::make_shared<Frame>(frame);
782 }
783
790 std::shared_ptr<Frame> getFrameByIndex(uint32_t index) const {
791 ob_error *error = nullptr;
792 auto frame = ob_frameset_get_frame_by_index(impl_, index, &error);
793 if(!frame) {
794 return nullptr;
795 }
796 Error::handle(&error);
797 return std::make_shared<Frame>(frame);
798 }
799
807 void pushFrame(std::shared_ptr<const Frame> frame) const {
808 ob_error *error = nullptr;
809
810 // unsafe operation, need to cast const to non-const
811 auto unConstImpl = const_cast<ob_frame *>(impl_);
812
813 auto otherImpl = frame->getImpl();
814 ob_frameset_push_frame(unConstImpl, otherImpl, &error);
815
816 Error::handle(&error);
817 }
818
819public:
820 // The following interfaces are deprecated and are retained here for compatibility purposes.
821 uint32_t frameCount() const {
822 return getCount();
823 }
824
825 std::shared_ptr<DepthFrame> depthFrame() const {
826 auto frame = getFrame(OB_FRAME_DEPTH);
827 if(frame == nullptr) {
828 return nullptr;
829 }
830 auto depthFrame = frame->as<ob::DepthFrame>();
831 return depthFrame;
832 }
833
834 std::shared_ptr<ColorFrame> colorFrame() const {
835 auto frame = getFrame(OB_FRAME_COLOR);
836 if(frame == nullptr) {
837 return nullptr;
838 }
839 auto colorFrame = frame->as<ob::ColorFrame>();
840 return colorFrame;
841 }
842
843 std::shared_ptr<IRFrame> irFrame() const {
844 auto frame = getFrame(OB_FRAME_IR);
845 if(frame == nullptr) {
846 return nullptr;
847 }
848 auto irFrame = frame->as<ob::IRFrame>();
849 return irFrame;
850 }
851
852public:
853 // The following interfaces are deprecated and are retained here for compatibility purposes.
854 std::shared_ptr<PointsFrame> pointsFrame() const {
855 auto frame = getFrame(OB_FRAME_POINTS);
856 if(frame == nullptr) {
857 return nullptr;
858 }
859 auto pointsFrame = frame->as<ob::PointsFrame>();
860 return pointsFrame;
861 }
862
863 std::shared_ptr<Frame> getFrame(int index) const {
864 return getFrameByIndex(index);
865 }
866};
867
872public:
881 static std::shared_ptr<Frame> createFrame(OBFrameType frameType, OBFormat format, uint32_t dataSize) {
882 ob_error *error = nullptr;
883 auto impl = ob_create_frame(frameType, format, dataSize, &error);
884 Error::handle(&error);
885
886 return std::make_shared<Frame>(impl);
887 }
888
901 static std::shared_ptr<VideoFrame> createVideoFrame(OBFrameType frameType, OBFormat format, uint32_t width, uint32_t height, uint32_t stride = 0) {
902 ob_error *error = nullptr;
903 auto impl = ob_create_video_frame(frameType, format, width, height, stride, &error);
904 Error::handle(&error);
905
906 auto frame = std::make_shared<Frame>(impl);
907 return frame->as<VideoFrame>();
908 }
909
919 static std::shared_ptr<Frame> createFrameFromOtherFrame(std::shared_ptr<const Frame> otherFrame, bool shouldCopyData = true) {
920 ob_error *error = nullptr;
921 auto otherImpl = otherFrame->getImpl();
922 auto impl = ob_create_frame_from_other_frame(otherImpl, shouldCopyData, &error);
923 Error::handle(&error);
924
925 return std::make_shared<Frame>(impl);
926 }
927
935 static std::shared_ptr<Frame> createFrameFromStreamProfile(std::shared_ptr<const StreamProfile> profile) {
936 ob_error *error = nullptr;
937 auto impl = ob_create_frame_from_stream_profile(profile->getImpl(), &error);
938 Error::handle(&error);
939
940 return std::make_shared<Frame>(impl);
941 }
942
946 typedef std::function<void(uint8_t *)> BufferDestroyCallback;
947
962 static std::shared_ptr<Frame> createFrameFromBuffer(OBFrameType frameType, OBFormat format, uint8_t *buffer, BufferDestroyCallback destroyCallback,
963 uint32_t bufferSize) {
964 ob_error *error = nullptr;
965 auto ctx = new BufferDestroyContext{ destroyCallback };
966 auto impl = ob_create_frame_from_buffer(frameType, format, buffer, bufferSize, &FrameFactory::BufferDestroy, ctx, &error);
967 Error::handle(&error);
968
969 return std::make_shared<Frame>(impl);
970 }
971
991 static std::shared_ptr<VideoFrame> createVideoFrameFromBuffer(OBFrameType frameType, OBFormat format, uint32_t width, uint32_t height, uint8_t *buffer,
992 BufferDestroyCallback destroyCallback, uint32_t bufferSize, uint32_t stride = 0) {
993 ob_error *error = nullptr;
994 auto ctx = new BufferDestroyContext{ destroyCallback };
995 auto impl = ob_create_video_frame_from_buffer(frameType, format, width, height, stride, buffer, bufferSize, &FrameFactory::BufferDestroy, ctx, &error);
996 Error::handle(&error);
997
998 auto frame = std::make_shared<Frame>(impl);
999 return frame->as<VideoFrame>();
1000 }
1001
1011 static std::shared_ptr<FrameSet> createFrameSet() {
1012 ob_error *error = nullptr;
1013 auto impl = ob_create_frameset(&error);
1014 Error::handle(&error);
1015 return std::make_shared<FrameSet>(impl);
1016 }
1017
1018private:
1019 struct BufferDestroyContext {
1020 BufferDestroyCallback callback;
1021 };
1022
1023 static void BufferDestroy(uint8_t *buffer, void *context) {
1024 auto *ctx = static_cast<BufferDestroyContext *>(context);
1025 if(ctx->callback) {
1026 ctx->callback(buffer);
1027 }
1028 delete ctx;
1029 }
1030};
1031
1037public:
1044 static void setFrameDeviceTimestampUs(std::shared_ptr<Frame> frame, uint64_t deviceTimestampUs) {
1045 ob_error *error = nullptr;
1046 auto impl = const_cast<ob_frame *>(frame->getImpl());
1047 ob_frame_set_timestamp_us(impl, deviceTimestampUs, &error);
1048 Error::handle(&error);
1049 }
1050
1051public:
1052 // The following interfaces are deprecated and are retained here for compatibility purposes.
1053 static void setFrameSystemTimestamp(std::shared_ptr<Frame> frame, uint64_t systemTimestamp) {
1054 // In order to compile, some high-version compilers will warn that the function parameters are not used.
1055 (void)frame;
1056 (void)systemTimestamp;
1057 }
1058
1059 static void setFrameDeviceTimestamp(std::shared_ptr<Frame> frame, uint64_t deviceTimestamp) {
1060 // In order to compile, some high-version compilers will warn that the function parameters are not used.
1061 (void)frame;
1062 (void)deviceTimestamp;
1063 }
1064};
1065
1066// Define the is() template function for the Frame class
1067template <typename T> bool Frame::is() const {
1068 switch(this->getType()) {
1069 case OB_FRAME_IR_LEFT: // Follow
1070 case OB_FRAME_IR_RIGHT: // Follow
1071 case OB_FRAME_IR:
1072 return (typeid(T) == typeid(IRFrame) || typeid(T) == typeid(VideoFrame));
1073 case OB_FRAME_DEPTH:
1074 return (typeid(T) == typeid(DepthFrame) || typeid(T) == typeid(VideoFrame));
1075 case OB_FRAME_COLOR:
1076 return (typeid(T) == typeid(ColorFrame) || typeid(T) == typeid(VideoFrame));
1078 return (typeid(T) == typeid(ConfidenceFrame) || typeid(T) == typeid(VideoFrame));
1079 case OB_FRAME_GYRO:
1080 return (typeid(T) == typeid(GyroFrame));
1081 case OB_FRAME_ACCEL:
1082 return (typeid(T) == typeid(AccelFrame));
1083 case OB_FRAME_POINTS:
1084 return (typeid(T) == typeid(PointsFrame));
1085 case OB_FRAME_SET:
1086 return (typeid(T) == typeid(FrameSet));
1087 default:
1088 std::cout << "ob::Frame::is() did not catch frame type: " << (int)this->getType() << std::endl;
1089 break;
1090 }
1091 return false;
1092}
1093
1094} // namespace ob
This file defines the Error class, which describes abnormal errors within the SDK....
Frame related function is mainly used to obtain frame data and frame information.
OB_EXPORT void ob_frameset_push_frame(ob_frame *frameset, const ob_frame *frame, ob_error **error)
Push a frame to the frameset.
OB_EXPORT ob_frame * ob_create_video_frame_from_buffer(ob_frame_type frame_type, ob_format format, uint32_t width, uint32_t height, uint32_t stride_bytes, uint8_t *buffer, uint32_t buffer_size, ob_frame_destroy_callback *buffer_destroy_cb, void *buffer_destroy_context, ob_error **error)
Create a video frame object based on an externally created buffer.
OB_EXPORT uint8_t * ob_frame_get_data(const ob_frame *frame, ob_error **error)
Get the data buffer of a frame.
OB_EXPORT ob_frame * ob_create_frame_from_buffer(ob_frame_type frame_type, ob_format format, uint8_t *buffer, uint32_t buffer_size, ob_frame_destroy_callback *buffer_destroy_cb, void *buffer_destroy_context, ob_error **error)
Create a frame object based on an externally created buffer.
OB_EXPORT ob_frame * ob_create_frame_from_stream_profile(const ob_stream_profile *stream_profile, ob_error **error)
Create a frame object according to the specified stream profile.
OB_EXPORT ob_frame * ob_create_frame_from_other_frame(const ob_frame *other_frame, bool should_copy_data, ob_error **error)
Create (clone) a frame object based on the specified other frame object.
OB_EXPORT uint64_t ob_frame_get_timestamp_us(const ob_frame *frame, ob_error **error)
Get the frame timestamp (also known as device timestamp, hardware timestamp) of the frame in microsec...
OB_EXPORT ob_frame * ob_create_video_frame(ob_frame_type frame_type, ob_format format, uint32_t width, uint32_t height, uint32_t stride_bytes, ob_error **error)
Create an video frame object based on the specified parameters.
OB_EXPORT ob_frame_type ob_frame_get_type(const ob_frame *frame, ob_error **error)
Get the frame type.
OB_EXPORT ob_frame * ob_frameset_get_frame(const ob_frame *frameset, ob_frame_type frame_type, ob_error **error)
Get a frame of a specific type from the frameset.
OB_EXPORT ob_frame * ob_create_frameset(ob_error **error)
Create an empty frameset object.
OB_EXPORT ob_format ob_frame_get_format(const ob_frame *frame, ob_error **error)
Get the frame format.
OB_EXPORT ob_accel_value ob_accel_frame_get_value(const ob_frame *frame, ob_error **error)
Get accelerometer frame data.
OB_EXPORT uint32_t ob_video_frame_get_width(const ob_frame *frame, ob_error **error)
Get video frame width.
OB_EXPORT uint8_t ob_video_frame_get_pixel_available_bit_size(const ob_frame *frame, ob_error **error)
Get the effective number of pixels (such as Y16 format frame, but only the lower 10 bits are effectiv...
OB_EXPORT float ob_depth_frame_get_value_scale(const ob_frame *frame, ob_error **error)
Get the value scale of the depth frame. The pixel value of the depth frame is multiplied by the scale...
OB_EXPORT ob_stream_profile * ob_frame_get_stream_profile(const ob_frame *frame, ob_error **error)
Get the stream profile of the frame.
OB_EXPORT float ob_points_frame_get_coordinate_value_scale(const ob_frame *frame, ob_error **error)
Get the point coordinate value scale of the points frame. The point position value of the points fram...
OB_EXPORT float ob_accel_frame_get_temperature(const ob_frame *frame, ob_error **error)
Get the temperature when acquiring the accelerometer frame.
OB_EXPORT ob_frame * ob_frameset_get_frame_by_index(const ob_frame *frameset, uint32_t index, ob_error **error)
Get a frame at a specific index from the FrameSet.
OB_EXPORT bool ob_frame_has_metadata(const ob_frame *frame, ob_frame_metadata_type type, ob_error **error)
check if the frame contains the specified metadata
OB_EXPORT int64_t ob_frame_get_metadata_value(const ob_frame *frame, ob_frame_metadata_type type, ob_error **error)
Get the metadata value of the frame.
OB_EXPORT uint32_t ob_point_cloud_frame_get_width(const ob_frame *frame, ob_error **error)
Get point cloud frame width.
OB_EXPORT ob_gyro_value ob_gyro_frame_get_value(const ob_frame *frame, ob_error **error)
Get gyroscope frame data.
OB_EXPORT uint64_t ob_frame_get_global_timestamp_us(const ob_frame *frame, ob_error **error)
Get the global timestamp of the frame in microseconds.
OB_EXPORT uint32_t ob_frame_get_metadata_size(const ob_frame *frame, ob_error **error)
Get the metadata size of the frame.
OB_EXPORT void ob_frame_set_timestamp_us(ob_frame *frame, uint64_t timestamp_us, ob_error **error)
Set the frame timestamp (also known as the device timestamp, hardware timestamp) of a frame object.
OB_EXPORT uint32_t ob_frame_get_data_size(const ob_frame *frame, ob_error **error)
Get the frame data size.
OB_EXPORT ob_device * ob_frame_get_device(const ob_frame *frame, ob_error **error)
Get the device of the frame.
OB_EXPORT uint64_t ob_frame_get_system_timestamp_us(const ob_frame *frame, ob_error **error)
Get the system timestamp of the frame in microseconds.
OB_EXPORT float ob_gyro_frame_get_temperature(const ob_frame *frame, ob_error **error)
Get the temperature when acquiring the gyroscope frame.
OB_EXPORT uint64_t ob_frame_get_index(const ob_frame *frame, ob_error **error)
Get the frame index.
OB_EXPORT void ob_frame_add_ref(const ob_frame *frame, ob_error **error)
Increase the reference count of a frame object.
OB_EXPORT uint32_t ob_point_cloud_frame_get_height(const ob_frame *frame, ob_error **error)
Get point cloud frame height.
OB_EXPORT ob_pixel_type ob_video_frame_get_pixel_type(const ob_frame *frame, ob_error **error)
Get video frame pixel format.
OB_EXPORT void ob_delete_frame(const ob_frame *frame, ob_error **error)
Delete a frame object.
OB_EXPORT ob_sensor * ob_frame_get_sensor(const ob_frame *frame, ob_error **error)
Get the sensor of the frame.
OB_EXPORT ob_frame * ob_create_frame(ob_frame_type frame_type, ob_format format, uint32_t data_size, ob_error **error)
Crate a frame object based on the specified parameters.
OB_EXPORT uint8_t * ob_frame_get_metadata(const ob_frame *frame, ob_error **error)
Get the metadata of the frame.
OB_EXPORT uint32_t ob_frameset_get_count(const ob_frame *frameset, ob_error **error)
Get the number of frames contained in the frameset.
OB_EXPORT uint32_t ob_video_frame_get_height(const ob_frame *frame, ob_error **error)
Get video frame height.
struct ob_frame_t ob_frame
Definition ObTypes.h:33
struct OBAccelValue OBGyroValue
OBFormat
Enumeration value describing the pixel format.
Definition ObTypes.h:199
enum ob_frame_metadata_type OBFrameMetadataType
OBFrameType
Enumeration value describing the type of frame.
Definition ObTypes.h:165
@ OB_FRAME_IR_RIGHT
Definition ObTypes.h:176
@ OB_FRAME_ACCEL
Definition ObTypes.h:171
@ OB_FRAME_GYRO
Definition ObTypes.h:174
@ OB_FRAME_IR_LEFT
Definition ObTypes.h:175
@ OB_FRAME_COLOR
Definition ObTypes.h:169
@ OB_FRAME_SET
Definition ObTypes.h:172
@ OB_FRAME_CONFIDENCE
Definition ObTypes.h:178
@ OB_FRAME_POINTS
Definition ObTypes.h:173
@ OB_FRAME_IR
Definition ObTypes.h:168
@ OB_FRAME_DEPTH
Definition ObTypes.h:170
OBPixelType
Enumeration value describing the pixel type of frame (usually used for depth frame)
Definition ObTypes.h:187
The stream profile related type is used to get information such as the width, height,...
Define the AccelFrame class, which inherits from the Frame class.
Definition Frame.hpp:654
OBAccelValue value()
Definition Frame.hpp:689
OBAccelValue getValue() const
Get the accelerometer frame data.
Definition Frame.hpp:666
float getTemperature() const
Get the temperature when the frame was sampled.
Definition Frame.hpp:679
float temperature()
Definition Frame.hpp:693
~AccelFrame() noexcept override=default
AccelFrame(const ob_frame *impl)
Definition Frame.hpp:657
Define the ColorFrame class, which inherits from the VideoFrame classd.
Definition Frame.hpp:481
~ColorFrame() noexcept override=default
ColorFrame(const ob_frame *impl)
Construct a new ColorFrame object with a given pointer to the internal frame object.
Definition Frame.hpp:493
Define the ConfidenceFrame class, which inherits from the VideoFrame class.
Definition Frame.hpp:560
~ConfidenceFrame() noexcept override=default
ConfidenceFrame(const ob_frame *impl)
Construct a new ConfidenceFrame object with a given pointer to the internal frame object.
Definition Frame.hpp:573
Define the DepthFrame class, which inherits from the VideoFrame class.
Definition Frame.hpp:501
float getValueScale() const
Get the value scale of the depth frame. The pixel value of depth frame is multiplied by the scale to ...
Definition Frame.hpp:525
~DepthFrame() noexcept override=default
DepthFrame(const ob_frame *impl)
Construct a new DepthFrame object with a given pointer to the internal frame object.
Definition Frame.hpp:514
static void handle(ob_error **error, bool throw_exception=true)
A static function to handle the ob_error and throw an exception if needed.
Definition Error.hpp:38
FrameFactory class, which provides some static functions to create frame objects.
Definition Frame.hpp:871
static std::shared_ptr< VideoFrame > createVideoFrameFromBuffer(OBFrameType frameType, OBFormat format, uint32_t width, uint32_t height, uint8_t *buffer, BufferDestroyCallback destroyCallback, uint32_t bufferSize, uint32_t stride=0)
Create a video frame object based on an externally created buffer.
Definition Frame.hpp:991
static std::shared_ptr< Frame > createFrame(OBFrameType frameType, OBFormat format, uint32_t dataSize)
Create a Frame object of a specific type with a given format and data size.
Definition Frame.hpp:881
static std::shared_ptr< Frame > createFrameFromOtherFrame(std::shared_ptr< const Frame > otherFrame, bool shouldCopyData=true)
Create (clone) a frame object based on the specified other frame object.
Definition Frame.hpp:919
static std::shared_ptr< Frame > createFrameFromStreamProfile(std::shared_ptr< const StreamProfile > profile)
Create a Frame From (according to)Stream Profile object.
Definition Frame.hpp:935
std::function< void(uint8_t *)> BufferDestroyCallback
The callback function to destroy the buffer when the frame is destroyed.
Definition Frame.hpp:946
static std::shared_ptr< Frame > createFrameFromBuffer(OBFrameType frameType, OBFormat format, uint8_t *buffer, BufferDestroyCallback destroyCallback, uint32_t bufferSize)
Create a frame object based on an externally created buffer.
Definition Frame.hpp:962
static std::shared_ptr< VideoFrame > createVideoFrame(OBFrameType frameType, OBFormat format, uint32_t width, uint32_t height, uint32_t stride=0)
Create a VideoFrame object of a specific type with a given format, width, height, and stride.
Definition Frame.hpp:901
static std::shared_ptr< FrameSet > createFrameSet()
Create a new FrameSet object.
Definition Frame.hpp:1011
FrameHepler class, which provides some static functions to set timestamp for frame objects FrameHeple...
Definition Frame.hpp:1036
static void setFrameDeviceTimestamp(std::shared_ptr< Frame > frame, uint64_t deviceTimestamp)
Definition Frame.hpp:1059
static void setFrameDeviceTimestampUs(std::shared_ptr< Frame > frame, uint64_t deviceTimestampUs)
Set the device timestamp of the frame.
Definition Frame.hpp:1044
static void setFrameSystemTimestamp(std::shared_ptr< Frame > frame, uint64_t systemTimestamp)
Definition Frame.hpp:1053
std::shared_ptr< StreamProfile > getStreamProfile() const
get StreamProfile of the frame
Definition Frame.hpp:260
uint64_t systemTimeStampUs() const
Definition Frame.hpp:372
virtual ~Frame() noexcept
Destroy the Frame object.
Definition Frame.hpp:76
int64_t getMetadataValue(OBFrameMetadataType type) const
Get the metadata value.
Definition Frame.hpp:247
uint64_t timeStamp() const
Definition Frame.hpp:360
virtual OBFrameType getType() const
Get the type of frame.
Definition Frame.hpp:90
Frame(const ob_frame *impl)
Construct a new Frame object with a given pointer to the internal frame object.
Definition Frame.hpp:62
virtual uint8_t * getData() const
Get frame data.
Definition Frame.hpp:131
std::shared_ptr< Sensor > getSensor() const
get owner sensor of the frame
Definition Frame.hpp:272
std::shared_ptr< T > as()
Convert the frame object to a target type.
Definition Frame.hpp:307
bool hasMetadata(OBFrameMetadataType type) const
Check if the frame object has metadata of a given type.
Definition Frame.hpp:233
uint32_t getMetadataSize() const
Get the size of the metadata of the frame.
Definition Frame.hpp:219
uint32_t metadataSize() const
Definition Frame.hpp:384
virtual OBFormat getFormat() const
Get the format of the frame.
Definition Frame.hpp:103
const ob_frame * impl_
The pointer to the internal (c api level) frame object.
Definition Frame.hpp:50
OBFrameType type() const
Definition Frame.hpp:339
bool is() const
Check if the runtime type of the frame object is compatible with a given type.
Definition Frame.hpp:1067
uint64_t getTimeStampUs() const
Get the hardware timestamp of the frame in microseconds.
Definition Frame.hpp:160
std::shared_ptr< Device > getDevice() const
get owner device of the frame
Definition Frame.hpp:285
uint64_t globalTimeStampUs() const
Definition Frame.hpp:376
uint8_t * getMetadata() const
Get the metadata pointer of the frame.
Definition Frame.hpp:206
virtual uint64_t getIndex() const
Get the sequence number of the frame.
Definition Frame.hpp:118
virtual uint64_t index() const
Definition Frame.hpp:347
uint64_t timeStampUs() const
Definition Frame.hpp:364
uint8_t * metadata() const
Definition Frame.hpp:380
virtual void * data() const
Definition Frame.hpp:351
std::shared_ptr< const T > as() const
Convert the frame object to a target type.
Definition Frame.hpp:325
virtual uint32_t dataSize() const
Definition Frame.hpp:356
virtual uint32_t getDataSize() const
Get the size of the frame data.
Definition Frame.hpp:146
virtual OBFormat format() const
Definition Frame.hpp:343
uint64_t getSystemTimeStampUs() const
Get the system timestamp of the frame in microseconds.
Definition Frame.hpp:174
uint64_t getGlobalTimeStampUs() const
Get the global timestamp of the frame in microseconds.
Definition Frame.hpp:193
const ob_frame * getImpl() const
Get the internal (impl) frame object.
Definition Frame.hpp:69
uint64_t systemTimeStamp() const
Definition Frame.hpp:368
Define the FrameSet class, which inherits from the Frame class.
Definition Frame.hpp:749
std::shared_ptr< ColorFrame > colorFrame() const
Definition Frame.hpp:834
uint32_t getCount() const
Get the number of frames in the FrameSet.
Definition Frame.hpp:761
std::shared_ptr< PointsFrame > pointsFrame() const
Definition Frame.hpp:854
std::shared_ptr< DepthFrame > depthFrame() const
Definition Frame.hpp:825
FrameSet(const ob_frame *impl)
Definition Frame.hpp:752
~FrameSet() noexcept override=default
std::shared_ptr< Frame > getFrameByIndex(uint32_t index) const
Get a frame at a specific index from the FrameSet.
Definition Frame.hpp:790
std::shared_ptr< Frame > getFrame(int index) const
Definition Frame.hpp:863
std::shared_ptr< IRFrame > irFrame() const
Definition Frame.hpp:843
std::shared_ptr< Frame > getFrame(OBFrameType frameType) const
Get a frame of a specific type from the FrameSet.
Definition Frame.hpp:774
void pushFrame(std::shared_ptr< const Frame > frame) const
Push a frame to the FrameSet.
Definition Frame.hpp:807
uint32_t frameCount() const
Definition Frame.hpp:821
Define the GyroFrame class, which inherits from the Frame class.
Definition Frame.hpp:701
~GyroFrame() noexcept override=default
OBGyroValue getValue() const
Get the gyro frame data.
Definition Frame.hpp:713
GyroFrame(const ob_frame *impl)
Definition Frame.hpp:704
OBGyroValue value()
Definition Frame.hpp:736
float temperature()
Definition Frame.hpp:740
float getTemperature() const
Get the temperature when the frame was sampled.
Definition Frame.hpp:726
Define the IRFrame class, which inherits from the VideoFrame class.
Definition Frame.hpp:538
IRFrame(const ob_frame *impl)
Construct a new IRFrame object with a given pointer to the internal frame object.
Definition Frame.hpp:551
~IRFrame() noexcept override=default
Define the PointsFrame class, which inherits from the Frame class.
Definition Frame.hpp:586
uint32_t getHeight() const
Get the height of the frame.
Definition Frame.hpp:637
PointsFrame(const ob_frame *impl)
Construct a new PointsFrame object with a given pointer to the internal frame object.
Definition Frame.hpp:599
~PointsFrame() noexcept override=default
uint32_t getWidth() const
Get the width of the frame.
Definition Frame.hpp:623
float getCoordinateValueScale() const
Get the point coordinate value scale of the points frame. The point position value of the points fram...
Definition Frame.hpp:610
static std::shared_ptr< StreamProfile > create(const ob_stream_profile_t *impl)
Define the VideoFrame class, which inherits from the Frame class.
Definition Frame.hpp:392
uint32_t width() const
Definition Frame.hpp:465
uint32_t getWidth() const
Get the width of the frame.
Definition Frame.hpp:412
uint8_t pixelAvailableBitSize() const
Definition Frame.hpp:473
OBPixelType getPixelType() const
Get the Pixel Type object.
Definition Frame.hpp:441
uint32_t getHeight() const
Get the height of the frame.
Definition Frame.hpp:425
uint8_t getPixelAvailableBitSize() const
Get the effective number of pixels in the frame.
Definition Frame.hpp:455
uint32_t height() const
Definition Frame.hpp:469
~VideoFrame() noexcept override=default
VideoFrame(const ob_frame *impl)
Construct a new VideoFrame object with a given pointer to the internal frame object.
Definition Frame.hpp:403
Definition Context.hpp:19
Data structures for accelerometers and gyroscopes.
Definition ObTypes.h:638
The error class exposed by the SDK, users can get detailed error information according to the error.
Definition ObTypes.h:117