mirror of
https://github.com/orbbec/OrbbecSDK_ROS2.git
synced 2026-10-09 06:17:46 +08:00
Update SDK version to v2.4.1
This commit is contained in:
@@ -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 {
|
||||
@@ -127,7 +127,7 @@ public:
|
||||
/**
|
||||
* @brief Activates device clock synchronization to synchronize the clock of the host and all created devices (if supported).
|
||||
*
|
||||
* @param repeatInterval The interval for auto-repeated synchronization, in milliseconds. If the value is 0, synchronization is performed only once.
|
||||
* @param repeatIntervalMsec The interval for auto-repeated synchronization, in milliseconds. If the value is 0, synchronization is performed only once.
|
||||
*/
|
||||
void enableDeviceClockSync(uint64_t repeatIntervalMsec) const {
|
||||
ob_error *error = nullptr;
|
||||
@@ -146,12 +146,12 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief For linux, there are two ways to enable the UVC backend: libuvc and libusb. This function is used to set the backend type.
|
||||
* @brief For linux, there are two ways to enable the UVC backend: libuvc and v4l2. This function is used to set the backend type.
|
||||
* @brief It is effective when the new device is created.
|
||||
*
|
||||
* @attention This interface is only available for Linux.
|
||||
*
|
||||
* @param[in] backend_type The backend type to be used.
|
||||
* @param[in] type The backend type to be used.
|
||||
*/
|
||||
void setUvcBackendType(OBUvcBackendType type) const {
|
||||
ob_error *error = nullptr;
|
||||
@@ -202,7 +202,7 @@ public:
|
||||
* @param callback The callback function.
|
||||
*/
|
||||
static void setLoggerToCallback(OBLogSeverity severity, LogCallback callback) {
|
||||
ob_error *error = nullptr;
|
||||
ob_error *error = nullptr;
|
||||
Context::getLogCallback() = callback;
|
||||
ob_set_logger_to_callback(severity, &Context::logCallback, &Context::getLogCallback(), &error);
|
||||
Error::handle(&error);
|
||||
@@ -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.
|
||||
*
|
||||
@@ -240,7 +240,7 @@ private:
|
||||
}
|
||||
|
||||
// Lazy initialization of the logcallback_. The purpose is to initialize logcallback_ in .hpp
|
||||
static LogCallback& getLogCallback() {
|
||||
static LogCallback &getLogCallback() {
|
||||
static LogCallback logCallback_ = nullptr;
|
||||
return logCallback_;
|
||||
}
|
||||
@@ -249,4 +249,3 @@ private:
|
||||
#define enableMultiDeviceSync enableDeviceClockSync
|
||||
};
|
||||
} // namespace ob
|
||||
|
||||
|
||||
@@ -292,6 +292,30 @@ public:
|
||||
Error::handle(&error);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the customer data type of a device property
|
||||
*
|
||||
* @param data The data to set
|
||||
* @param dataSize The size of the data to set,the maximum length cannot exceed 65532 bytes.
|
||||
*/
|
||||
void writeCustomerData(const void *data, uint32_t dataSize) {
|
||||
ob_error *error = nullptr;
|
||||
ob_device_write_customer_data(impl_, data, dataSize, &error);
|
||||
Error::handle(&error);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the customer data type of a device property
|
||||
*
|
||||
* @param data The property data obtained
|
||||
* @param dataSize The size of the data obtained
|
||||
*/
|
||||
void readCustomerData(void *data, uint32_t *dataSize) {
|
||||
ob_error *error = nullptr;
|
||||
ob_device_read_customer_data(impl_, data, dataSize, &error);
|
||||
Error::handle(&error);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the number of properties supported by the device
|
||||
*
|
||||
@@ -491,7 +515,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 +588,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.
|
||||
*/
|
||||
@@ -755,7 +779,7 @@ public:
|
||||
* @param[in] sendData The data to be sent to the device.
|
||||
* @param[in] sendDataSize The size of the data to be sent to the device.
|
||||
* @param[out] receiveData The data received from the device.
|
||||
* @param[in out] receiveDataSize The requeseted size of the data received from the device, and the actual size of the data received from the device.
|
||||
* @param[in,out] receiveDataSize The requeseted size of the data received from the device, and the actual size of the data received from the device.
|
||||
*/
|
||||
void sendAndReceiveData(const uint8_t *sendData, uint32_t sendDataSize, uint8_t *receiveData, uint32_t *receiveDataSize) const {
|
||||
ob_error *error = nullptr;
|
||||
@@ -919,7 +943,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 +1165,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 +1189,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 +1239,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
|
||||
*
|
||||
@@ -1379,9 +1418,9 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the number of device presets in the list
|
||||
* @brief Get the number of camera parameters in the list.
|
||||
*
|
||||
* @return uint32_t the number of device presets in the list
|
||||
* @return uint32_t the number of camera parameters in the list.
|
||||
*/
|
||||
uint32_t getCount() {
|
||||
ob_error *error = nullptr;
|
||||
|
||||
@@ -22,10 +22,12 @@ private:
|
||||
*
|
||||
* @attention This constructor should not be called directly, use the handle() function instead.
|
||||
*
|
||||
* @param error
|
||||
* @param error The ob_error object
|
||||
*/
|
||||
explicit Error(ob_error *error) : impl_(error) {};
|
||||
|
||||
Error& operator=(const Error&) = default;
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief A static function to handle the ob_error and throw an exception if needed.
|
||||
|
||||
@@ -311,7 +311,7 @@ public:
|
||||
* @brief Some private filters require an activation key to be activated, its depends on the vendor of the filter.
|
||||
*
|
||||
* @param name The name of the filter.
|
||||
* @param activation_key The activation key of the filter.
|
||||
* @param activationKey The activation key of the filter.
|
||||
*/
|
||||
static std::shared_ptr<Filter> createPrivateFilter(const std::string &name, const std::string &activationKey) {
|
||||
ob_error *error = nullptr;
|
||||
@@ -352,7 +352,7 @@ public:
|
||||
/**
|
||||
* @brief Set the output pointcloud frame format.
|
||||
*
|
||||
* @param type The point cloud frame format: OB_FORMAT_POINT or OB_FORMAT_RGB_POINT
|
||||
* @param format The point cloud frame format: OB_FORMAT_POINT or OB_FORMAT_RGB_POINT
|
||||
*/
|
||||
void setCreatePointFormat(OBFormat format) {
|
||||
setConfigValue("pointFormat", static_cast<double>(format));
|
||||
@@ -534,7 +534,7 @@ public:
|
||||
/**
|
||||
* @brief Set the sequenceId filter params.
|
||||
*
|
||||
* @param sequence id to pass the filter.
|
||||
* @param sequence_id id to pass the filter.
|
||||
*/
|
||||
void selectSequenceId(int sequence_id) {
|
||||
setConfigValue("sequenceid", static_cast<double>(sequence_id));
|
||||
@@ -580,7 +580,7 @@ public:
|
||||
/**
|
||||
* @brief Set the decimation filter scale value.
|
||||
*
|
||||
* @param type The decimation filter scale value.
|
||||
* @param value The decimation filter scale value.
|
||||
*/
|
||||
void setScaleValue(uint8_t value) {
|
||||
setConfigValue("decimate", static_cast<double>(value));
|
||||
@@ -796,7 +796,6 @@ public:
|
||||
/**
|
||||
* @brief Set the HoleFillingFilter mode.
|
||||
*
|
||||
* @param[in] filter A holefilling_filter object.
|
||||
* @param mode OBHoleFillingMode, OB_HOLE_FILL_TOP,OB_HOLE_FILL_NEAREST or OB_HOLE_FILL_FAREST.
|
||||
*/
|
||||
void setFilterMode(OBHoleFillingMode mode) {
|
||||
@@ -830,7 +829,7 @@ public:
|
||||
/**
|
||||
* @brief Set the noise removal filter params.
|
||||
*
|
||||
* @param[in] params ob_noise_removal_filter_params.
|
||||
* @param[in] filterParams ob_noise_removal_filter_params.
|
||||
*/
|
||||
void setFilterParams(OBNoiseRemovalFilterParams filterParams) {
|
||||
setConfigValue("max_size", static_cast<double>(filterParams.max_size));
|
||||
|
||||
@@ -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
|
||||
@@ -902,11 +929,11 @@ public:
|
||||
* @attention The buffer is owned by the caller, and will not be destroyed by the frame object. The user should ensure that the buffer is valid and not
|
||||
* modified.
|
||||
*
|
||||
* @param[in] frame_type Frame object type.
|
||||
* @param[in] frameType Frame object type.
|
||||
* @param[in] format Frame object format.
|
||||
* @param[in] buffer Frame object buffer.
|
||||
* @param[in] buffer_size Frame object buffer size.
|
||||
* @param[in] destroyCallback Destroy callback, will be called when the frame object is destroyed.
|
||||
* @param[in] bufferSize Frame object buffer size.
|
||||
*
|
||||
* @return std::shared_ptr<Frame> The created frame object.
|
||||
*/
|
||||
@@ -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;
|
||||
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
* If no parameters are specified, the stream will be enabled with default resolution settings.
|
||||
* Users who wish to set custom resolutions should refer to the product manual, as available resolutions vary by camera model.
|
||||
*
|
||||
* @param type The video stream type.
|
||||
* @param streamType The video stream type.
|
||||
* @param width The video stream width (default is OB_WIDTH_ANY, which selects the default resolution).
|
||||
* @param height The video stream height (default is OB_HEIGHT_ANY, which selects the default resolution).
|
||||
* @param fps The video stream frame rate (default is OB_FPS_ANY, which selects the default frame rate).
|
||||
@@ -182,7 +182,7 @@ public:
|
||||
* @brief Disable a sensor stream to be used in the pipeline.
|
||||
* @brief Will convert sensor type to stream type automatically.
|
||||
*
|
||||
* @param sensorType
|
||||
* @param sensorType The sensor configuration to be disabled
|
||||
*/
|
||||
void disableStream(OBSensorType sensorType) const {
|
||||
auto streamType = ob::TypeHelper::convertSensorTypeToStreamType(sensorType);
|
||||
@@ -346,7 +346,7 @@ public:
|
||||
/**
|
||||
* @brief Wait for frameset
|
||||
*
|
||||
* @param timeout_ms The waiting timeout in milliseconds
|
||||
* @param timeoutMs The waiting timeout in milliseconds
|
||||
* @return std::shared_ptr<FrameSet> The waiting frameset data
|
||||
*/
|
||||
std::shared_ptr<FrameSet> waitForFrameset(uint32_t timeoutMs = 1000) const {
|
||||
|
||||
@@ -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
|
||||
@@ -51,9 +51,9 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the format of the stream
|
||||
* @brief Get the format of the stream.
|
||||
*
|
||||
* @return OBFormat return the format of the stream
|
||||
* @return OBFormat return the format of the stream.
|
||||
*/
|
||||
OBFormat getFormat() const {
|
||||
ob_error *error = nullptr;
|
||||
@@ -63,9 +63,9 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the type of stream
|
||||
* @brief Get the type of stream.
|
||||
*
|
||||
* @return OBStreamType return the type of the stream
|
||||
* @return OBStreamType return the type of the stream.
|
||||
*/
|
||||
OBStreamType getType() const {
|
||||
ob_error *error = nullptr;
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the extrinsic parameters from current stream profile to the given target stream profile
|
||||
* @brief Get the extrinsic parameters from current stream profile to the given target stream profile.
|
||||
*
|
||||
* @return OBExtrinsic Return the extrinsic parameters.
|
||||
*/
|
||||
@@ -87,17 +87,41 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if frame object is compatible with the given type
|
||||
* @brief Set the extrinsic parameters from current stream profile to the given target stream profile.
|
||||
*
|
||||
* @tparam target Target stream profile.
|
||||
* @tparam extrinsic The extrinsic.
|
||||
*/
|
||||
void bindExtrinsicTo(std::shared_ptr<StreamProfile> target, const OBExtrinsic &extrinsic) {
|
||||
ob_error *error = nullptr;
|
||||
ob_stream_profile_set_extrinsic_to(const_cast<ob_stream_profile_t *>(impl_), const_cast<const ob_stream_profile_t *>(target->getImpl()), extrinsic, &error);
|
||||
Error::handle(&error);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the extrinsic parameters from current stream profile to the given target stream type.
|
||||
*
|
||||
* @tparam targetStreamType Target stream type.
|
||||
* @tparam extrinsic The extrinsic.
|
||||
*/
|
||||
void bindExtrinsicTo(const OBStreamType &targetStreamType, const OBExtrinsic &extrinsic) {
|
||||
ob_error *error = nullptr;
|
||||
ob_stream_profile_set_extrinsic_to_type(const_cast<ob_stream_profile_t *>(impl_),targetStreamType,extrinsic, &error);
|
||||
Error::handle(&error);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if frame object is compatible with the given type.
|
||||
*
|
||||
* @tparam T Given type
|
||||
* @return bool return result
|
||||
* @tparam T Given type.
|
||||
* @return bool return result.
|
||||
*/
|
||||
template <typename T> bool is() const;
|
||||
|
||||
/**
|
||||
* @brief Converts object type to target type
|
||||
* @brief Converts object type to target type.
|
||||
*
|
||||
* @tparam T Target type
|
||||
* @tparam T Target type.
|
||||
* @return std::shared_ptr<T> Return the result. Throws an exception if conversion is not possible.
|
||||
*/
|
||||
template <typename T> std::shared_ptr<T> as() {
|
||||
@@ -109,9 +133,9 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Converts object type to target type (const version)
|
||||
* @brief Converts object type to target type (const version).
|
||||
*
|
||||
* @tparam T Target type
|
||||
* @tparam T Target type.
|
||||
* @return std::shared_ptr<T> Return the result. Throws an exception if conversion is not possible.
|
||||
*/
|
||||
template <typename T> std::shared_ptr<const T> as() const {
|
||||
@@ -192,6 +216,17 @@ public:
|
||||
return intrinsic;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the intrinsic parameters of the stream.
|
||||
*
|
||||
* @param intrinsic The intrinsic parameters.
|
||||
*/
|
||||
void setIntrinsic(const OBCameraIntrinsic &intrinsic) {
|
||||
ob_error *error = nullptr;
|
||||
ob_video_stream_profile_set_intrinsic(const_cast<ob_stream_profile_t *>(impl_), intrinsic, &error);
|
||||
Error::handle(&error);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the distortion parameters of the stream.
|
||||
* @brief Brown distortion model
|
||||
@@ -205,6 +240,17 @@ public:
|
||||
return distortion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the distortion parameters of the stream.
|
||||
*
|
||||
* @param distortion The distortion parameters.
|
||||
*/
|
||||
void setDistortion(const OBCameraDistortion &distortion) {
|
||||
ob_error *error = nullptr;
|
||||
ob_video_stream_profile_set_distortion(const_cast<ob_stream_profile_t *>(impl_), distortion, &error);
|
||||
Error::handle(&error);
|
||||
}
|
||||
|
||||
public:
|
||||
// The following interfaces are deprecated and are retained here for compatibility purposes.
|
||||
uint32_t fps() const {
|
||||
|
||||
@@ -113,7 +113,7 @@ public:
|
||||
* OB_SENSOR_IR_LEFT,
|
||||
* OB_SENSOR_IR_RIGHT,
|
||||
*
|
||||
* @param type
|
||||
* @param type The sensor type
|
||||
* @return true
|
||||
* @return false
|
||||
*/
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user