45class Frame :
public std::enable_shared_from_this<Frame> {
277 return std::make_shared<Sensor>(sensor);
290 return std::make_shared<Device>(device);
299 template <
typename T>
bool is()
const;
307 template <
typename T> std::shared_ptr<T>
as() {
309 throw std::runtime_error(
"unsupported operation, object's type is not require type");
316 return std::make_shared<T>(
impl_);
325 template <
typename T> std::shared_ptr<const T>
as()
const {
327 throw std::runtime_error(
"unsupported operation, object's type is not require type");
334 return std::make_shared<const T>(
impl_);
353 return reinterpret_cast<void *
>(
data);
647#define getPositionValueScale getCoordinateValueScale
781 return std::make_shared<Frame>(frame);
797 return std::make_shared<Frame>(frame);
807 void pushFrame(std::shared_ptr<const Frame> frame)
const {
813 auto otherImpl = frame->getImpl();
827 if(frame ==
nullptr) {
836 if(frame ==
nullptr) {
845 if(frame ==
nullptr) {
856 if(frame ==
nullptr) {
886 return std::make_shared<Frame>(impl);
906 auto frame = std::make_shared<Frame>(impl);
921 auto otherImpl = otherFrame->getImpl();
925 return std::make_shared<Frame>(impl);
940 return std::make_shared<Frame>(impl);
963 uint32_t bufferSize) {
965 auto ctx =
new BufferDestroyContext{ destroyCallback };
969 return std::make_shared<Frame>(impl);
994 auto ctx =
new BufferDestroyContext{ destroyCallback };
998 auto frame = std::make_shared<Frame>(impl);
1015 return std::make_shared<FrameSet>(impl);
1019 struct BufferDestroyContext {
1020 BufferDestroyCallback callback;
1023 static void BufferDestroy(uint8_t *buffer,
void *context) {
1024 auto *ctx =
static_cast<BufferDestroyContext *
>(context);
1026 ctx->callback(buffer);
1046 auto impl =
const_cast<ob_frame *
>(frame->getImpl());
1056 (void)systemTimestamp;
1062 (void)deviceTimestamp;
1080 return (
typeid(T) ==
typeid(
GyroFrame));
1086 return (
typeid(T) ==
typeid(
FrameSet));
1088 std::cout <<
"ob::Frame::is() did not catch frame type: " << (int)this->
getType() << std::endl;
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
struct OBAccelValue OBGyroValue
OBFormat
Enumeration value describing the pixel format.
enum ob_frame_metadata_type OBFrameMetadataType
OBFrameType
Enumeration value describing the type of frame.
OBPixelType
Enumeration value describing the pixel type of frame (usually used for depth frame)
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.
OBAccelValue getValue() const
Get the accelerometer frame data.
float getTemperature() const
Get the temperature when the frame was sampled.
~AccelFrame() noexcept override=default
AccelFrame(const ob_frame *impl)
Define the ColorFrame class, which inherits from the VideoFrame classd.
~ColorFrame() noexcept override=default
ColorFrame(const ob_frame *impl)
Construct a new ColorFrame object with a given pointer to the internal frame object.
Define the ConfidenceFrame class, which inherits from the VideoFrame class.
~ConfidenceFrame() noexcept override=default
ConfidenceFrame(const ob_frame *impl)
Construct a new ConfidenceFrame object with a given pointer to the internal frame object.
Define the DepthFrame class, which inherits from the VideoFrame class.
float getValueScale() const
Get the value scale of the depth frame. The pixel value of depth frame is multiplied by the scale to ...
~DepthFrame() noexcept override=default
DepthFrame(const ob_frame *impl)
Construct a new DepthFrame object with a given pointer to the internal frame object.
static void handle(ob_error **error, bool throw_exception=true)
A static function to handle the ob_error and throw an exception if needed.
FrameFactory class, which provides some static functions to create frame objects.
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.
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.
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.
static std::shared_ptr< Frame > createFrameFromStreamProfile(std::shared_ptr< const StreamProfile > profile)
Create a Frame From (according to)Stream Profile object.
std::function< void(uint8_t *)> BufferDestroyCallback
The callback function to destroy the buffer when the frame is destroyed.
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.
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.
static std::shared_ptr< FrameSet > createFrameSet()
Create a new FrameSet object.
FrameHepler class, which provides some static functions to set timestamp for frame objects FrameHeple...
static void setFrameDeviceTimestamp(std::shared_ptr< Frame > frame, uint64_t deviceTimestamp)
static void setFrameDeviceTimestampUs(std::shared_ptr< Frame > frame, uint64_t deviceTimestampUs)
Set the device timestamp of the frame.
static void setFrameSystemTimestamp(std::shared_ptr< Frame > frame, uint64_t systemTimestamp)
std::shared_ptr< StreamProfile > getStreamProfile() const
get StreamProfile of the frame
uint64_t systemTimeStampUs() const
virtual ~Frame() noexcept
Destroy the Frame object.
int64_t getMetadataValue(OBFrameMetadataType type) const
Get the metadata value.
uint64_t timeStamp() const
virtual OBFrameType getType() const
Get the type of frame.
Frame(const ob_frame *impl)
Construct a new Frame object with a given pointer to the internal frame object.
virtual uint8_t * getData() const
Get frame data.
std::shared_ptr< Sensor > getSensor() const
get owner sensor of the frame
std::shared_ptr< T > as()
Convert the frame object to a target type.
bool hasMetadata(OBFrameMetadataType type) const
Check if the frame object has metadata of a given type.
uint32_t getMetadataSize() const
Get the size of the metadata of the frame.
uint32_t metadataSize() const
virtual OBFormat getFormat() const
Get the format of the frame.
const ob_frame * impl_
The pointer to the internal (c api level) frame object.
bool is() const
Check if the runtime type of the frame object is compatible with a given type.
uint64_t getTimeStampUs() const
Get the hardware timestamp of the frame in microseconds.
std::shared_ptr< Device > getDevice() const
get owner device of the frame
uint64_t globalTimeStampUs() const
uint8_t * getMetadata() const
Get the metadata pointer of the frame.
virtual uint64_t getIndex() const
Get the sequence number of the frame.
virtual uint64_t index() const
uint64_t timeStampUs() const
uint8_t * metadata() const
virtual void * data() const
std::shared_ptr< const T > as() const
Convert the frame object to a target type.
virtual uint32_t dataSize() const
virtual uint32_t getDataSize() const
Get the size of the frame data.
virtual OBFormat format() const
uint64_t getSystemTimeStampUs() const
Get the system timestamp of the frame in microseconds.
uint64_t getGlobalTimeStampUs() const
Get the global timestamp of the frame in microseconds.
const ob_frame * getImpl() const
Get the internal (impl) frame object.
uint64_t systemTimeStamp() const
Define the FrameSet class, which inherits from the Frame class.
std::shared_ptr< ColorFrame > colorFrame() const
uint32_t getCount() const
Get the number of frames in the FrameSet.
std::shared_ptr< PointsFrame > pointsFrame() const
std::shared_ptr< DepthFrame > depthFrame() const
FrameSet(const ob_frame *impl)
~FrameSet() noexcept override=default
std::shared_ptr< Frame > getFrameByIndex(uint32_t index) const
Get a frame at a specific index from the FrameSet.
std::shared_ptr< Frame > getFrame(int index) const
std::shared_ptr< IRFrame > irFrame() const
std::shared_ptr< Frame > getFrame(OBFrameType frameType) const
Get a frame of a specific type from the FrameSet.
void pushFrame(std::shared_ptr< const Frame > frame) const
Push a frame to the FrameSet.
uint32_t frameCount() const
Define the GyroFrame class, which inherits from the Frame class.
~GyroFrame() noexcept override=default
OBGyroValue getValue() const
Get the gyro frame data.
GyroFrame(const ob_frame *impl)
float getTemperature() const
Get the temperature when the frame was sampled.
Define the IRFrame class, which inherits from the VideoFrame class.
IRFrame(const ob_frame *impl)
Construct a new IRFrame object with a given pointer to the internal frame object.
~IRFrame() noexcept override=default
Define the PointsFrame class, which inherits from the Frame class.
uint32_t getHeight() const
Get the height of the frame.
PointsFrame(const ob_frame *impl)
Construct a new PointsFrame object with a given pointer to the internal frame object.
~PointsFrame() noexcept override=default
uint32_t getWidth() const
Get the width of the frame.
float getCoordinateValueScale() const
Get the point coordinate value scale of the points frame. The point position value of the points fram...
static std::shared_ptr< StreamProfile > create(const ob_stream_profile_t *impl)
Define the VideoFrame class, which inherits from the Frame class.
uint32_t getWidth() const
Get the width of the frame.
uint8_t pixelAvailableBitSize() const
OBPixelType getPixelType() const
Get the Pixel Type object.
uint32_t getHeight() const
Get the height of the frame.
uint8_t getPixelAvailableBitSize() const
Get the effective number of pixels in the frame.
~VideoFrame() noexcept override=default
VideoFrame(const ob_frame *impl)
Construct a new VideoFrame object with a given pointer to the internal frame object.
Data structures for accelerometers and gyroscopes.
The error class exposed by the SDK, users can get detailed error information according to the error.