Update sdk version to v2.3.1

This commit is contained in:
jj
2025-03-31 12:42:07 +08:00
parent 40cf9531e7
commit b5dcada17b
32 changed files with 995 additions and 527 deletions
@@ -101,7 +101,7 @@ public:
* @brief Creates a network device with the specified IP address and port.
*
* @param[in] address The IP address, ipv4 only. such as "192.168.1.10"
* @param[in] port The port number, currently only support 8090
* @param[in] port The port number, currently only support 8090
* @return std::shared_ptr<Device> The created device object.
*/
std::shared_ptr<Device> createNetDevice(const char *address, uint16_t port) const {
@@ -210,7 +210,7 @@ public:
/**
* @brief Set the extensions directory
* @brief The extensions directory is used to search for dynamic libraries that provide additional functionality to the SDK, such as the Frame filters.
* @brief The extensions directory is used to search for dynamic libraries that provide additional functionality to the SDK, such as the Frame filters.
*
* @attention Should be called before creating the context and pipeline, otherwise the default extensions directory (./extensions) will be used.
*
@@ -491,7 +491,7 @@ public:
* Please delete the object directly and obtain it again after the device is reconnected.
* Support devices: Gemini2 L
*
* @param[in] delayMs Time unit:ms。delayMs == 0:No delay;delayMs > 0, Delay millisecond connect to host device after reboot
* @param[in] delayMs Time unit: ms. delayMs == 0: No delay; delayMs > 0, Delay millisecond connect to host device after reboot
*/
void reboot(uint32_t delayMs) const {
setIntProperty(OB_PROP_DEVICE_REBOOT_DELAY_INT, delayMs);
@@ -564,7 +564,7 @@ public:
*
* @attention The frequency of the user call this function multiplied by the number of frames per trigger should be less than the frame rate of the stream.
* The number of frames per trigger can be set by @ref framesPerTrigger.
* @attention For some models,receive and execute the capture command will have a certain delay and performance consumption, so the frequency of calling
* @attention For some models, receive and execute the capture command will have a certain delay and performance consumption, so the frequency of calling
* this function should not be too high, please refer to the product manual for the specific supported frequency.
* @attention If the device is not in the @ref OB_MULTI_DEVICE_SYNC_MODE_HARDWARE_TRIGGERING mode, device will ignore the capture command.
*/
@@ -919,7 +919,7 @@ public:
/**
* @brief Get the connection type of the device
*
* @return const char* the connection type of the device,currently supports:"USB", "USB1.0", "USB1.1", "USB2.0", "USB2.1", "USB3.0", "USB3.1",
* @return const char* the connection type of the device, currently supports: "USB", "USB1.0", "USB1.1", "USB2.0", "USB2.1", "USB3.0", "USB3.1",
* "USB3.2", "Ethernet"
*/
const char *getConnectionType() const {
@@ -1141,7 +1141,7 @@ public:
* @brief Get device connection type
*
* @param index device index
* @return const char* returns connection type,currently supports:"USB", "USB1.0", "USB1.1", "USB2.0", "USB2.1", "USB3.0", "USB3.1", "USB3.2", "Ethernet"
* @return const char* returns connection type, currently supports: "USB", "USB1.0", "USB1.1", "USB2.0", "USB2.1", "USB3.0", "USB3.1", "USB3.2", "Ethernet"
*/
const char *getConnectionType(uint32_t index) const {
ob_error *error = nullptr;
@@ -1165,6 +1165,21 @@ public:
return ip;
}
/**
* @brief get the local mac address of the device at the specified index
*
* @attention Only valid for network devices, otherwise it will return "0:0:0:0:0:0".
*
* @param index the index of the device
* @return const char* the local mac address of the device
*/
const char *getLocalMacAddress(uint32_t index) const {
ob_error *error = nullptr;
auto mac = ob_device_list_get_device_local_mac(impl_, index, &error);
Error::handle(&error);
return mac;
}
/**
* @brief Get the device object at the specified index
*
@@ -1200,7 +1215,7 @@ public:
* @brief On Linux platform, for usb device, the uid of the device is composed of bus-port-dev, for example 1-1.2-1. But the SDK will remove the dev number
* and only keep the bus-port as the uid to create the device, for example 1-1.2, so that we can create a device connected to the specified USB port.
* Similarly, users can also directly pass in bus-port as uid to create device.
* @brief For GMSL device,the uid is GMSL port with “gmsl2-” prefix, for example gmsl2-1.
* @brief For GMSL device, the uid is GMSL port with "gmsl2-" prefix, for example gmsl2-1.
*
* @attention If the device has been acquired and created elsewhere, repeated acquisition will throw an exception
*
@@ -18,7 +18,7 @@
#include <functional>
/**
* Frame classis inheritance hierarchy:
* Frame classis inheritance hierarchy:
* Frame
* |
* +-----------+----------+----------+-----------+
@@ -181,7 +181,7 @@ public:
/**
* @brief Get the global timestamp of the frame in microseconds.
* @brief The global timestamp is the time point when the frame was was captured by the device, and has been converted to the host clock domain. The
* @brief The global timestamp is the time point when the frame was captured by the device, and has been converted to the host clock domain. The
* conversion process base on the device timestamp and can eliminate the timer drift of the device
*
* @attention The global timestamp disable by default. If global timestamp is not enabled, the function will return 0. To enable the global timestamp,
@@ -593,6 +593,33 @@ public:
return scale;
}
/**
* @brief Get the width of the frame.
*
* @return uint32_t The width of the frame.
*/
uint32_t getWidth() const {
ob_error *error = nullptr;
// TODO
auto width = ob_point_cloud_frame_get_width(impl_, &error);
Error::handle(&error);
return width;
}
/**
* @brief Get the height of the frame.
*
* @return uint32_t The height of the frame.
*/
uint32_t getHeight() const {
ob_error *error = nullptr;
auto height = ob_point_cloud_frame_get_height(impl_, &error);
Error::handle(&error);
return height;
}
public:
// The following interfaces are deprecated and are retained here for compatibility purposes.
#define getPositionValueScale getCoordinateValueScale
@@ -957,7 +984,7 @@ private:
static void BufferDestroy(uint8_t *buffer, void *context) {
auto *ctx = static_cast<BufferDestroyContext *>(context);
if (ctx->callback) {
if(ctx->callback) {
ctx->callback(buffer);
}
delete ctx;
@@ -0,0 +1,188 @@
// Copyright (c) Orbbec Inc. All Rights Reserved.
// Licensed under the MIT License.
/**
* @file RecordPlayback.hpp
* @brief Record and playback device-related types, including interfaces to create recording and playback devices,
record and playback streaming data, etc.
*/
#pragma once
#include "Types.hpp"
#include "Error.hpp"
#include "libobsensor/h/RecordPlayback.h"
#include "libobsensor/hpp/Device.hpp"
namespace ob {
typedef std::function<void(OBPlaybackStatus status)> PlaybackStatusChangeCallback;
class RecordDevice {
private:
ob_record_device_t *impl_;
public:
explicit RecordDevice(std::shared_ptr<Device> device, const std::string &file, bool compressionEnabled = true) {
ob_error *error = nullptr;
impl_ = ob_create_record_device(device->getImpl(), file.c_str(), compressionEnabled, &error);
Error::handle(&error);
}
virtual ~RecordDevice() noexcept {
ob_error *error = nullptr;
ob_delete_record_device(impl_, &error);
Error::handle(&error, false);
}
RecordDevice(RecordDevice &&other) {
if(this != &other) {
impl_ = other.impl_;
other.impl_ = nullptr;
}
}
RecordDevice &operator=(RecordDevice &&other) {
if(this != &other) {
impl_ = other.impl_;
other.impl_ = nullptr;
}
return *this;
}
RecordDevice(const RecordDevice &) = delete;
RecordDevice &operator=(const RecordDevice &) = delete;
public:
void pause() {
ob_error *error = nullptr;
ob_record_device_pause(impl_, &error);
Error::handle(&error);
}
void resume() {
ob_error *error = nullptr;
ob_record_device_resume(impl_, &error);
Error::handle(&error);
}
};
class PlaybackDevice : public Device {
public:
explicit PlaybackDevice(const std::string &file) : Device(nullptr) {
ob_error *error = nullptr;
impl_ = ob_create_playback_device(file.c_str(), &error);
Error::handle(&error);
}
virtual ~PlaybackDevice() noexcept = default;
PlaybackDevice(PlaybackDevice &&other) : Device(std::move(other)) {}
PlaybackDevice &operator=(PlaybackDevice &&other) {
Device::operator=(std::move(other));
return *this;
}
PlaybackDevice(const PlaybackDevice &) = delete;
PlaybackDevice &operator=(const PlaybackDevice &) = delete;
public:
/**
* @brief Pause the streaming data from the playback device.
*/
void pause() {
ob_error *error = nullptr;
ob_playback_device_pause(impl_, &error);
Error::handle(&error);
}
/**
* @brief Resume the streaming data from the playback device.
*/
void resume() {
ob_error *error = nullptr;
ob_playback_device_resume(impl_, &error);
Error::handle(&error);
}
/**
* @brief Seek to a specific timestamp when playing back a recording.
* @param[in] timestamp The timestamp to seek to, in milliseconds.
*/
void seek(const int64_t timestamp) {
ob_error *error = nullptr;
ob_playback_device_seek(impl_, timestamp, &error);
Error::handle(&error);
}
/**
* @brief Set the playback rate of the playback device.
* @param[in] rate The playback rate to set.
*/
void setPlaybackRate(const float rate) {
ob_error *error = nullptr;
ob_playback_device_set_playback_rate(impl_, rate, &error);
Error::handle(&error);
}
/**
* @brief Set a callback function to be called when the playback status changes.
* @param[in] callback The callback function to set.
*/
void setPlaybackStatusChangeCallback(PlaybackStatusChangeCallback callback) {
callback_ = callback;
ob_error *error = nullptr;
ob_playback_device_set_playback_status_changed_callback(impl_, &PlaybackDevice::playbackStatusCallback, this, &error);
Error::handle(&error);
}
/**
* @brief Get the current playback status of the playback device.
* @return The current playback status.
*/
OBPlaybackStatus getPlaybackStatus() const {
ob_error *error = nullptr;
OBPlaybackStatus status = ob_playback_device_get_current_playback_status(impl_, &error);
Error::handle(&error);
return status;
}
/**
* @brief Get the current position of the playback device.
* @return The current position of the playback device, in milliseconds.
*/
uint64_t getPosition() const {
ob_error *error = nullptr;
uint64_t position = ob_playback_device_get_position(impl_, &error);
Error::handle(&error);
return position;
}
/**
* @brief Get the duration of the playback device.
* @return The duration of the playback device, in milliseconds.
*/
uint64_t getDuration() const {
ob_error *error = nullptr;
uint64_t duration = ob_playback_device_get_duration(impl_, &error);
Error::handle(&error);
return duration;
}
private:
static void playbackStatusCallback(OBPlaybackStatus status, void *userData) {
auto *playbackDevice = static_cast<PlaybackDevice *>(userData);
if(playbackDevice && playbackDevice->callback_) {
playbackDevice->callback_(status);
}
}
private:
PlaybackStatusChangeCallback callback_;
};
} // namespace ob
@@ -128,7 +128,7 @@ public:
* OB_STREAM_VIDEO,
* OB_STREAM_DEPTH,
* OB_STREAM_COLOR,
* OB_STREAM_IR,
* OB_STREAM_IR,
* OB_STREAM_IR_LEFT,
* OB_STREAM_IR_RIGHT,
*
@@ -17,7 +17,7 @@
namespace ob {
class Device;
class CoordinateTransformHelper {
class CoordinateTransformHelper {
public:
/**
* @brief Transform a 3d point of a source coordinate system into a 3d point of the target coordinate system.
@@ -29,8 +29,8 @@ public:
* @return bool Transform result
*/
static bool transformation3dto3d(const OBPoint3f source_point3f, OBExtrinsic extrinsic, OBPoint3f *target_point3f) {
ob_error *error = NULL;
bool result = ob_transformation_3d_to_3d(source_point3f, extrinsic, target_point3f, &error);
ob_error *error = NULL;
bool result = ob_transformation_3d_to_3d(source_point3f, extrinsic, target_point3f, &error);
Error::handle(&error);
return result;
}
@@ -48,8 +48,8 @@ public:
*/
static bool transformation2dto3d(const OBPoint2f source_point2f, const float source_depth_pixel_value, const OBCameraIntrinsic source_intrinsic,
OBExtrinsic extrinsic, OBPoint3f *target_point3f) {
ob_error *error = NULL;
bool result = ob_transformation_2d_to_3d(source_point2f, source_depth_pixel_value, source_intrinsic, extrinsic, target_point3f, &error);
ob_error *error = NULL;
bool result = ob_transformation_2d_to_3d(source_point2f, source_depth_pixel_value, source_intrinsic, extrinsic, target_point3f, &error);
Error::handle(&error);
return result;
}
@@ -66,9 +66,9 @@ public:
* @return bool Transform result
*/
static bool transformation3dto2d(const OBPoint3f source_point3f, const OBCameraIntrinsic target_intrinsic, const OBCameraDistortion target_distortion,
OBExtrinsic extrinsic, OBPoint2f *target_point2f) {
ob_error *error = NULL;
bool result = ob_transformation_3d_to_2d(source_point3f, target_intrinsic, target_distortion, extrinsic, target_point2f, &error);
OBExtrinsic extrinsic, OBPoint2f *target_point2f) {
ob_error *error = NULL;
bool result = ob_transformation_3d_to_2d(source_point3f, target_intrinsic, target_distortion, extrinsic, target_point2f, &error);
Error::handle(&error);
return result;
}
@@ -90,7 +90,7 @@ public:
static bool transformation2dto2d(const OBPoint2f source_point2f, const float source_depth_pixel_value, const OBCameraIntrinsic source_intrinsic,
const OBCameraDistortion source_distortion, const OBCameraIntrinsic target_intrinsic,
const OBCameraDistortion target_distortion, OBExtrinsic extrinsic, OBPoint2f *target_point2f) {
ob_error *error = NULL;
ob_error *error = NULL;
bool result = ob_transformation_2d_to_2d(source_point2f, source_depth_pixel_value, source_intrinsic, source_distortion, target_intrinsic,
target_distortion, extrinsic, target_point2f, &error);
Error::handle(&error);
@@ -101,8 +101,8 @@ public:
// The following interfaces are deprecated and are retained here for compatibility purposes.
static bool calibration3dTo3d(const OBCalibrationParam calibrationParam, const OBPoint3f sourcePoint3f, const OBSensorType sourceSensorType,
const OBSensorType targetSensorType, OBPoint3f *targetPoint3f) {
ob_error *error = NULL;
bool result = ob_calibration_3d_to_3d(calibrationParam, sourcePoint3f, sourceSensorType, targetSensorType, targetPoint3f, &error);
ob_error *error = NULL;
bool result = ob_calibration_3d_to_3d(calibrationParam, sourcePoint3f, sourceSensorType, targetSensorType, targetPoint3f, &error);
Error::handle(&error);
return result;
}
@@ -110,15 +110,16 @@ public:
static bool calibration2dTo3d(const OBCalibrationParam calibrationParam, const OBPoint2f sourcePoint2f, const float sourceDepthPixelValue,
const OBSensorType sourceSensorType, const OBSensorType targetSensorType, OBPoint3f *targetPoint3f) {
ob_error *error = NULL;
bool result = ob_calibration_2d_to_3d(calibrationParam, sourcePoint2f, sourceDepthPixelValue, sourceSensorType, targetSensorType, targetPoint3f, &error);
bool result =
ob_calibration_2d_to_3d(calibrationParam, sourcePoint2f, sourceDepthPixelValue, sourceSensorType, targetSensorType, targetPoint3f, &error);
Error::handle(&error);
return result;
}
static bool calibration3dTo2d(const OBCalibrationParam calibrationParam, const OBPoint3f sourcePoint3f, const OBSensorType sourceSensorType,
const OBSensorType targetSensorType, OBPoint2f *targetPoint2f) {
ob_error *error = NULL;
bool result = ob_calibration_3d_to_2d(calibrationParam, sourcePoint3f, sourceSensorType, targetSensorType, targetPoint2f, &error);
ob_error *error = NULL;
bool result = ob_calibration_3d_to_2d(calibrationParam, sourcePoint3f, sourceSensorType, targetSensorType, targetPoint2f, &error);
Error::handle(&error);
return result;
}
@@ -126,7 +127,8 @@ public:
static bool calibration2dTo2d(const OBCalibrationParam calibrationParam, const OBPoint2f sourcePoint2f, const float sourceDepthPixelValue,
const OBSensorType sourceSensorType, const OBSensorType targetSensorType, OBPoint2f *targetPoint2f) {
ob_error *error = NULL;
bool result = ob_calibration_2d_to_2d(calibrationParam, sourcePoint2f, sourceDepthPixelValue, sourceSensorType, targetSensorType, targetPoint2f, &error);
bool result =
ob_calibration_2d_to_2d(calibrationParam, sourcePoint2f, sourceDepthPixelValue, sourceSensorType, targetSensorType, targetPoint2f, &error);
Error::handle(&error);
return result;
}
@@ -138,15 +140,15 @@ public:
// unsafe operation, need to cast const to non-const
auto unConstImpl = const_cast<ob_frame *>(depthFrame->getImpl());
auto result = transformation_depth_frame_to_color_camera(device->getImpl() , unConstImpl, targetColorCameraWidth, targetColorCameraHeight, &error);
auto result = transformation_depth_frame_to_color_camera(device->getImpl(), unConstImpl, targetColorCameraWidth, targetColorCameraHeight, &error);
Error::handle(&error);
return std::make_shared<ob::Frame>(result);
}
static bool transformationInitXYTables(const OBCalibrationParam calibrationParam, const OBSensorType sensorType, float *data, uint32_t *dataSize,
OBXYTables *xyTables) {
ob_error *error = NULL;
bool result = transformation_init_xy_tables(calibrationParam, sensorType, data, dataSize, xyTables, &error);
ob_error *error = NULL;
bool result = transformation_init_xy_tables(calibrationParam, sensorType, data, dataSize, xyTables, &error);
Error::handle(&error);
return result;
}
@@ -157,11 +159,32 @@ public:
Error::handle(&error, false);
}
static void transformationDepthToRGBDPointCloud(OBXYTables *xyTables, const void *depthImageData, const void *colorImageData, void *pointCloudData){
static void transformationDepthToRGBDPointCloud(OBXYTables *xyTables, const void *depthImageData, const void *colorImageData, void *pointCloudData) {
ob_error *error = NULL;
transformation_depth_to_rgbd_pointcloud(xyTables, depthImageData, colorImageData, pointCloudData, &error);
Error::handle(&error, false);
}
};
} // namespace ob
class PointCloudHelper {
public:
/**
* @brief save point cloud to ply file.
*
* @param[in] fileName Point cloud save path
* @param[in] frame Point cloud frame
* @param[in] saveBinary Binary or textual,true: binary, false: textual
* @param[in] useMesh Save mesh or not, true: save as mesh, false: not save as mesh
* @param[in] meshThreshold Distance threshold for creating faces in point cloud,default value :50
*
* @return bool save point cloud result
*/
static bool savePointcloudToPly(const char *fileName, std::shared_ptr<ob::Frame> frame, bool saveBinary, bool useMesh, float meshThreshold) {
ob_error *error = NULL;
auto unConstImpl = const_cast<ob_frame *>(frame->getImpl());
bool result = ob_save_pointcloud_to_ply(fileName, unConstImpl, saveBinary, useMesh, meshThreshold, &error);
Error::handle(&error, false);
return result;
}
};
} // namespace ob