updata libOrbbecSDK.so , ob_camera_node and CMakeLists.txt

This commit is contained in:
jj
2024-09-04 12:47:36 +08:00
parent 3cd3a7fdd3
commit 9f764c8e57
58 changed files with 6218 additions and 5345 deletions
@@ -6,37 +6,78 @@
*/
#pragma once
#include "libobsensor/h/Context.h"
#include "Types.hpp"
#include "Error.hpp"
#include <functional>
#include <memory>
struct ContextImpl;
namespace ob {
// forward declarations
class Device;
class DeviceInfo;
class DeviceList;
class OB_EXTENSION_API Context {
class Context {
public:
/**
* @brief Type definition for the device changed callback function.
*
* @param removedList The list of removed devices.
* @param addedList The list of added devices.
*/
typedef std::function<void(std::shared_ptr<DeviceList> removedList, std::shared_ptr<DeviceList> addedList)> DeviceChangedCallback;
/**
* @brief Type definition for the log output callback function.
*
* @param severity The current callback log level.
* @param logMsg The log message.
*/
typedef std::function<void(OBLogSeverity severity, const char *logMsg)> LogCallback;
private:
std::unique_ptr<ContextImpl> impl_;
ob_context *impl_ = nullptr;
DeviceChangedCallback deviceChangedCallback_;
static LogCallback logCallback_;
public:
/**
* @brief Context constructor.
* @brief The Context class is a management class that describes the runtime of the SDK. It is responsible for applying and releasing resources for the SDK.
* The context has the ability to manage multiple devices, enumerate devices, monitor device callbacks, and enable functions such as multi-device
* synchronization.
*
* @param[in] configPath The path to the configuration file. If the path is empty, the default configuration will be used.
*/
Context(const char *configPath = "");
virtual ~Context() noexcept;
explicit Context(const char *configPath = "") {
ob_error *error = nullptr;
impl_ = ob_create_context_with_config(configPath, &error);
Error::handle(&error);
}
/**
* @brief Context destructor.
*/
~Context() noexcept {
ob_error *error = nullptr;
ob_delete_context(impl_, &error);
Error::handle(&error, false);
}
/**
* @brief Queries the enumerated device list.
*
* @return std::shared_ptr<DeviceList> A pointer to the device list class.
*/
std::shared_ptr<DeviceList> queryDeviceList();
std::shared_ptr<DeviceList> queryDeviceList() const {
ob_error *error = nullptr;
auto list = ob_query_device_list(impl_, &error);
Error::handle(&error);
return std::make_shared<DeviceList>(list);
}
/**
* @brief enable or disable net device enumeration.
@@ -45,55 +86,71 @@ public:
*
* @attention Net device enumeration by gvcp protocol, if the device is not in the same subnet as the host, it will be discovered but cannot be connected.
*
* @param[out] enable true to enable, false to disable
* @param[in] enable true to enable, false to disable
*/
void enableNetDeviceEnumeration(bool enable);
void enableNetDeviceEnumeration(bool enable) const {
ob_error *error = nullptr;
ob_enable_net_device_enumeration(impl_, enable, &error);
Error::handle(&error);
}
/**
* @brief Creates a network device object.
* @brief Creates a network device with the specified IP address and port.
*
* @param address The IP address.
* @param port The port.
* @param[in] address The IP address, ipv4 only. such as "192.168.1.10"
* @param[in] port The port number.
* @return std::shared_ptr<Device> The created device object.
*/
std::shared_ptr<Device> createNetDevice(const char *address, uint16_t port);
/**
* @brief Changes the IP configuration of a network device.
*
* @param deviceUid The device unique ID, which is the network device MAC address. It can be obtained through the @ref DeviceList::uid() function.
* @param config The new IP configuration.
*/
void changeNetDeviceIpConfig(const char *deviceUid, const OBNetIpConfig &config);
using DeviceChangedCallback = std::function<void(std::shared_ptr<DeviceList> removedList, std::shared_ptr<DeviceList> addedList)>;
std::shared_ptr<Device> createNetDevice(const char *address, uint16_t port) const {
ob_error *error = nullptr;
auto device = ob_create_net_device(impl_, address, port, &error);
Error::handle(&error);
return std::make_shared<Device>(device);
}
/**
* @brief Set the device plug-in callback function.
*
* @param callback The function triggered when the device is plugged and unplugged.
*/
void setDeviceChangedCallback(DeviceChangedCallback callback);
void setDeviceChangedCallback(DeviceChangedCallback callback) {
deviceChangedCallback_ = callback;
ob_error *error = nullptr;
ob_set_device_changed_callback(impl_, &Context::deviceChangedCallback, this, &error);
Error::handle(&error);
}
/**
* @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.
*/
void enableDeviceClockSync(uint64_t repeatInterval);
#define enableMultiDeviceSync enableDeviceClockSync
void enableDeviceClockSync(uint64_t repeatInterval) const {
ob_error *error = nullptr;
ob_enable_device_clock_sync(impl_, repeatInterval, &error);
Error::handle(&error);
}
/**
* @brief Frees idle memory from the internal frame memory pool.
* @brief The SDK includes an internal frame memory pool that caches memory allocated for frames received from devices.
*/
void freeIdleMemory();
void freeIdleMemory() const {
ob_error *error = nullptr;
ob_free_idle_memory(impl_, &error);
Error::handle(&error);
}
/**
* @brief Set the level of the global log, which affects both the log level output to the terminal and output to the file.
* @brief Set the level of the global log, which affects both the log level output to the console, output to the file and output the user defined callback.
*
* @param severity The log output level.
*/
static void setLoggerSeverity(OBLogSeverity severity);
static void setLoggerSeverity(OBLogSeverity severity) {
ob_error *error = nullptr;
ob_set_logger_severity(severity, &error);
Error::handle(&error);
}
/**
* @brief Set log output to a file.
@@ -102,22 +159,22 @@ public:
* @param directory The log file output path. If the path is empty, the existing settings will continue to be used (if the existing configuration is also
* empty, the log will not be output to the file).
*/
static void setLoggerToFile(OBLogSeverity severity, const char *directory);
static void setLoggerToFile(OBLogSeverity severity, const char *directory) {
ob_error *error = nullptr;
ob_set_logger_to_file(severity, directory, &error);
Error::handle(&error);
}
/**
* @brief Set log output to the terminal.
* @brief Set log output to the console.
*
* @param severity The log level output to the terminal.
* @param severity The log level output to the console.
*/
static void setLoggerToConsole(OBLogSeverity severity);
/**
* @brief Log output callback function.
*
* @param severity The current callback log level.
* @param logMsg The log message.
*/
using LogCallback = std::function<void(OBLogSeverity severity, const char *logMsg)>;
static void setLoggerToConsole(OBLogSeverity severity) {
ob_error *error = nullptr;
ob_set_logger_to_console(severity, &error);
Error::handle(&error);
}
/**
* @brief Set the logger to callback.
@@ -125,23 +182,31 @@ public:
* @param severity The callback log level.
* @param callback The callback function.
*/
static void setLoggerToCallback(OBLogSeverity severity, LogCallback callback);
static void setLoggerToCallback(OBLogSeverity severity, LogCallback callback) {
ob_error *error = nullptr;
Context::logCallback_ = callback;
ob_set_logger_to_callback(severity, &Context::logCallback, &Context::logCallback_, &error);
Error::handle(&error);
}
/**
* @brief Loads a license file.
*
* @param filePath The license file path.
* @param key The decryption key.
*/
static void loadLicense(const char *filePath, const char *key = OB_DEFAULT_DECRYPT_KEY);
private:
static void deviceChangedCallback(ob_device_list *removedList, ob_device_list *addedList, void *userData) {
auto ctx = static_cast<Context *>(userData);
if(ctx && ctx->deviceChangedCallback_) {
auto removed = std::make_shared<DeviceList>(removedList);
auto added = std::make_shared<DeviceList>(addedList);
ctx->deviceChangedCallback_(removed, added);
}
}
/**
* @brief Loads a license from data.
*
* @param data The license data.
* @param dataLen The license data length.
* @param key The decryption key.
*/
static void loadLicenseFromData(const char *data, uint32_t dataLen, const char *key = OB_DEFAULT_DECRYPT_KEY);
static void logCallback(OBLogSeverity severity, const char *logMsg, void *userData) {
auto cb = static_cast<LogCallback *>(userData);
if(cb) {
(*cb)(severity, logMsg);
}
}
// for backward compatibility
#define enableMultiDeviceSync enableDeviceClockSync
};
} // namespace ob
File diff suppressed because it is too large Load Diff
@@ -6,44 +6,109 @@
#pragma once
#include "Types.hpp"
#include "libobsensor/h/Error.h"
#include <memory>
struct ErrorImpl;
namespace ob {
class OB_EXTENSION_API Error {
class Error : public std::exception {
private:
std::unique_ptr<ErrorImpl> impl_;
ob_error *impl_;
/**
* @brief Construct a new Error object
*
* @attention This constructor should not be called directly, use the handle() function instead.
*
* @param error
*/
explicit Error(ob_error *error) : impl_(error) {};
public:
Error(std::unique_ptr<ErrorImpl> impl) noexcept;
/**
* @brief A static function to handle the ob_error and throw an exception if needed.
*
* @param error The ob_error pointer to be handled.
* @param throw_exception A boolean value to indicate whether to throw an exception or not, the default value is true.
*/
static void handle(ob_error **error, bool throw_exception = true) {
if(!error || !*error) { // no error
return;
}
Error(const Error &error) noexcept;
~Error() noexcept;
if(throw_exception) {
throw Error(*error);
}
else {
ob_delete_error(*error);
*error = nullptr;
}
}
/**
* @brief Get the detailed error logs of SDK internal exceptions.
* @return A C-style string containing the error message.
* @brief Destroy the Error object
*/
const char *getMessage() const noexcept;
~Error() override {
if(impl_) {
ob_delete_error(impl_);
impl_ = nullptr;
}
}
/**
* @brief Get the exception type of the error, which can be used to determine which module is abnormal.
* @return The OBExceptionType enum value.
* @brief Returns the error message of the exception.
*
* @return const char* The error message.
*/
OBExceptionType getExceptionType() const noexcept;
const char *what() const noexcept override {
return impl_->message;
}
/**
* @brief Get the name of the error function.
* @return A C-style string containing the name of the error function.
* @brief Returns the exception type of the exception.
* @brief Read the comments of the OBExceptionType enum in the libobsensor/h/ObTypes.h file for more information.
*
* @return OBExceptionType The exception type.
*/
const char *getName() const noexcept;
OBExceptionType getExceptionType() const noexcept {
return impl_->exception_type;
}
/**
* @brief Get the parameter passed to the error interface.
* @return A C-style string containing the error interface parameter.
* @brief Returns the name of the function where the exception occurred.
*
* @return const char* The function name.
*/
const char *getArgs() const noexcept;
const char *getFunction() const noexcept {
return impl_->function;
}
/**
* @brief Returns the arguments of the function where the exception occurred.
*
* @return const char* The arguments.
*/
const char *getArgs() const noexcept {
return impl_->args;
}
/**
* @brief Returns the error message of the exception.
* @brief It is recommended to use the what() function instead.
*
* @return const char* The error message.
*/
const char *getMessage() const noexcept {
return impl_->message;
}
/**
* @brief (Deprecated) Returns the name of the function where the exception occurred.
* @brief Use the getFunction() function instead.
*
* @return const char* The function name.
*/
OB_DEPRECATED const char *getName() const noexcept {
return impl_->function;
}
};
} // namespace ob
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -1,335 +1,469 @@
/**
* @file Pipeline.hpp
* @brief The SDK's advanced API type can quickly implement switching streaming and frame synchronization
* operations.
* @brief The SDK's advanced API type can quickly implement switching streaming and frame
* synchronization operations.
*/
#pragma once
#include "Types.hpp"
#include "Frame.hpp"
#include "Device.hpp"
#include "StreamProfile.hpp"
#include "libobsensor/h/Pipeline.h"
#include "libobsensor/hpp/Types.hpp"
#include "libobsensor/hpp/TypeHelper.hpp"
#include <functional>
#include <memory>
struct PipelineImpl;
struct ConfigImpl;
#include <functional>
namespace ob {
class FrameSet;
class Frame;
class Device;
class Playback;
class DeviceInfo;
class Config;
class StreamProfile;
class StreamProfileList;
typedef std::function<void(std::shared_ptr<FrameSet> frame)> FrameSetCallback;
class OB_EXTENSION_API Pipeline {
private:
std::unique_ptr<PipelineImpl> impl_;
public:
/**
* @brief Pipeline is a high-level interface for applications, algorithms related RGBD data streams. Pipeline can provide alignment inside and synchronized
* FrameSet. Pipeline() no parameter version, which opens the first device in the list of devices connected to the OS by default. If the application has
* obtained the device through the DeviceList, opening the Pipeline() at this time will throw an exception that the device has been created.
*/
Pipeline();
/**
* @brief
* Pipeline(std::shared_ptr< Device > device ) Function for multi-device operations. Multiple devices need to be obtained through DeviceList, and the device
* and pipeline are bound through this interface.
*/
Pipeline(std::shared_ptr<Device> device);
/**
* @brief Construct a pipeline for playback of recorded stream files
*
* @param filename The file path of the recorded stream file to be played back
*/
Pipeline(const char *filename);
/**
* @brief Destroy the pipeline object
*/
~Pipeline() noexcept;
/**
* @brief Start the pipeline with configuration parameters
*
* @param config The parameter configuration of the pipeline
*/
void start(std::shared_ptr<Config> config);
/**
* @brief Start the pipeline with default configuration parameters
*/
void start();
/**
* @brief Start the pipeline and set the frameset data callback
*
* @param config The configuration of the pipeline
* @param callback The callback to be triggered when all frame data in the frameset arrives
*/
void start(std::shared_ptr<Config> config, FrameSetCallback callback);
/**
* @brief Stop the pipeline
*/
void stop();
/**
* @brief get Enabled Stream Profile List,It must be called after the pipeline is started, otherwise it will return an empty list
*/
std::shared_ptr<StreamProfileList> getEnabledStreamProfileList();
/**
* @brief Get the pipeline configuration parameters
* @brief Returns the default configuration if the user has not configured it
*
* @return std::shared_ptr<Config> The configured parameters
*/
std::shared_ptr<Config> getConfig();
/**
* @brief Wait for frameset data
*
* @param timeout_ms The waiting timeout in milliseconds
* @return std::shared_ptr<FrameSet> The waiting frameset data
*/
std::shared_ptr<FrameSet> waitForFrames(uint32_t timeout_ms = 1000);
/**
* @brief Get the device object
*
* @return std::shared_ptr<Device> The device object
*/
std::shared_ptr<Device> getDevice();
/**
* @brief Get the playback object
*
* @return std::shared_ptr<Playback> The playback object
*/
std::shared_ptr<Playback> getPlayback();
/**
* @brief Get the stream profile of the specified sensor
*
* @param sensorType The type of sensor
* @return std::shared_ptr<StreamProfileList> The stream profile list
*/
std::shared_ptr<StreamProfileList> getStreamProfileList(OBSensorType sensorType);
/**
* @brief Turn on frame synchronization
*/
void enableFrameSync();
/**
* @brief Turn off frame synchronization
*/
void disableFrameSync();
/**
* @brief Get the camera parameters
*
* @note If D2C is enabled, it will return the camera parameters after D2C. If not, it will return the default parameters.
*
* @return OBCameraParam The camera parameters
*/
OBCameraParam getCameraParam();
/**
* @brief Get camera parameters by entering color and depth resolution
* @attention If D2C is enabled, it will return the camera parameters after D2C, if not, it will return to the default parameters
*
* @param colorWidth Width of color resolution
* @param colorHeight High of color resolution
* @param depthWidth Width of depth resolution
* @param depthHeight High of depth resolution
*
* @return OBCameraParam returns camera parameters
*/
OBCameraParam getCameraParamWithProfile(uint32_t colorWidth, uint32_t colorHeight, uint32_t depthWidth, uint32_t depthHeight);
/**
* @brief Get the calibration parameters
*
* @param config The configured parameters
*
* @return OBCalibrationParam The calibration parameters
*/
OBCalibrationParam getCalibrationParam(std::shared_ptr<Config> config);
/**
* @brief Return a list of D2C-enabled depth sensor resolutions corresponding to the input color sensor resolution
*
* @param colorProfile The input color sensor resolution
* @param alignMode The input align mode
* @return std::shared_ptr<StreamProfileList> A list of depth sensor resolutions
*/
std::shared_ptr<StreamProfileList> getD2CDepthProfileList(std::shared_ptr<StreamProfile> colorProfile, OBAlignMode alignMode);
/**
* @brief Get the valid area between the minimum distance and maximum distance after D2C
*
* @param minimumDistance The minimum working distance
* @param maximumDistance The maximum working distance (optional)
* @return OBRect The area information valid after D2C at the working distance
*/
OBRect getD2CValidArea(uint32_t minimumDistance, uint32_t maximumDistance = 0);
/**
* @brief Dynamically switch the corresponding config configuration
*
* @param config The updated config configuration
*/
void switchConfig(std::shared_ptr<Config> config);
/**
* @brief Start recording
*
* @param filename The name of the record file
*/
void startRecord(const char *filename);
/**
* @brief Stop recording
*/
void stopRecord();
};
/**
* @brief Config class for configuring pipeline parameters
*
* The Config class provides an interface for configuring pipeline parameters.
*/
class OB_EXTENSION_API Config {
private:
std::unique_ptr<ConfigImpl> impl_;
class Config {
private:
ob_config_t *impl_;
public:
/**
* @brief Construct a new Config object
*/
Config();
public:
/**
* @brief Construct a new Config object
*/
Config() {
ob_error *error = nullptr;
impl_ = ob_create_config(&error);
Error::handle(&error);
}
/**
* @brief Destroy the Config object
*/
~Config() noexcept;
explicit Config(ob_config_t *impl) : impl_(impl) {}
/**
* @brief Enable a stream to be used in the pipeline
*
* @param streamProfile The stream configuration to be enabled
*/
void enableStream(std::shared_ptr<StreamProfile> streamProfile);
/**
* @brief Destroy the Config object
*/
~Config() noexcept {
ob_error *error = nullptr;
ob_delete_config(impl_, &error);
Error::handle(&error, false);
}
/**
* @deprecated Use enableStream(std::shared_ptr<StreamProfile> streamProfile) instead
* @brief Enable all streams to be used in the pipeline
*/
void enableAllStream();
ob_config_t *getImpl() const { return impl_; }
/**
* @brief Enable a video stream to be used in the pipeline.
*
* This function allows users to enable a video stream with customizable parameters.
* 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 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).
* @param format The video stream format (default is OB_FORMAT_ANY, which selects the default format).
*/
void enableVideoStream(ob_stream_type type, int width = OB_WIDTH_ANY, int height = OB_HEIGHT_ANY, int fps = OB_FPS_ANY, OBFormat format = OB_FORMAT_ANY);
/**
* @brief enable a stream with a specific stream type
*
* @param streamType The stream type to be enabled
*/
void enableStream(OBStreamType streamType) const {
ob_error *error = nullptr;
ob_config_enable_stream(impl_, streamType, &error);
Error::handle(&error);
}
/**
* @brief Enable an accelerometer stream to be used in the pipeline.
*
* This function allows users to enable an accelerometer stream with customizable parameters.
* If no parameters are specified, the stream will be enabled with default settings.
* Users who wish to set custom full-scale ranges or sample rates should refer to the product manual, as available settings vary by device model.
*
* @param fullScaleRange The full-scale range of the accelerometer (default is OB_ACCEL_FULL_SCALE_RANGE_ANY, which selects the default range).
* @param sampleRate The sample rate of the accelerometer (default is OB_ACCEL_SAMPLE_RATE_ANY, which selects the default rate).
*/
void enableAccelStream(ob_accel_full_scale_range fullScaleRange = OB_ACCEL_FULL_SCALE_RANGE_ANY,
ob_accel_sample_rate sampleRate = OB_ACCEL_SAMPLE_RATE_ANY);
/**
* @brief Enable a stream with a specific sensor type
* @brief Will convert sensor type to stream type automatically.
*
* @param sensorType The sensor type to be enabled
*/
void enableStream(OBSensorType sensorType) const {
auto streamType = ob::TypeHelper::convertSensorTypeToStreamType(sensorType);
enableStream(streamType);
}
/**
* @brief Enable a gyroscope stream to be used in the pipeline.
*
* This function allows users to enable a gyroscope stream with customizable parameters.
* If no parameters are specified, the stream will be enabled with default settings.
* Users who wish to set custom full-scale ranges or sample rates should refer to the product manual, as available settings vary by device model.
*
* @param fullScaleRange The full-scale range of the gyroscope (default is OB_GYRO_FULL_SCALE_RANGE_ANY, which selects the default range).
* @param sampleRate The sample rate of the gyroscope (default is OB_GYRO_SAMPLE_RATE_ANY, which selects the default rate).
*/
void enableGyroStream(ob_gyro_full_scale_range fullScaleRange = OB_GYRO_FULL_SCALE_RANGE_ANY, ob_gyro_sample_rate sampleRate = OB_GYRO_SAMPLE_RATE_ANY);
/**
* @brief Enable a stream to be used in the pipeline
*
* @param streamProfile The stream configuration to be enabled
*/
void enableStream(std::shared_ptr<const StreamProfile> streamProfile) const {
ob_error *error = nullptr;
auto c_stream_profile = streamProfile->getImpl();
ob_config_enable_stream_with_stream_profile(impl_, c_stream_profile, &error);
Error::handle(&error);
}
/**
* @brief Disable a stream to be used in the pipeline
*
* @param streamType The stream configuration to be disabled
*/
void disableStream(OBStreamType streamType);
/**
* @brief Enable a video stream to be used in the pipeline.
*
* This function allows users to enable a video stream with customizable parameters.
* 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 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).
* @param format The video stream format (default is OB_FORMAT_ANY, which selects the default
* format).
*/
void enableVideoStream(OBStreamType streamType, uint32_t width = OB_WIDTH_ANY,
uint32_t height = OB_HEIGHT_ANY, uint32_t fps = OB_FPS_ANY,
OBFormat format = OB_FORMAT_ANY) const {
ob_error *error = nullptr;
ob_config_enable_video_stream(impl_, streamType, width, height, fps, format, &error);
Error::handle(&error);
}
/**
* @brief Disable all streams to be used in the pipeline
*/
void disableAllStream();
/**
* @brief Enable a video stream to be used in the pipeline.
* @brief Will convert sensor type to stream type automatically.
*
* @param sensorType The sensor type to be enabled.
* @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).
* @param format The video stream format (default is OB_FORMAT_ANY, which selects the default
* format).
*/
void enableVideoStream(OBSensorType sensorType, uint32_t width = OB_WIDTH_ANY,
uint32_t height = OB_HEIGHT_ANY, uint32_t fps = OB_FPS_ANY,
OBFormat format = OB_FORMAT_ANY) const {
auto streamType = ob::TypeHelper::convertSensorTypeToStreamType(sensorType);
enableVideoStream(streamType, width, height, fps, format);
}
/**
* @brief Get the Enabled Stream Profile List
*
* @return std::shared_ptr<StreamProfileList>
*/
std::shared_ptr<StreamProfileList> getEnabledStreamProfileList() const;
/**
* @brief Enable an accelerometer stream to be used in the pipeline.
*
* This function allows users to enable an accelerometer stream with customizable parameters.
* If no parameters are specified, the stream will be enabled with default settings.
* Users who wish to set custom full-scale ranges or sample rates should refer to the product
* manual, as available settings vary by device model.
*
* @param fullScaleRange The full-scale range of the accelerometer (default is
* OB_ACCEL_FULL_SCALE_RANGE_ANY, which selects the default range).
* @param sampleRate The sample rate of the accelerometer (default is OB_ACCEL_SAMPLE_RATE_ANY,
* which selects the default rate).
*/
void enableAccelStream(OBAccelFullScaleRange fullScaleRange = OB_ACCEL_FULL_SCALE_RANGE_ANY,
OBAccelSampleRate sampleRate = OB_ACCEL_SAMPLE_RATE_ANY) const {
ob_error *error = nullptr;
ob_config_enable_accel_stream(impl_, fullScaleRange, sampleRate, &error);
Error::handle(&error);
}
/**
* @brief Set the alignment mode
*
* @param mode The alignment mode
*/
void setAlignMode(OBAlignMode mode);
/**
* @brief Enable a gyroscope stream to be used in the pipeline.
*
* This function allows users to enable a gyroscope stream with customizable parameters.
* If no parameters are specified, the stream will be enabled with default settings.
* Users who wish to set custom full-scale ranges or sample rates should refer to the product
* manual, as available settings vary by device model.
*
* @param fullScaleRange The full-scale range of the gyroscope (default is
* OB_GYRO_FULL_SCALE_RANGE_ANY, which selects the default range).
* @param sampleRate The sample rate of the gyroscope (default is OB_GYRO_SAMPLE_RATE_ANY, which
* selects the default rate).
*/
void enableGyroStream(OBGyroFullScaleRange fullScaleRange = OB_GYRO_FULL_SCALE_RANGE_ANY,
OBGyroSampleRate sampleRate = OB_GYRO_SAMPLE_RATE_ANY) const {
ob_error *error = nullptr;
ob_config_enable_gyro_stream(impl_, fullScaleRange, sampleRate, &error);
Error::handle(&error);
}
/**
* @brief Set whether the depth needs to be scaled after setting D2C
*
* @param enable Whether scaling is required
*/
void setDepthScaleRequire(bool enable);
/**
* @deprecated Use enableStream(std::shared_ptr<StreamProfile> streamProfile) instead
* @brief Enable all streams to be used in the pipeline
*/
void enableAllStream() {
ob_error *error = nullptr;
ob_config_enable_all_stream(impl_, &error);
Error::handle(&error);
}
/**
* @brief Set the D2C target resolution
* @brief The D2C target resolution is applicable to cases where the color stream is not enabled using the OrbbecSDK and the depth needs to be D2C.
*
* @note When you use OrbbecSDK to enable the color stream, you also use this interface to set the D2C target resolution. The configuration of the
* enabled Color stream is preferred for D2C.
*
* @param d2cTargetWidth The D2C target width resolution
* @param d2cTargetHeight The D2C target height resolution
*/
void setD2CTargetResolution(uint32_t d2cTargetWidth, uint32_t d2cTargetHeight);
/**
* @brief Disable a stream to be used in the pipeline
*
* @param streamType The stream configuration to be disabled
*/
void disableStream(OBStreamType streamType) const {
ob_error *error = nullptr;
ob_config_disable_stream(impl_, streamType, &error);
Error::handle(&error);
}
/**
* @brief Set the frame aggregation output mode for the pipeline configuration
* @brief The processing strategy when the FrameSet generated by the frame aggregation function does not contain the frames of all opened streams (which
* can be caused by different frame rates of each stream, or by the loss of frames of one stream): drop directly or output to the user.
*
* @param mode The frame aggregation output mode to be set (default mode is @ref OB_FRAME_AGGREGATE_OUTPUT_FULL_FRAME_REQUIRE)
*/
void setFrameAggregateOutputMode(OBFrameAggregateOutputMode mode);
/**
* @brief Disable a sensor stream to be used in the pipeline.
* @brief Will convert sensor type to stream type automatically.
*
* @param sensorType
*/
void disableStream(OBSensorType sensorType) const {
auto streamType = ob::TypeHelper::convertSensorTypeToStreamType(sensorType);
disableStream(streamType);
}
friend class Pipeline;
/**
* @brief Disable all streams to be used in the pipeline
*/
void disableAllStream() const {
ob_error *error = nullptr;
ob_config_disable_all_stream(impl_, &error);
Error::handle(&error);
}
/**
* @brief Get the Enabled Stream Profile List
*
* @return std::shared_ptr<StreamProfileList>
*/
std::shared_ptr<StreamProfileList> getEnabledStreamProfileList() const {
ob_error *error = nullptr;
auto list = ob_config_get_enabled_stream_profile_list(impl_, &error);
Error::handle(&error);
return std::make_shared<StreamProfileList>(list);
}
/**
* @brief Set the alignment mode
*
* @param mode The alignment mode
*/
void setAlignMode(OBAlignMode mode) const {
ob_error *error = nullptr;
ob_config_set_align_mode(impl_, mode, &error);
Error::handle(&error);
}
/**
* @brief Set whether the depth needs to be scaled after setting D2C
*
* @param enable Whether scaling is required
*/
void setDepthScaleRequire(bool enable) const {
ob_error *error = nullptr;
ob_config_set_depth_scale_after_align_require(impl_, enable, &error);
Error::handle(&error);
}
/**
* @brief Set the frame aggregation output mode for the pipeline configuration
* @brief The processing strategy when the FrameSet generated by the frame aggregation function
* does not contain the frames of all opened streams (which can be caused by different frame rates
* of each stream, or by the loss of frames of one stream): drop directly or output to the user.
*
* @param mode The frame aggregation output mode to be set (default mode is @ref
* OB_FRAME_AGGREGATE_OUTPUT_ANY_SITUATION)
*/
void setFrameAggregateOutputMode(OBFrameAggregateOutputMode mode) const {
ob_error *error = nullptr;
ob_config_set_frame_aggregate_output_mode(impl_, mode, &error);
Error::handle(&error);
}
};
class Pipeline {
public:
/**
* @brief FrameSetCallback is a callback function type for frameset data arrival.
*
* @param frame The returned frameset data
*/
typedef std::function<void(std::shared_ptr<FrameSet> frame)> FrameSetCallback;
private:
ob_pipeline_t *impl_;
FrameSetCallback callback_;
public:
/**
* @brief Pipeline is a high-level interface for applications, algorithms related RGBD data
* streams. Pipeline can provide alignment inside and synchronized FrameSet. Pipeline() no
* parameter version, which opens the first device in the list of devices connected to the OS by
* default. If the application has obtained the device through the DeviceList, opening the
* Pipeline() at this time will throw an exception that the device has been created.
*/
Pipeline() {
ob_error *error = nullptr;
impl_ = ob_create_pipeline(&error);
Error::handle(&error);
}
/**
* @brief
* Pipeline(std::shared_ptr< Device > device ) Function for multi-device operations. Multiple
* devices need to be obtained through DeviceList, and the device and pipeline are bound through
* this interface.
*/
explicit Pipeline(std::shared_ptr<Device> device) {
ob_error *error = nullptr;
impl_ = ob_create_pipeline_with_device(device->getImpl(), &error);
Error::handle(&error);
}
/**
* @brief Destroy the pipeline object
*/
~Pipeline() noexcept {
ob_error *error = nullptr;
ob_delete_pipeline(impl_, &error);
Error::handle(&error, false);
}
/**
* @brief Start the pipeline with configuration parameters
*
* @param config The parameter configuration of the pipeline
*/
void start(std::shared_ptr<Config> config = nullptr) const {
ob_error *error = nullptr;
ob_config_t *config_impl = config == nullptr ? nullptr : config->getImpl();
ob_pipeline_start_with_config(impl_, config_impl, &error);
Error::handle(&error);
}
/**
* @brief Start the pipeline and set the frameset data callback
*
* @param config The configuration of the pipeline
* @param callback The callback to be triggered when all frame data in the frameset arrives
*/
void start(std::shared_ptr<Config> config, FrameSetCallback callback) {
callback_ = callback;
ob_error *error = nullptr;
ob_pipeline_start_with_callback(impl_, config ? config->getImpl() : nullptr,
&Pipeline::frameSetCallback, this, &error);
Error::handle(&error);
}
static void frameSetCallback(ob_frame_t *frameSet, void *userData) {
auto pipeline = static_cast<Pipeline *>(userData);
pipeline->callback_(std::make_shared<FrameSet>(frameSet));
}
/**
* @brief Stop the pipeline
*/
void stop() const {
ob_error *error = nullptr;
ob_pipeline_stop(impl_, &error);
Error::handle(&error);
}
/**
* @brief Get the pipeline configuration parameters
* @brief Returns the default configuration if the user has not configured it
*
* @return std::shared_ptr<Config> The configured parameters
*/
std::shared_ptr<Config> getConfig() const {
ob_error *error = nullptr;
auto config = ob_pipeline_get_config(impl_, &error);
Error::handle(&error);
return std::make_shared<Config>(config);
}
/**
* @brief Wait for frameset
*
* @param timeout_ms The waiting timeout in milliseconds
* @return std::shared_ptr<FrameSet> The waiting frameset data
*/
std::shared_ptr<FrameSet> waitForFrameset(uint32_t timeoutMs = 1000) const {
ob_error *error = nullptr;
auto frameSet = ob_pipeline_wait_for_frameset(impl_, timeoutMs, &error);
if (frameSet == nullptr) {
return nullptr;
}
Error::handle(&error);
return std::make_shared<FrameSet>(frameSet);
}
/**
* @brief Get the device object
*
* @return std::shared_ptr<Device> The device object
*/
std::shared_ptr<Device> getDevice() const {
ob_error *error = nullptr;
auto device = ob_pipeline_get_device(impl_, &error);
Error::handle(&error);
return std::make_shared<Device>(device);
}
/**
* @brief Get the stream profile of the specified sensor
*
* @param sensorType The type of sensor
* @return std::shared_ptr<StreamProfileList> The stream profile list
*/
std::shared_ptr<StreamProfileList> getStreamProfileList(OBSensorType sensorType) const {
ob_error *error = nullptr;
auto list = ob_pipeline_get_stream_profile_list(impl_, sensorType, &error);
Error::handle(&error);
return std::make_shared<StreamProfileList>(list);
}
/**
* @brief Turn on frame synchronization
*/
void enableFrameSync() const {
ob_error *error = nullptr;
ob_pipeline_enable_frame_sync(impl_, &error);
Error::handle(&error);
}
/**
* @brief Turn off frame synchronization
*/
void disableFrameSync() const {
ob_error *error = nullptr;
ob_pipeline_disable_frame_sync(impl_, &error);
Error::handle(&error);
}
std::shared_ptr<StreamProfileList> getD2CDepthProfileList(
std::shared_ptr<StreamProfile> colorProfile, OBAlignMode alignMode) {
ob_error *error = nullptr;
auto list = ob_get_d2c_depth_profile_list(impl_, colorProfile->getImpl(), alignMode, &error);
Error::handle(&error);
return std::make_shared<StreamProfileList>(list);
}
OBCameraParam getCameraParam() {
ob_error *error = nullptr;
OBCameraParam cameraParam = ob_pipeline_get_camera_param(impl_, &error);
Error::handle(&error);
return cameraParam;
}
OBCameraParam getCameraParamWithProfile(uint32_t colorWidth, uint32_t colorHeight,
uint32_t depthWidth, uint32_t depthHeight) {
ob_error *error = nullptr;
OBCameraParam cameraParam = ob_pipeline_get_camera_param_with_profile(
impl_, colorWidth, colorHeight, depthWidth, depthHeight, &error);
Error::handle(&error);
return cameraParam;
}
OBCalibrationParam getCalibrationParam(std::shared_ptr<Config> config) {
std::cout << "getCalibrationParam" << std::endl;
ob_error *error = nullptr;
OBCalibrationParam calibrationParam =
ob_pipeline_get_calibration_param(impl_, config->getImpl(), &error);
std::cout << "over" << std::endl;
Error::handle(&error);
return calibrationParam;
}
/**
* In order to be compatible with the closed source version of orbbecsdk's interface.
* We recommend using the latest interface names for a better experience.
*/
OB_DEPRECATED std::shared_ptr<FrameSet> waitForFrames(uint32_t timeoutMs = 1000) const {
return waitForFrameset(timeoutMs);
}
};
} // namespace ob
@@ -1,109 +0,0 @@
/**
* @file RecordPlayback.hpp
* @brief Header file for recording and playback functions.
*/
#pragma once
#include "Types.hpp"
#include <memory>
struct RecorderImpl;
struct PlaybackImpl;
namespace ob {
class Device;
class Frame;
class DeviceInfo;
using PlaybackCallback = std::function<void(std::shared_ptr<Frame> frame)>;
using MediaStateCallback = std::function<void(OBMediaState state)>;
class OB_EXTENSION_API Recorder {
private:
std::unique_ptr<RecorderImpl> impl_;
public:
/**
* @brief Create a recorder for data recording.
*/
Recorder();
Recorder(std::unique_ptr<RecorderImpl> impl);
/**
* @brief Create a recorder for data recording.
* @param device The device for which to record device information.
*/
Recorder(std::shared_ptr<Device> device);
virtual ~Recorder() noexcept;
/**
* @brief Enable the recorder. Throws an exception on failure.
*
* @param filename The name of the recorded file.
* @param async Whether to execute asynchronously.
*/
void start(const char *filename, bool async = false);
/**
* @brief Stop the recorder. Throws an exception on failure.
*/
void stop();
/**
* @brief Write frame data to the recorder.
*
* @param frame The frame data to write.
*/
void write(std::shared_ptr<Frame> frame);
};
class OB_EXTENSION_API Playback {
private:
std::unique_ptr<PlaybackImpl> impl_;
public:
/**
* @brief Create a playback object.
* @param filename The name of the playback file.
*/
Playback(const char *filename);
Playback(std::unique_ptr<PlaybackImpl> impl);
virtual ~Playback() noexcept;
/**
* @brief Start playback. The playback data is returned from the callback. Throws an exception on failure.
* @param callback The callback for playback data.
* @param type The type of playback data.
*/
void start(PlaybackCallback callback, OBMediaType type = OB_MEDIA_ALL);
/**
* @brief Stop playback. Throws an exception on failure.
*/
void stop();
/**
* @brief Set the playback state.
* @param state The playback status callback.
*/
void setPlaybackStateCallback(MediaStateCallback state);
/**
* @brief Get the device information in the recording file.
*
* @return DeviceInfo The device information.
*/
std::shared_ptr<DeviceInfo> getDeviceInfo();
/**
* @brief Get the intrinsic and extrinsic parameter in the recording file.
*
* @return OBCameraParam Camera intrinsic and extrinsic parameter
*/
OBCameraParam getCameraParam();
};
} // namespace ob
@@ -6,55 +6,100 @@
#include "Types.hpp"
#include "libobsensor/hpp/Filter.hpp"
#include "libobsensor/h/Sensor.h"
#include "libobsensor/h/Filter.h"
#include "Error.hpp"
#include "StreamProfile.hpp"
#include "Device.hpp"
#include "Frame.hpp"
#include <functional>
#include <memory>
struct SensorImpl;
struct SensorListImpl;
#include <vector>
namespace ob {
class StreamProfile;
class StreamProfileList;
class Device;
class Frame;
class ImuFrame;
class OBFilterList;
/**
* @brief Callback function for frame data.
*
* @param frame The frame data.
*/
using FrameCallback = std::function<void(std::shared_ptr<Frame> frame)>;
class Sensor {
public:
/**
* @brief Callback function for frame data.
*
* @param frame The frame data.
*/
typedef std::function<void(std::shared_ptr<Frame> frame)> FrameCallback;
class OB_EXTENSION_API Sensor {
protected:
std::unique_ptr<SensorImpl> impl_;
ob_sensor_t * impl_;
FrameCallback callback_;
public:
Sensor(std::unique_ptr<SensorImpl> impl);
virtual ~Sensor() noexcept;
explicit Sensor(ob_sensor_t *impl) : impl_(impl) {}
Sensor(Sensor &&sensor) noexcept : impl_(sensor.impl_) {
sensor.impl_ = nullptr;
}
Sensor &operator=(Sensor &&sensor) noexcept {
if(this != &sensor) {
ob_error *error = nullptr;
ob_delete_sensor(impl_, &error);
Error::handle(&error);
impl_ = sensor.impl_;
sensor.impl_ = nullptr;
}
return *this;
}
Sensor(const Sensor &sensor) = delete;
Sensor &operator=(const Sensor &sensor) = delete;
virtual ~Sensor() noexcept {
ob_error *error = nullptr;
ob_delete_sensor(impl_, &error);
Error::handle(&error, false);
}
/**
* @brief Get the sensor type.
*
* @return OBSensorType The sensor type.
*/
OBSensorType type();
OBSensorType getType() const {
ob_error *error = nullptr;
auto type = ob_sensor_get_type(impl_, &error);
Error::handle(&error);
return type;
}
/**
* @brief Get the list of stream profiles.
*
* @return std::shared_ptr<StreamProfileList> The stream profile list.
*/
const std::shared_ptr<StreamProfileList> getStreamProfileList();
std::shared_ptr<StreamProfileList> getStreamProfileList() const {
ob_error *error = nullptr;
auto list = ob_sensor_get_stream_profile_list(impl_, &error);
Error::handle(&error);
return std::make_shared<StreamProfileList>(list);
}
/**
* @brief Request recommended filters
* @return OBFilterList list of frame processing block
*/
const std::shared_ptr<OBFilterList> getRecommendedFilters();
std::vector<std::shared_ptr<Filter>> getRecommendedFilters() const {
ob_error *error = nullptr;
auto list = ob_sensor_get_recommended_filter_list(impl_, &error);
Error::handle(&error);
auto filter_count = ob_filter_list_get_count(list, &error);
std::vector<std::shared_ptr<Filter>> filters;
for(uint32_t i = 0; i < filter_count; i++) {
auto filterImpl = ob_filter_list_get_filter(list, i, &error);
Error::handle(&error);
filters.push_back(std::make_shared<Filter>(filterImpl));
}
return filters;
}
/**
* @brief Open a frame data stream and set up a callback.
@@ -62,36 +107,72 @@ public:
* @param streamProfile The stream configuration.
* @param callback The callback to set when frame data arrives.
*/
void start(std::shared_ptr<StreamProfile> streamProfile, FrameCallback callback);
void start(std::shared_ptr<StreamProfile> streamProfile, FrameCallback callback) {
ob_error *error = nullptr;
callback_ = std::move(callback);
ob_sensor_start(impl_, const_cast<ob_stream_profile_t *>(streamProfile->getImpl()), &Sensor::frameCallback, this, &error);
Error::handle(&error);
}
/**
* @brief Stop the stream.
*/
void stop();
void stop() const {
ob_error *error = nullptr;
ob_sensor_stop(impl_, &error);
Error::handle(&error);
}
/**
* @brief Dynamically switch resolutions.
*
* @param streamProfile The resolution to switch to.
*/
void switchProfile(std::shared_ptr<StreamProfile> streamProfile);
void switchProfile(std::shared_ptr<StreamProfile> streamProfile) {
ob_error *error = nullptr;
ob_sensor_switch_profile(impl_, const_cast<ob_stream_profile_t *>(streamProfile->getImpl()), &error);
Error::handle(&error);
}
private:
static void frameCallback(ob_frame *frame, void *userData) {
auto sensor = static_cast<Sensor *>(userData);
sensor->callback_(std::make_shared<Frame>(frame));
}
/**
* In order to be compatible with the closed source version of orbbecsdk's interface.
* We recommend using the latest interface names for a better experience.
*/
OB_DEPRECATED OBSensorType type() const {
return getType();
}
};
class OB_EXTENSION_API SensorList {
class SensorList {
private:
std::unique_ptr<SensorListImpl> impl_;
ob_sensor_list_t *impl_ = nullptr;
public:
SensorList(std::unique_ptr<SensorListImpl> impl);
explicit SensorList(ob_sensor_list_t *impl) : impl_(impl) {}
virtual ~SensorList() noexcept;
~SensorList() noexcept {
ob_error *error = nullptr;
ob_delete_sensor_list(impl_, &error);
Error::handle(&error, false);
}
/**
* @brief Get the number of sensors.
*
* @return uint32_t The number of sensors.
*/
uint32_t count();
uint32_t getCount() const {
ob_error *error = nullptr;
auto count = ob_sensor_list_get_count(impl_, &error);
Error::handle(&error);
return count;
}
/**
* @brief Get the type of the specified sensor.
@@ -99,7 +180,12 @@ public:
* @param index The sensor index.
* @return OBSensorType The sensor type.
*/
OBSensorType type(uint32_t index);
OBSensorType getSensorType(uint32_t index) const {
ob_error *error = nullptr;
auto type = ob_sensor_list_get_sensor_type(impl_, index, &error);
Error::handle(&error);
return type;
}
/**
* @brief Get a sensor by index number.
@@ -107,7 +193,12 @@ public:
* @param index The sensor index. The range is [0, count-1]. If the index exceeds the range, an exception will be thrown.
* @return std::shared_ptr<Sensor> The sensor object.
*/
std::shared_ptr<Sensor> getSensor(uint32_t index);
std::shared_ptr<Sensor> getSensor(uint32_t index) const {
ob_error *error = nullptr;
auto sensor = ob_sensor_list_get_sensor(impl_, index, &error);
Error::handle(&error);
return std::make_shared<Sensor>(sensor);
}
/**
* @brief Get a sensor by sensor type.
@@ -115,35 +206,24 @@ public:
* @param sensorType The sensor type to obtain.
* @return std::shared_ptr<Sensor> A sensor object. If the specified sensor type does not exist, it will return empty.
*/
std::shared_ptr<Sensor> getSensor(OBSensorType sensorType);
};
/**
* @brief Class representing a list of FrameProcessingBlock
*/
class OB_EXTENSION_API OBFilterList {
private:
std::unique_ptr<OBFilterListImpl> impl_;
public:
OBFilterList(std::unique_ptr<OBFilterListImpl> impl_);
~OBFilterList() noexcept;
std::shared_ptr<Sensor> getSensor(OBSensorType sensorType) const {
ob_error *error = nullptr;
auto sensor = ob_sensor_list_get_sensor_by_type(impl_, sensorType, &error);
Error::handle(&error);
return std::make_shared<Sensor>(sensor);
}
/**
* @brief Get the number of OBDepthWorkMode FrameProcessingBlock in the list
*
* @return uint32_t the number of FrameProcessingBlock objects in the list
* In order to be compatible with the closed source version of orbbecsdk's interface.
* We recommend using the latest interface names for a better experience.
*/
uint32_t count();
OB_DEPRECATED uint32_t count() const {
return getCount();
}
/**
* @brief Get the Filter object at the specified index
*
* @param index the index of the target Filter object
* @return the Filter object at the specified index
*/
std::shared_ptr<Filter> getFilter(uint32_t index);
OB_DEPRECATED OBSensorType type(uint32_t index) const {
return getSensorType(index);
}
};
} // namespace ob
@@ -5,49 +5,84 @@
#pragma once
#include "Types.hpp"
#include "libobsensor/h/StreamProfile.h"
#include <iostream>
#include <memory>
struct StreamProfileImpl;
struct StreamProfileListImpl;
namespace ob {
class VideoStreamProfile;
class GyroStreamProfile;
class AccelStreamProfile;
class Config;
class OB_EXTENSION_API StreamProfile : public std::enable_shared_from_this<StreamProfile> {
class StreamProfile : public std::enable_shared_from_this<StreamProfile> {
protected:
std::unique_ptr<StreamProfileImpl> impl_;
const ob_stream_profile_t *impl_ = nullptr;
public:
StreamProfile(std::unique_ptr<StreamProfileImpl> impl);
StreamProfile(StreamProfile &streamProfile);
virtual ~StreamProfile() noexcept;
explicit StreamProfile(const ob_stream_profile_t *impl) : impl_(impl) {}
StreamProfile(StreamProfile &streamProfile) = delete;
StreamProfile &operator=(StreamProfile &streamProfile) = delete;
StreamProfile(StreamProfile &&streamProfile) noexcept : impl_(streamProfile.impl_) {
streamProfile.impl_ = nullptr;
}
StreamProfile &operator=(StreamProfile &&streamProfile) noexcept {
if(this != &streamProfile) {
ob_error *error = nullptr;
ob_delete_stream_profile(impl_, &error);
Error::handle(&error);
impl_ = streamProfile.impl_;
streamProfile.impl_ = nullptr;
}
return *this;
}
virtual ~StreamProfile() noexcept {
if(impl_) {
ob_error *error = nullptr;
ob_delete_stream_profile(impl_, &error);
Error::handle(&error);
}
}
const ob_stream_profile *getImpl() const {
return impl_;
}
/**
* @brief Get the format of the stream
*
* @return OBFormat return the format of the stream
*/
OBFormat format() const;
OBFormat getFormat() const {
ob_error *error = nullptr;
auto format = ob_stream_profile_get_format(impl_, &error);
Error::handle(&error);
return format;
}
/**
* @brief Get the type of stream
*
* @return OBStreamType return the type of the stream
*/
OBStreamType type() const;
OBStreamType getType() const {
ob_error *error = nullptr;
auto type = ob_stream_profile_get_type(impl_, &error);
Error::handle(&error);
return type;
}
/**
* @brief Get the extrinsic parameters from current stream profile to the given target stream profile
*
* @return OBExtrinsic Return the extrinsic parameters.
*/
OBExtrinsic getExtrinsicTo(std::shared_ptr<StreamProfile> target);
OBExtrinsic getExtrinsicTo(std::shared_ptr<StreamProfile> target) const {
ob_error *error = nullptr;
auto extrinsic = ob_stream_profile_get_extrinsic_to(impl_, const_cast<ob_stream_profile_t *>(target->getImpl()), &error);
Error::handle(&error);
return extrinsic;
}
/**
* @brief Check if frame object is compatible with the given type
@@ -55,7 +90,7 @@ public:
* @tparam T Given type
* @return bool return result
*/
template <typename T> bool is();
template <typename T> bool is() const;
/**
* @brief Converts object type to target type
@@ -68,52 +103,92 @@ public:
throw std::runtime_error("Unsupported operation. Object's type is not the required type.");
}
return std::static_pointer_cast<T>(std::const_pointer_cast<StreamProfile>(shared_from_this()));
return std::static_pointer_cast<T>(shared_from_this());
}
friend class Sensor;
friend class Config;
friend class Pipeline;
/**
* @brief Converts object type to target type (const version)
*
* @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 {
if(!is<T>()) {
throw std::runtime_error("Unsupported operation. Object's type is not the required type.");
}
return std::static_pointer_cast<const T>(shared_from_this());
}
/**
* In order to be compatible with the closed source version of orbbecsdk's interface.
* We recommend using the latest interface names for a better experience.
*/
OB_DEPRECATED OBFormat format() const {
return getFormat();
}
OB_DEPRECATED OBStreamType type() const {
return getType();
}
};
/**
* @brief Class representing a video stream profile.
*/
class OB_EXTENSION_API VideoStreamProfile : public StreamProfile {
class VideoStreamProfile : public StreamProfile {
public:
explicit VideoStreamProfile(StreamProfile &profile);
explicit VideoStreamProfile(const ob_stream_profile_t *impl) : StreamProfile(impl) {}
explicit VideoStreamProfile(std::unique_ptr<StreamProfileImpl> impl);
~VideoStreamProfile() noexcept override;
~VideoStreamProfile() noexcept override = default;
/**
* @brief Return the frame rate of the stream.
*
* @return uint32_t Return the frame rate of the stream.
*/
uint32_t fps() const;
uint32_t getFps() const {
ob_error *error = nullptr;
auto fps = ob_video_stream_profile_get_fps(impl_, &error);
Error::handle(&error);
return fps;
}
/**
* @brief Return the width of the stream.
*
* @return uint32_t Return the width of the stream.
*/
uint32_t width() const;
uint32_t getWidth() const {
ob_error *error = nullptr;
auto width = ob_video_stream_profile_get_width(impl_, &error);
Error::handle(&error);
return width;
}
/**
* @brief Return the height of the stream.
*
* @return uint32_t Return the height of the stream.
*/
uint32_t height() const;
uint32_t getHeight() const {
ob_error *error = nullptr;
auto height = ob_video_stream_profile_get_height(impl_, &error);
Error::handle(&error);
return height;
}
/**
* @brief Get the intrinsic parameters of the stream.
*
* @return OBCameraIntrinsic Return the intrinsic parameters.
*/
OBCameraIntrinsic getIntrinsic();
OBCameraIntrinsic getIntrinsic() const {
ob_error *error = nullptr;
auto intrinsic = ob_video_stream_profile_get_intrinsic(impl_, &error);
Error::handle(&error);
return intrinsic;
}
/**
* @brief Get the distortion parameters of the stream.
@@ -121,76 +196,140 @@ public:
*
* @return OBCameraDistortion Return the distortion parameters.
*/
OBCameraDistortion getDistortion();
OBCameraDistortion getDistortion() const {
ob_error *error = nullptr;
auto distortion = ob_video_stream_profile_get_distortion(impl_, &error);
Error::handle(&error);
return distortion;
}
/**
* In order to be compatible with the closed source version of orbbecsdk's interface.
* We recommend using the latest interface names for a better experience.
*/
OB_DEPRECATED uint32_t fps() const {
return getFps();
}
OB_DEPRECATED uint32_t width() const {
return getWidth();
}
OB_DEPRECATED uint32_t height() const {
return getHeight();
}
};
/**
* @brief Class representing an accelerometer stream profile.
*/
class OB_EXTENSION_API AccelStreamProfile : public StreamProfile {
class AccelStreamProfile : public StreamProfile {
public:
explicit AccelStreamProfile(StreamProfile &profile);
explicit AccelStreamProfile(const ob_stream_profile_t *impl) : StreamProfile(impl) {}
explicit AccelStreamProfile(std::unique_ptr<StreamProfileImpl> impl);
~AccelStreamProfile() noexcept override;
~AccelStreamProfile() noexcept override = default;
/**
* @brief Return the full scale range.
*
* @return OBAccelFullScaleRange Return the scale range value.
*/
OBAccelFullScaleRange fullScaleRange() const;
OBAccelFullScaleRange getFullScaleRange() const {
ob_error *error = nullptr;
auto fullScaleRange = ob_accel_stream_profile_get_full_scale_range(impl_, &error);
Error::handle(&error);
return fullScaleRange;
}
/**
* @brief Return the sampling frequency.
*
* @return OBAccelFullScaleRange Return the sampling frequency.
*/
OBAccelSampleRate sampleRate() const;
OBAccelSampleRate getSampleRate() const {
ob_error *error = nullptr;
auto sampleRate = ob_accel_stream_profile_get_sample_rate(impl_, &error);
Error::handle(&error);
return sampleRate;
}
/**
* @brief get the intrinsic parameters of the stream.
*
* @return OBAccelIntrinsic Return the intrinsic parameters.
*/
OBAccelIntrinsic getIntrinsic();
OBAccelIntrinsic getIntrinsic() const {
ob_error *error = nullptr;
auto intrinsic = ob_accel_stream_profile_get_intrinsic(impl_, &error);
Error::handle(&error);
return intrinsic;
}
OB_DEPRECATED OBAccelFullScaleRange fullScaleRange() const{
return getFullScaleRange();
}
OB_DEPRECATED OBAccelSampleRate sampleRate() const{
return getSampleRate();
}
};
/**
* @brief Class representing a gyroscope stream profile.
*/
class OB_EXTENSION_API GyroStreamProfile : public StreamProfile {
class GyroStreamProfile : public StreamProfile {
public:
explicit GyroStreamProfile(StreamProfile &profile);
explicit GyroStreamProfile(const ob_stream_profile_t *impl) : StreamProfile(impl) {}
explicit GyroStreamProfile(std::unique_ptr<StreamProfileImpl> impl);
~GyroStreamProfile() noexcept override;
~GyroStreamProfile() noexcept override = default;
/**
* @brief Return the full scale range.
*
* @return OBAccelFullScaleRange Return the scale range value.
*/
OBGyroFullScaleRange fullScaleRange() const;
OBGyroFullScaleRange getFullScaleRange() const {
ob_error *error = nullptr;
auto fullScaleRange = ob_gyro_stream_profile_get_full_scale_range(impl_, &error);
Error::handle(&error);
return fullScaleRange;
}
/**
* @brief Return the sampling frequency.
*
* @return OBAccelFullScaleRange Return the sampling frequency.
*/
OBGyroSampleRate sampleRate() const;
OBGyroSampleRate getSampleRate() const {
ob_error *error = nullptr;
auto sampleRate = ob_gyro_stream_profile_get_sample_rate(impl_, &error);
Error::handle(&error);
return sampleRate;
}
/**
* @brief get the intrinsic parameters of the stream.
*
* @return OBGyroIntrinsic Return the intrinsic parameters.
*/
OBGyroIntrinsic getIntrinsic();
OBGyroIntrinsic getIntrinsic() const {
ob_error *error = nullptr;
auto intrinsic = ob_gyro_stream_get_intrinsic(impl_, &error);
Error::handle(&error);
return intrinsic;
}
OB_DEPRECATED OBGyroFullScaleRange fullScaleRange() const{
return getFullScaleRange();
}
OB_DEPRECATED OBGyroSampleRate sampleRate() const{
return getSampleRate();
}
};
template <typename T> bool StreamProfile::is() {
switch(this->type()) {
template <typename T> bool StreamProfile::is() const {
switch(this->getType()) {
case OB_STREAM_VIDEO:
case OB_STREAM_IR:
case OB_STREAM_IR_LEFT:
@@ -209,20 +348,29 @@ template <typename T> bool StreamProfile::is() {
return false;
}
class OB_EXTENSION_API StreamProfileList {
class StreamProfileList {
protected:
std::unique_ptr<StreamProfileListImpl> impl_;
const ob_stream_profile_list_t *impl_;
public:
explicit StreamProfileList(std::unique_ptr<StreamProfileListImpl> impl);
~StreamProfileList() noexcept;
explicit StreamProfileList(ob_stream_profile_list_t *impl) : impl_(impl) {}
~StreamProfileList() noexcept {
ob_error *error = nullptr;
ob_delete_stream_profile_list(impl_, &error);
Error::handle(&error, false);
}
/**
* @brief Return the number of StreamProfile objects.
*
* @return uint32_t Return the number of StreamProfile objects.
*/
uint32_t count() const;
uint32_t getCount() const {
ob_error *error = nullptr;
auto count = ob_stream_profile_list_get_count(impl_, &error);
Error::handle(&error);
return count;
}
/**
* @brief Return the StreamProfile object at the specified index.
@@ -230,7 +378,12 @@ public:
* @param index The index of the StreamProfile object to be retrieved. Must be in the range [0, count-1]. Throws an exception if the index is out of range.
* @return std::shared_ptr<StreamProfile> Return the StreamProfile object.
*/
const std::shared_ptr<StreamProfile> getProfile(uint32_t index);
std::shared_ptr<StreamProfile> getProfile(uint32_t index) const {
ob_error *error = nullptr;
auto profile = ob_stream_profile_list_get_profile(impl_, index, &error);
Error::handle(&error);
return std::make_shared<StreamProfile>(profile);
}
/**
* @brief Match the corresponding video stream profile based on the passed-in parameters. If multiple Match are found, the first one in the list is
@@ -242,8 +395,13 @@ public:
* @param fps The frame rate of the stream. Pass OB_FPS_ANY if no matching condition is required.
* @return std::shared_ptr<VideoStreamProfile> Return the matching resolution.
*/
const std::shared_ptr<VideoStreamProfile> getVideoStreamProfile(int width = OB_WIDTH_ANY, int height = OB_HEIGHT_ANY, OBFormat format = OB_FORMAT_ANY,
int fps = OB_FPS_ANY);
std::shared_ptr<VideoStreamProfile> getVideoStreamProfile(int width = OB_WIDTH_ANY, int height = OB_HEIGHT_ANY, OBFormat format = OB_FORMAT_ANY,
int fps = OB_FPS_ANY) const {
ob_error *error = nullptr;
auto profile = ob_stream_profile_list_get_video_stream_profile(impl_, width, height, format, fps, &error);
Error::handle(&error);
return std::make_shared<VideoStreamProfile>(profile);
}
/**
* @brief Match the corresponding accelerometer stream profile based on the passed-in parameters. If multiple Match are found, the first one in the list
@@ -252,7 +410,12 @@ public:
* @param fullScaleRange The full scale range. Pass 0 if no matching condition is required.
* @param sampleRate The sampling frequency. Pass 0 if no matching condition is required.
*/
const std::shared_ptr<AccelStreamProfile> getAccelStreamProfile(OBAccelFullScaleRange fullScaleRange, OBAccelSampleRate sampleRate);
std::shared_ptr<AccelStreamProfile> getAccelStreamProfile(OBAccelFullScaleRange fullScaleRange, OBAccelSampleRate sampleRate) const {
ob_error *error = nullptr;
auto profile = ob_stream_profile_list_get_accel_stream_profile(impl_, fullScaleRange, sampleRate, &error);
Error::handle(&error);
return std::make_shared<AccelStreamProfile>(profile);
}
/**
* @brief Match the corresponding gyroscope stream profile based on the passed-in parameters. If multiple Match are found, the first one in the list is
@@ -261,7 +424,20 @@ public:
* @param fullScaleRange The full scale range. Pass 0 if no matching condition is required.
* @param sampleRate The sampling frequency. Pass 0 if no matching condition is required.
*/
const std::shared_ptr<GyroStreamProfile> getGyroStreamProfile(OBGyroFullScaleRange fullScaleRange, OBGyroSampleRate sampleRate);
std::shared_ptr<GyroStreamProfile> getGyroStreamProfile(OBGyroFullScaleRange fullScaleRange, OBGyroSampleRate sampleRate) const {
ob_error *error = nullptr;
auto profile = ob_stream_profile_list_get_gyro_stream_profile(impl_, fullScaleRange, sampleRate, &error);
Error::handle(&error);
return std::make_shared<GyroStreamProfile>(profile);
}
/**
* In order to be compatible with the closed source version of orbbecsdk's interface.
* We recommend using the latest interface names for a better experience.
*/
OB_DEPRECATED uint32_t count() const {
return getCount();
}
};
} // namespace ob
@@ -0,0 +1,139 @@
#pragma once
#include <string>
#include <iostream>
#include "libobsensor/h/ObTypes.h"
#include "libobsensor/h/TypeHelper.h"
#include <functional>
namespace ob {
class TypeHelper {
public:
/**
* @brief Convert OBFormat to " string " type and then return.
*
* @param[in] type OBFormat type.
* @return OBFormat of "string" type.
*/
static std::string convertOBFormatTypeToString(const OBFormat &type) {
return ob_format_type_to_string(type);
}
/**
* @brief Convert OBFrameType to " string " type and then return.
*
* @param[in] type OBFrameType type.
* @return OBFrameType of "string" type.
*/
static std::string convertOBFrameTypeToString(const OBFrameType &type) {
return ob_frame_type_to_string(type);
}
/**
* @brief Convert OBStreamType to " string " type and then return.
*
* @param[in] type OBStreamType type.
* @return OBStreamType of "string" type.
*/
static std::string convertOBStreamTypeToString(const OBStreamType &type) {
return ob_stream_type_to_string(type);
}
/**
* @brief Convert OBSensorType to " string " type and then return.
*
* @param[in] type OBSensorType type.
* @return OBSensorType of "string" type.
*/
static std::string convertOBSensorTypeToString(const OBSensorType &type) {
return ob_sensor_type_to_string(type);
}
/**
* @brief Convert OBIMUSampleRate to " string " type and then return.
*
* @param[in] type OBIMUSampleRate type.
* @return OBIMUSampleRate of "string" type.
*/
static std::string convertOBIMUSampleRateTypeToString(const OBIMUSampleRate &type) {
return ob_imu_rate_type_to_string(type);
}
/**
* @brief Convert OBGyroFullScaleRange to " string " type and then return.
*
* @param[in] type OBGyroFullScaleRange type.
* @return OBGyroFullScaleRange of "string" type.
*/
static std::string convertOBGyroFullScaleRangeTypeToString(const OBGyroFullScaleRange &type) {
return ob_gyro_range_type_to_string(type);
}
/**
* @brief Convert OBAccelFullScaleRange to " string " type and then return.
*
* @param[in] type OBAccelFullScaleRange type.
* @return OBAccelFullScaleRange of "string" type.
*/
static std::string convertOBAccelFullScaleRangeTypeToString(const OBAccelFullScaleRange &type) {
return ob_accel_range_type_to_string(type);
}
/**
* @brief Convert OBFrameMetadataType to " string " type and then return.
*
* @param[in] type OBFrameMetadataType type.
* @return OBFrameMetadataType of "string" type.
*/
static std::string convertOBFrameMetadataTypeToString(const OBFrameMetadataType &type) {
return ob_meta_data_type_to_string(type);
}
/**
* @brief Convert OBSensorType to OBStreamType type and then return.
*
* @param[in] type OBSensorType type.
* @return OBStreamType type.
*/
static OBStreamType convertSensorTypeToStreamType(OBSensorType type) {
return ob_sensor_type_to_stream_type(type);
}
/**
* @brief Check if the given sensor type is a video sensor.
* @brief Video sensors are sensors that produce video frames.
* @brief The following sensor types are considered video sensors:
* OB_SENSOR_COLOR,
* OB_SENSOR_DEPTH,
* OB_SENSOR_IR,
* OB_SENSOR_IR_LEFT,
* OB_SENSOR_IR_RIGHT,
*
* @param type
* @return true
* @return false
*/
static bool isVideoSensorType(OBSensorType type) {
return ob_is_video_sensor_type(type);
}
/**
* @brief Check if the given stream type is a video stream.
* @brief Video streams are streams that contain video frames.
* @brief The following stream types are considered video streams:
* OB_STREAM_VIDEO,
* OB_STREAM_DEPTH,
* OB_STREAM_COLOR,
* OB_STREAM_IR,
* OB_STREAM_IR_LEFT,
* OB_STREAM_IR_RIGHT,
*
* @param type The stream type to check.
* @return true if the given stream type is a video stream, false otherwise.
*/
static bool isVideoStreamType(OBStreamType type) {
return ob_is_video_stream_type(type);
}
};
} // namespace ob
@@ -1,60 +1,2 @@
/**
* @file Types.hpp
* @brief Provides SDK structure and enumeration constant definitions (depending on libobsensor/h/ObTypes.h).
*/
#pragma once
#include "libobsensor/h/ObTypes.h"
#include <functional>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Callback function for file transfer status updates.
*
* @param state The file transfer status.
* @param message Status information.
* @param percent The percentage of the file that has been transferred.
*/
using SendFileCallback = std::function<void(OBFileTranState state, const char *message, uint8_t percent)>;
/**
* @brief Callback function for device upgrade status updates.
*
* @param state The device upgrade status.
* @param message Status information.
* @param percent The percentage of the upgrade that has been completed.
*/
using DeviceUpgradeCallback = std::function<void(OBUpgradeState state, const char *message, uint8_t percent)>;
/**
* @brief Callback function for device status updates.
*
* @param state The device status.
* @param message Status information.
*/
using DeviceStateChangedCallback = std::function<void(OBDeviceState state, const char *message)>;
/**
* @brief Callback function for getting raw data property data when data and progress callbacks are made.
*
* @param dataChunk The data chunk.
* @param state The status of getting the data.
*/
using GetDataCallback = std::function<void(OBDataTranState state, OBDataChunk *dataChunk)>;
/**
* @brief Callback function for setting the raw data property when progress callbacks are made.
*
* @param percent The progress percentage.
* @param state The status of setting the data.
*/
using SetDataCallback = std::function<void(OBDataTranState state, uint8_t percent)>;
#ifdef __cplusplus
}
#endif
// empty file, leave here for backwards compatibility
@@ -4,87 +4,95 @@
*
*/
#pragma once
#include "libobsensor/h/Utils.h"
#include "Device.hpp"
#include "Types.hpp"
#include "Frame.hpp"
#include <memory>
namespace ob {
class Device;
class OB_EXTENSION_API CoordinateTransformHelper {
class CoordinateTransformHelper {
public:
/**
* @brief Transform a 3d point of a source coordinate system into a 3d point of the target coordinate system.
*
* @param calibrationParam Device calibration param,see pipeline::getCalibrationParam
* @param sourcePoint3f Source 3d point value
* @param sourceSensorType Source sensor type
* @param targetSensorType Target sensor type
* @param targetPoint3f Target 3d point value
*
* @return bool Transform result
*/
static bool calibration3dTo3d(const OBCalibrationParam calibrationParam, const OBPoint3f sourcePoint3f, const OBSensorType sourceSensorType,
const OBSensorType targetSensorType, OBPoint3f *targetPoint3f);
/**
* @brief Transform a 2d pixel coordinate with an associated depth value of the source camera into a 3d point of the target coordinate system.
*
* @param calibrationParam Device calibration param,see pipeline::getCalibrationParam
* @param sourcePoint2f Source 2d point value
* @param sourceDepthPixelValue The depth of sourcePoint2f in millimeters
* @param sourceSensorType Source sensor type
* @param targetSensorType Target sensor type
* @param targetPoint3f Target 3d point value
* @param[in] source_point3f Source 3d point value
* @param[in] extrinsic Transformation matrix from source to target
* @param[out] target_point3f Target 3d point value
*
* @return bool Transform result
*/
static bool calibration2dTo3d(const OBCalibrationParam calibrationParam, const OBPoint2f sourcePoint2f, const float sourceDepthPixelValue,
const OBSensorType sourceSensorType, const OBSensorType targetSensorType, OBPoint3f *targetPoint3f);
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);
Error::handle(&error);
return result;
}
/**
* @brief Transform a 2d pixel coordinate with an associated depth value of the source camera into a 3d point of the target coordinate system.
* @brief This function uses undistortion, which may result in longer processing time.
*
* @param calibrationParam Device calibration param,see pipeline::getCalibrationParam
* @param sourcePoint2f Source 2d point value
* @param sourceDepthPixelValue The depth of sourcePoint2f in millimeters
* @param sourceSensorType Source sensor type
* @param targetSensorType Target sensor type
* @param targetPoint3f Target 3d point value
* @param[in] source_intrinsic Source intrinsic parameters
* @param[in] source_point2f Source 2d point value
* @param[in] source_depth_pixel_value The depth of sourcePoint2f in millimeters
* @param[in] extrinsic Transformation matrix from source to target
* @param[out] target_point3f Target 3d point value
*
* @return bool Transform result
*/
static bool calibration2dTo3dUndistortion(const OBCalibrationParam calibrationParam, const OBPoint2f sourcePoint2f, const float sourceDepthPixelValue,
const OBSensorType sourceSensorType, const OBSensorType targetSensorType, OBPoint3f *targetPoint3f);
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);
Error::handle(&error);
return result;
}
/**
* @brief Transform a 3d point of a source coordinate system into a 2d pixel coordinate of the target camera.
*
* @param calibrationParam Device calibration param,see pipeline::getCalibrationParam
* @param sourcePoint3f Source 3d point value
* @param sourceSensorType Source sensor type
* @param targetSensorType Target sensor type
* @param targetPoint2f Target 2d point value
* @param[in] source_point3f Source 3d point value
* @param[in] target_intrinsic Target intrinsic parameters
* @param[in] target_distortion Target distortion parameters
* @param[in] extrinsic Transformation matrix from source to target
* @param[out] target_point2f Target 2d point value
*
* @return bool Transform result
*/
static bool calibration3dTo2d(const OBCalibrationParam calibrationParam, const OBPoint3f sourcePoint3f, const OBSensorType sourceSensorType,
const OBSensorType targetSensorType, OBPoint2f *targetPoint2f);
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);
Error::handle(&error);
return result;
}
/**
* @brief Transform a 2d pixel coordinate with an associated depth value of the source camera into a 2d pixel coordinate of the target camera
*
* @param calibrationParam Device calibration param,see pipeline::getCalibrationParam
* @param sourcePoint2f Source 2d point value
* @param sourceDepthPixelValue The depth of sourcePoint2f in millimeters
* @param sourceSensorType Source sensor type
* @param targetSensorType Target sensor type
* @param targetPoint2f Target 2d point value
* @param[in] source_intrinsic Source intrinsic parameters
* @param[in] source_distortion Source distortion parameters
* @param[in] source_point2f Source 2d point value
* @param[in] source_depth_pixel_value The depth of sourcePoint2f in millimeters
* @param[in] target_intrinsic Target intrinsic parameters
* @param[in] target_distortion Target distortion parameters
* @param[in] extrinsic Transformation matrix from source to target
* @param[out] target_point2f Target 2d point value
*
* @return bool Transform result
*/
static bool calibration2dTo2d(const OBCalibrationParam calibrationParam, const OBPoint2f sourcePoint2f, const float sourceDepthPixelValue,
const OBSensorType sourceSensorType, const OBSensorType targetSensorType, OBPoint2f *targetPoint2f);
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;
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);
return result;
}
/**
* @brief Transforms the depth frame into the geometry of the color camera.
@@ -97,7 +105,16 @@ public:
* @return std::shared_ptr<ob::Frame> Transformed depth frame
*/
static std::shared_ptr<ob::Frame> transformationDepthFrameToColorCamera(std::shared_ptr<ob::Device> device, std::shared_ptr<ob::Frame> depthFrame,
uint32_t targetColorCameraWidth, uint32_t targetColorCameraHeight);
uint32_t targetColorCameraWidth, uint32_t targetColorCameraHeight) {
ob_error *error = NULL;
// 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);
Error::handle(&error);
return std::make_shared<ob::Frame>(result);
}
/**
* @brief Init transformation tables
@@ -112,7 +129,12 @@ public:
* @return bool Transform result
*/
static bool transformationInitXYTables(const OBCalibrationParam calibrationParam, const OBSensorType sensorType, float *data, uint32_t *dataSize,
OBXYTables *xyTables);
OBXYTables *xyTables) {
ob_error *error = NULL;
bool result = transformation_init_xy_tables(calibrationParam, sensorType, data, dataSize, xyTables, &error);
Error::handle(&error);
return result;
}
/**
* @brief Transform depth image to point cloud data
@@ -122,7 +144,11 @@ public:
* @param pointCloudData output point cloud data
*
*/
static void transformationDepthToPointCloud(OBXYTables *xyTables, const void *depthImageData, void *pointCloudData);
static void transformationDepthToPointCloud(OBXYTables *xyTables, const void *depthImageData, void *pointCloudData) {
ob_error *error = NULL;
transformation_depth_to_pointcloud(xyTables, depthImageData, pointCloudData, &error);
Error::handle(&error, false);
}
/**
* @brief Transform depth image to RGBD point cloud data
@@ -133,6 +159,49 @@ public:
* @param pointCloudData output RGBD point cloud data
*
*/
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);
}
// \deprecated This function is deprecated and will be removed in a future version.
// Use the transformation3dto3d instead.
OB_DEPRECATED 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);
Error::handle(&error);
return result;
}
// \deprecated This function is deprecated and will be removed in a future version.
// Use the transformation2dto3d instead.
OB_DEPRECATED 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);
Error::handle(&error);
return result;
}
// \deprecated This function is deprecated and will be removed in a future version.
// Use the transformation3dto2d instead.
OB_DEPRECATED 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);
Error::handle(&error);
return result;
}
// \deprecated This function is deprecated and will be removed in a future version.
// Use the transformation2dto2d instead.
OB_DEPRECATED 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);
Error::handle(&error);
return result;
}
};
} // namespace ob
@@ -4,42 +4,55 @@
*/
#pragma once
#include "libobsensor/h/Version.h"
namespace ob {
class OB_EXTENSION_API Version {
class Version {
public:
/**
* @brief Get the full version number of the SDK.
* @brief The full version number equals to: major * 10000 + minor * 100 + patch
*
* @return int The full version number of the SDK.
*/
static int getVersion() {
return ob_get_version();
}
/**
* @brief Get the major version number of the SDK.
*
* @return int The major version number of the SDK.
*/
static int getMajor();
static int getMajor() {
return ob_get_major_version();
}
/**
* @brief Get the minor version number of the SDK.
*
* @return int The minor version number of the SDK.
*/
static int getMinor();
static int getMinor() {
return ob_get_minor_version();
}
/**
* @brief Get the patch version number of the SDK.
*
* @return int The patch version number of the SDK.
*/
static int getPatch();
/**
* @brief Get the full version number of the SDK.
*
* @return int The full version number of the SDK.
*/
static int getVersion();
static int getPatch() {
return ob_get_patch_version();
}
/**
* @brief Get the stage version of the SDK.
* @brief The stage version string is a vendor defined string for some special releases.
*
* @return char* The stage version string of the SDK.
*/
static char *getStageVersion();
static const char *getStageVersion() {
return ob_get_stage_version();
}
};
} // namespace ob