update SDK to v1.6.1

This commit is contained in:
Joe Dong
2023-07-05 15:12:30 +08:00
parent 15ca0e347b
commit 05654eb0c7
42 changed files with 2794 additions and 5270 deletions
@@ -1,11 +1,7 @@
/**
* \if English
* @file Context.hpp
* @brief The SDK context class, the entry to the underlying SDK, is used to query device lists,handle device callbacks,set the level of the log
* \else
* @file Context.hpp
* @brief SDK上下文环境类,底层SDK的入口,用于获取设备列表,处理设备的回调,日志等级的设置操作
* \endif
* @brief The SDK context class, which serves as the entry point to the underlying SDK. It is used to query device lists, handle device callbacks, and set the
* log level.
*
*/
#pragma once
@@ -28,106 +24,113 @@ private:
public:
/**
* \if English
* @brief Context is a management class that describes the runtime of the SDK. It is responsible for the applying and releasing of resources for the SDK.
* The context has the ability to manage multiple devices, is responsible for enumerating devices, monitoring device callbacks, and enabling functions such
* as multi-device synchronization. \else
* @brief context是描述SDK的runtime一个管理类,负责SDK的资源申请与释放
* context具备多设备的管理能力,负责枚举设备,监听设备回调,启用多设备同步等功能
* \endif
*
* @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.
*/
Context(const char *configPath = "");
virtual ~Context() noexcept;
/**
*\if English
* @brief Query enumerated device list
* @brief Queries the enumerated device list.
*
* @return std::shared_ptr<DeviceList> returns a pointer to the device list class
* \else
* @brief 获取枚举到设备列表
*
* @return std::shared_ptr<DeviceList>返回设备列表类的指针
* \endif
* @return std::shared_ptr<DeviceList> A pointer to the device list class.
*/
std::shared_ptr<DeviceList> queryDeviceList();
/**
* @brief 创建网络设备对象
* @brief Creates a network device object.
*
* @param address ip 地址
* @param port 端口号
* @return std::shared_ptr<Device> 返回创建好的设备对象
* @param address The IP address.
* @param port The port.
* @return std::shared_ptr<Device> The created device object.
*/
std::shared_ptr<Device> createNetDevice(const char *address, uint16_t port);
using DeviceChangedCallback = std::function<void(std::shared_ptr<DeviceList> removedList, std::shared_ptr<DeviceList> addedList)>;
/**
* \if English
* @brief Set device plug-in callback function
* @brief Changes the IP configuration of a network device.
*
* @param callback function triggered when the device is plugged and unplugged
* \else
* @brief 设置设备插拔回调函数
* @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)>;
/**
* @brief Set the device plug-in callback function.
*
* @param callback 设备插拔时触发的回调函数
* \endif
* @param callback The function triggered when the device is plugged and unplugged.
*/
void setDeviceChangedCallback(DeviceChangedCallback callback);
/**
* \if English
* @brief Activate the multi-device synchronization function to synchronize the clock of the created device(the device needs support this function)
* @brief Activates the multi-device synchronization function to synchronize the clock of the created device (the device needs to support this function).
*
* @param repeatInterval synchronization time interval (unit: ms; if repeatInterval=0, it means that it will only be synchronized once and will not be
* executed regularly) \else
* @brief 启动多设备同步功能,同步已创建设备的时钟(需要使用的设备支持该功能)
*
* @param repeatInterval 定时同步时间间隔(单位ms;如果repeatInterval=0,表示只同步一次,不再定时执行)
* \endif
* @param repeatInterval The synchronization time interval (unit: ms; if repeatInterval=0, it means that it will only be synchronized once and will not be
* executed regularly).
*/
void enableMultiDeviceSync(uint64_t repeatInterval);
/**
* \if English
* @brief Set the level of the global log will affect both the log level output to the terminal and output to the file
* @brief Frees idle memory from the internal frame memory pool.
*/
void freeIdleMemory();
/**
* @brief Set the level of the global log, which affects both the log level output to the terminal and output to the file.
*
* @param severity log output level
* \else
* @brief 设置全局日志的等级,会同时作用于输出到终端和输出到文件的日志等级
*
* @param severity 日志输出等级
* \endif
* @param severity The log output level.
*/
static void setLoggerSeverity(OBLogSeverity severity);
/**
* \if English
* @brief Set log output to file
* @brief Set log output to a file.
*
* @param severity log level output to file
* @param severity The log level output to the file.
* @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) \else
* @brief 设置日志输出到文件
*
* @param severity 输出到文件的日志等级
* @param directory 日志文件输出路径,如果路径为空,则继续使用已有设置(已有配置也为空则不输出日志到文件)
* \endif
* empty, the log will not be output to the file).
*/
static void setLoggerToFile(OBLogSeverity severity, const char *directory);
/**
* \if English
* @brief Set log output to terminal
* @brief Set log output to the terminal.
*
* @param severity log level output to the terminal
* \else
* @brief 设置日志输出到终端
*
* @param severity 输出到终端的日志等级
* \endif
* @param severity The log level output to the terminal.
*/
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)>;
/**
* @brief Set the logger to callback.
*
* @param severity The callback log level.
* @param callback The callback function.
*/
static void setLoggerToCallback(OBLogSeverity severity, LogCallback callback);
/**
* @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);
/**
* @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);
};
} // namespace ob
File diff suppressed because it is too large Load Diff
@@ -1,11 +1,7 @@
/**
* \if English
* @file Error.hpp
* @brief Error describes the abnormal error within the SDK, and the detailed information of the exception can be realized through this class.
* \else
* @file Error.hpp
* @brief Error描述SDK内部的异常错误,通过该类可以实现异常的详细信息。
* \endif
* @brief This file defines the Error class, which describes abnormal errors within the SDK.
* Detailed information about the exception can be obtained through this class.
*/
#pragma once
@@ -25,40 +21,28 @@ public:
Error(const Error &error) noexcept;
~Error() noexcept;
/**
* \if English
* @brief Obtain detailed error logs of SDK internal exceptions.
* \else
* @brief 获取SDK内部异常的详细错误日志。
* \endif
* @brief Get the detailed error logs of SDK internal exceptions.
* @return A C-style string containing the error message.
*/
const char *getMessage() const noexcept;
/**
* \if English
* @brief Get the exception type of the error, and determine which module is abnormal.
* @return OBExceptionType
* \else
* @brief 获取该错误的异常类型,判断是具体哪个模块异常。
* @return OBExceptionType
* @brief Get the exception type of the error, which can be used to determine which module is abnormal.
* @return The OBExceptionType enum value.
*/
OBExceptionType getExceptionType() const noexcept;
/**
* \if English
* @brief Get the name of the error function.
* \else
* @brief 获取SDK内部异常的错误接口函数名称。
* \endif
* @return A C-style string containing the name of the error function.
*/
const char *getName() const noexcept;
/**
* \if English
* @brief Get the parameter passed in to the error interface.
* \else
* @brief 获取SDK内部异常的错误接口函数传入参数。
* \endif
* @brief Get the parameter passed to the error interface.
* @return A C-style string containing the error interface parameter.
*/
const char *getArgs() const noexcept;
};
@@ -1,11 +1,7 @@
/**
* \if English
* @file Filter.hpp
* @brief The processing unit of the SDK can perform point cloud generation, format conversion and other functions.
* \else
* @file Filter.hpp
* @brief SDK的处理单元,可以进行点云的生成,格式转换等功能
* \endif
* @brief This file contains the Filter class, which is the processing unit of the SDK that can perform point cloud generation, format conversion, and other
* functions.
*/
#pragma once
@@ -16,8 +12,14 @@
namespace ob {
class Frame;
/**
* @brief A callback function that takes a shared pointer to a Frame object as its argument.
*/
typedef std::function<void(std::shared_ptr<Frame>)> FilterCallback;
/**
* @brief The Filter class is the base class for all filters in the SDK.
*/
class OB_EXTENSION_API Filter {
public:
Filter();
@@ -25,53 +27,30 @@ public:
virtual ~Filter() = default;
/**
* \if English
* @brief filter reset, free the internal cache, stop the processing thread and clear the pending buffer frame when asynchronous processing
* \else
* @brief filter重置,释放内部缓存,异步处理时停止处理线程并清空待处理的缓存帧
* \endif
* @brief ReSet the filter, freeing the internal cache, stopping the processing thread, and clearing the pending buffer frame when asynchronous processing
* is used.
*/
virtual void reset();
/**
* \if English
* @brief Processing frames (synchronous interface)
* @brief Processes a frame synchronously.
*
* @param frame frame to be processed
* @return std::shared_ptr< Frame > processed frame
* \else
* @brief 处理帧(同步接口)
*
* @param frame 需要处理的frame
* @return std::shared_ptr< Frame > 处理后的frame
* \endif
* @param frame The frame to be processed.
* @return std::shared_ptr< Frame > The processed frame.
*/
virtual std::shared_ptr<Frame> process(std::shared_ptr<Frame> frame);
/**
* \if English
* @brief Push the pending frame into the cache (asynchronous callback interface)
* @brief Pushes the pending frame into the cache for asynchronous processing.
*
* @param frame The pending frame processing result is returned by the callback function
* \else
* @brief 压入待处理frame到缓存(异步回调接口)
*
* @param frame 待处理的frame处理结果通过回调函数返回
* \endif
* @param frame The pending frame. The processing result is returned by the callback function.
*/
virtual void pushFrame(std::shared_ptr<Frame> frame);
/**
* \if English
* @brief Set the callback function (asynchronous callback interface)
* @brief Set the callback function for asynchronous processing.
*
* @param callback Processing result callback
* \else
* @brief 设置回调函数(异步回调接口)
*
* @param callback 处理结果回调
* \endif
* @param callback The processing result callback.
*/
virtual void setCallBack(FilterCallback callback);
@@ -79,118 +58,93 @@ protected:
std::shared_ptr<FilterImpl> impl_;
};
/**
* @brief The PointCloudFilter class is a subclass of Filter that generates point clouds.
*/
class OB_EXTENSION_API PointCloudFilter : public Filter {
public:
PointCloudFilter();
/**
* \if English
* @brief Set point cloud type parameters
* @brief Set the point cloud type parameters.
*
* @param type Point cloud type depth point cloud or RGBD point cloud
* \else
* @brief 设置点云类型参数
*
* @param type 点云类型 深度点云或RGBD点云
* \endif
* @param type The point cloud type: depth point cloud or RGBD point cloud.
*/
void setCreatePointFormat(OBFormat type);
/**
* \if English
* @brief Set camera parameters
* @brief Set the camera parameters.
*
* @param param Camera internal and external parameters
* \else
* @brief 设置相机参数
*
* @param param 相机内外参数
* \endif
* @param param The camera internal and external parameters.
*/
void setCameraParam(OBCameraParam param);
/**
* \if English
* @brief Set the frame alignment state that will be input to generate point cloud (it needs to be enabled in D2C mode, as the basis for the algorithm to
* select the set of camera internal parameters)
* @brief Set the frame alignment state that will be input to generate point cloud.
*
* @param state Alignment status, True: enable alignment; False: disable alignment
* \else
* @brief 设置将要输入的用于生成点云的帧对齐状态(D2C模式下需要开启,作为算法选用那组相机内参的依据)
*
* @param state 对齐状态,True:开启对齐; False:关闭对齐
* \endif
* @param state The alignment status. True: enable alignment; False: disable alignment.
*/
void setFrameAlignState(bool state);
/**
* \if English
* @brief Set the point cloud coordinate data zoom factor
* @brief Set the point cloud coordinate data zoom factor.
*
* @attention Calling this function to set the scale will change the point coordinate scaling factor of the output point cloud frame: posScale = posScale /
* scale.The point coordinate scaling factor for the output point cloud frame can be obtained via @ref PointsFrame::getPositionValueScale function
* scale. The point coordinate scaling factor for the output point cloud frame can be obtained via @ref PointsFrame::getPositionValueScale function.
*
* @param scale Zoom factor
* \else
* @brief 设置点云坐标数据缩放比例
*
* @attention 调用该函数设置缩放比例会改变输出点云帧的点坐标缩放系数:posScale = posScale / scale;
* 输出点云帧的点坐标缩放系数可通过 @ref PointsFrame::getPositionValueScale 函数获取
*
* @param scale 缩放比例
* \endif
* @param scale The zoom factor.
*/
void setPositionDataScaled(float scale);
/**
* \if English
* @brief Set point cloud color data normalization
* @brief Set point cloud color data normalization.
*
* @param state Whether normalization is required
* \else
* @brief 设置点云颜色数据归一化
*
* @param state 是否需要归一化
* \endif
* @param state Whether normalization is required.
*/
void setColorDataNormalization(bool state);
/**
* @brief Set the point cloud coordinate system.
*
* @param type The coordinate system type.
*/
void setCoordinateSystem(OBCoordinateSystemType type);
};
/**
* @brief The FormatConvertFilter class is a subclass of Filter that performs format conversion.
*/
class OB_EXTENSION_API FormatConvertFilter : public Filter {
public:
FormatConvertFilter();
/**
* \if English
* @brief Set format conversion type
* @brief Set the format conversion type.
*
* @param type Format conversion type
* \else
* @brief 设置格式转化类型
*
* @param type 格式转化类型
* \endif
* @param type The format conversion type.
*/
void setFormatConvertType(OBConvertFormat type);
};
/**
* @brief The CompressionFilter class is a subclass of Filter that performs compression.
*/
class OB_EXTENSION_API CompressionFilter : public Filter {
public:
CompressionFilter();
/**
* \if English
* @brief Set compression params
* @brief Set the compression parameters.
*
* @param mode Compression mode OB_COMPRESSION_LOSSLESS or OB_COMPRESSION_LOSSY
* @param params Compression params, when mode is OB_COMPRESSION_LOSSLESS, params is NULL
* \else
* @brief 设置压缩参数
*
* @param mode 压缩模式 OB_COMPRESSION_LOSSLESS or OB_COMPRESSION_LOSSY
* @param params 压缩参数, 当mode为OB_COMPRESSION_LOSSLESS时,params为NULL
* \endif
* @param mode The compression mode: OB_COMPRESSION_LOSSLESS or OB_COMPRESSION_LOSSY.
* @param params The compression parameters. When mode is OB_COMPRESSION_LOSSLESS, params is NULL.
*/
void setCompressionParams(OBCompressionMode mode, void *params);
};
/**
* @brief The DecompressionFilter class is a subclass of Filter that performs decompression.
*/
class OB_EXTENSION_API DecompressionFilter : public Filter {
public:
DecompressionFilter();
@@ -1,11 +1,6 @@
/**
* \if English
* @file Frame.hpp
* @brief Frame related type, which is mainly used to obtain frame data and frame information.
* \else
* @file Frame.hpp
* @brief 帧相关类型,主要用于获取帧数据及帧的信息
* \endif
*
*/
#pragma once
@@ -17,12 +12,12 @@
#include <typeinfo>
/**
* Frame类继承关系:
* Frame class:
* Frame
* |
* +------+----------+----------+-----------+
* | | | | |
* VideoFrame PointFrame AccelFrame GyroFrame FrameSet
* VideoFrame PointsFrame AccelFrame GyroFrame FrameSet
* |
* +--+------+---------+
* | | |
@@ -47,149 +42,92 @@ protected:
std::unique_ptr<FrameImpl> impl_;
public:
Frame(std::unique_ptr<FrameImpl> impl);
explicit Frame(std::unique_ptr<FrameImpl> impl);
Frame(Frame &frame);
virtual ~Frame() noexcept;
/**
* \if English
* @brief Get the type of frame
* @brief Get the type of frame.
*
* @return OBFrameType returns the type of frame
* \else
* @brief 获取帧的类型
*
* @return OBFrameType 返回帧的类型
* \endif
* @return OBFrameType The type of frame.
*/
virtual OBFrameType type();
/**
* \if English
* @brief Get the format of the frame
* @brief Get the format of the frame.
*
* @return OBFormat returns the format of the frame
* \else
* @brief 获取帧的格式
*
* @return OBFormat 返回帧的格式
* \endif
* @return OBFormat The format of the frame.
*/
virtual OBFormat format();
/**
* \if English
* @brief Get the sequence number of the frame
* @brief Get the sequence number of the frame.
*
* @return uint64_t returns the sequence number of the frame
* \else
* @brief 获取帧的序号
*
* @return uint64_t 返回帧的序号
* \endif
* @return uint64_t The sequence number of the frame.
*/
virtual uint64_t index();
/**
* \if English
* @brief Get frame data
* @brief Get the frame data.
*
* @return void* returns frame data
* \else
* @brief 获取帧数据
*
* @return void* 返回帧数据
* \endif
* @return void* The frame data.
*/
virtual void *data();
/**
* \if English
* @brief Get the frame data size
* @brief Get the size of the frame data.
*
* @return uint32_t returns the frame data size
* If it is point cloud data, it returns the number of bytes occupied by all point sets. If you need to find the number of points, you need to divide the
* dataSize by the structure size of the corresponding point type. \else
* @brief 获取帧数据大小
*
* @return uint32_t 返回帧数据的大小
* 如果是点云数据返回的是所有点集合占的字节数,若需要求出点的个数需要将dataSize除以对应的点类型的结构体大小
* \endif
* @return uint32_t The size of the frame data.
* For point cloud data, this returns the number of bytes occupied by all point sets. To find the number of points, divide the dataSize by the structure
* size of the corresponding point type.
*/
virtual uint32_t dataSize();
/**
* \if English
* @brief Get the hardware timestamp of the frame
* @brief Get the hardware timestamp of the frame in milliseconds.
* @brief The hardware timestamp is the time point when the frame was captured by the device, on device clock domain.
*
* @return uint64_t returns the time stamp of the frame hardware
* \else
* @brief 获取帧的硬件时间戳
*
* @return uint64_t 返回帧硬件的时间戳
* \endif
* @return uint64_t The hardware timestamp of the frame in milliseconds.
*/
uint64_t timeStamp();
/**
* \if English
* @brief Get the hardware timestamp of the frame us
* @brief Get the hardware timestamp of the frame in microseconds.
* @brief The hardware timestamp is the time point when the frame was captured by the device, on device clock domain.
*
* @return uint64_t returns the time stamp of the frame hardware, unit us
* \else
* @brief 获取帧的硬件时间戳
*
* @return uint64_t 返回帧硬件的时间戳
* \endif
* @return uint64_t The hardware timestamp of the frame in microseconds.
*/
uint64_t timeStampUs();
/**
* \if English
* @brief Get frame system timestamp
* @brief Get the system timestamp of the frame in milliseconds.
* @brief The system timestamp is the time point when the frame was received by the host, on host clock domain.
*
* @return uint64_t returns the time stamp of the frame hardware
* \else
* @brief 获取帧的系统时间戳
*
* @return uint64_t 返回帧的系统时间戳
* \endif
* @return uint64_t The system timestamp of the frame in milliseconds.
*/
uint64_t systemTimeStamp();
/**
* \if English
* @brief Check if the runtime type of the frame object is compatible with a given type
* @brief Check if the runtime type of the frame object is compatible with a given type.
*
* @tparam T Given type
* @return bool returns result
* \else
* @brief 检查帧对象的运行时类型是否与给定类型兼容
*
* @tparam T 给定的类型
* @return bool 返回结果
* \endif
* @tparam T The given type.
* @return bool The result.
*/
template <typename T> bool is();
/**
* \if English
* @brief Frame object type conversion
* @brief Convert the frame object to a target type.
*
* @tparam T Target type
* @return std::shared_ptr<T> returns the result, if it cannot be converted, an exception will be thrown
* \else
* @brief 帧对象类型转换
*
* @tparam T 目标类型
* @return std::shared_ptr<T> 返回结果, 如果不能够转换,将抛异常
* \endif
* @tparam T The target type.
* @return std::shared_ptr<T> The result. If it cannot be converted, an exception will be thrown.
*/
template <typename T> std::shared_ptr<T> as() {
if(!is<T>())
throw "unsupported operation, object's type is not require type";
if(!is<T>()) {
throw std::runtime_error("unsupported operation, object's type is not require type");
}
return std::static_pointer_cast<T>(std::const_pointer_cast<Frame>(shared_from_this()));
return std::dynamic_pointer_cast<T>(shared_from_this());
}
private:
@@ -200,108 +138,83 @@ private:
class OB_EXTENSION_API VideoFrame : public Frame {
public:
VideoFrame(Frame &frame);
virtual ~VideoFrame() noexcept {};
explicit VideoFrame(Frame &frame);
explicit VideoFrame(std::unique_ptr<FrameImpl> impl);
~VideoFrame() noexcept override = default;
/**
* \if English
* @brief Get frame width
* @brief Get the width of the frame.
*
* @return uint32_t returns the width of the frame
* \else
* @brief 获取帧的宽
*
* @return uint32_t 返回帧的宽
* \endif
* @return uint32_t The width of the frame.
*/
uint32_t width();
/**
* \if English
* @brief Get frame height
* @brief Get the height of the frame.
*
* @return uint32_t returns the height of the frame
* \else
* @brief 获取帧的高
*
* @return uint32_t 返回帧的高
* \endif
* @return uint32_t The height of the frame.
*/
uint32_t height();
/**
* \if English
* @brief Get the metadata of the frame
* @brief Get the metadata of the frame.
*
* @return void* returns the metadata of the frame
* \else
* @brief 获取帧的元数据
*
* @return void* 返回帧的元数据
* \endif
* @return void* The metadata of the frame.
*/
void *metadata();
/**
* \if English
* @brief Get the metadata size of the frame
* @brief Get the size of the metadata of the frame.
*
* @return uint32_t returns the metadata size of the frame
* \else
* @brief 获取帧的元数据大小
*
* @return uint32_t 返回帧的元数据大小
* \endif
* @return uint32_t The size of the metadata of the frame.
*/
uint32_t metadataSize();
/**
* \if English
* @brief Get the effective number of pixels (such as Y16 format frame, but only the lower 10 bits are valid bits, and the upper 6 bits are filled with 0)
* @attention Only valid for Y8/Y10/Y11/Y12/Y14/Y16 format
* @brief Get the effective number of pixels in the frame.
* @attention Only valid for Y8/Y10/Y11/Y12/Y14/Y16 format.
*
* @return uint8_t returns the effective number of pixels in the pixel, or 0 if it is an unsupported format
* \else
* @brief 获取像素有效位数(如Y16格式帧,每个像素占16bit,但实际只有低10位是有效位,高6位填充0)
* @attention 仅对Y8/Y10/Y11/Y12/Y14/Y16格式有效
*
* @return uint8_t 返回像素有效位数,如果是不支持的格式,返回0
* \endif
* @return uint8_t The effective number of pixels in the frame, or 0 if it is an unsupported format.
*/
uint8_t pixelAvailableBitSize();
};
class OB_EXTENSION_API ColorFrame : public VideoFrame {
public:
ColorFrame(Frame &frame);
~ColorFrame() noexcept {};
explicit ColorFrame(Frame &frame);
explicit ColorFrame(std::unique_ptr<FrameImpl> impl);
~ColorFrame() noexcept override = default;
};
class OB_EXTENSION_API DepthFrame : public VideoFrame {
public:
DepthFrame(Frame &frame);
~DepthFrame() noexcept {};
explicit DepthFrame(Frame &frame);
explicit DepthFrame(std::unique_ptr<FrameImpl> impl);
~DepthFrame() noexcept override = default;
/**
* \if English
* @brief Get the value scale of the depth frame. The pixel value of depth frame is multiplied by the scale to give a depth value in millimeter.
* such as valueScale=0.1, and a certain coordinate pixel value is pixelValue=10000, then the depth value = pixelValue*valueScale = 10000*0.1=1000mm。
* @brief Get the value scale of the depth frame. The pixel value of depth frame is multiplied by the scale to give a depth value in millimeters.
* For example, if valueScale=0.1 and a certain coordinate pixel value is pixelValue=10000, then the depth value = pixelValue*valueScale =
* 10000*0.1=1000mm.
*
* @return float scale
* \else
* @brief 获取深度帧的值缩放系数,深度像素值乘以缩放系数后,可以得到单位为毫米的深度值; 如valueScale=0.1, 某坐标像素值为pixelValue=10000,
* 则表示深度值value = pixelValue*valueScale = 10000*0.1=1000mm。
*
* @return float 缩放系数
* \endif
* @return float The scale.
*/
float getValueScale();
};
class OB_EXTENSION_API IRFrame : public VideoFrame {
public:
IRFrame(Frame &frame);
virtual ~IRFrame() noexcept {};
explicit IRFrame(Frame &frame);
explicit IRFrame(std::unique_ptr<FrameImpl> impl);
~IRFrame() noexcept override = default;
public:
OBSensorType getDataSource();
@@ -309,245 +222,225 @@ public:
class OB_EXTENSION_API PointsFrame : public Frame {
public:
PointsFrame(Frame &frame);
~PointsFrame() noexcept {};
explicit PointsFrame(Frame &frame);
explicit PointsFrame(std::unique_ptr<FrameImpl> impl);
~PointsFrame() noexcept override = default;
/**
* \if English
* @brief Get the point position value scale of the points frame. the point position value of points frame is multiplied by the scale to give a position
* value in millimeter. such as scale=0.1, The x-coordinate value of a point is x = 10000, which means that the actual x-coordinate value = x*scale =
* 10000*0.1 = 1000mm.
* @brief Get the point position value scale of the points frame. The point position value of the points frame is multiplied by the scale to give a position
* value in millimeters. For example, if scale=0.1, the x-coordinate value of a point is x = 10000, which means that the actual x-coordinate value = x*scale
* = 10000*0.1 = 1000mm.
*
* @param[in] frame Frame object
* @param[out] error Log error messages
* @return float position value scale
* \else
* @brief 获取点云帧的点坐标值缩放系数,点坐标值乘以缩放系数后,可以得到单位为毫米的坐标值; 如scale=0.1, 某个点的x坐标值为x=10000,
* 则表示实际x坐标value = x*scale = 10000*0.1=1000mm。
*
* @return float 缩放系数
* \endif
* @return float The position value scale.
*/
float getPositionValueScale();
};
/**
* @brief Define the FrameSet class, which inherits from the Frame class
*
*/
class OB_EXTENSION_API FrameSet : public Frame {
public:
// FrameSet();
FrameSet(Frame &frame);
~FrameSet() noexcept;
explicit FrameSet(std::unique_ptr<FrameImpl> impl);
explicit FrameSet(Frame &frame);
~FrameSet() noexcept override;
/**
* \if English
* @brief Get frame count
* @brief Get the number of frames in the FrameSet
*
* @return uint32_t returns the number of frames
* \else
* @brief 帧集合中包含的帧数量
*
* @return uint32_t 返回帧的数量
* \endif
* @return uint32_t The number of frames
*/
uint32_t frameCount();
/**
* \if English
* @brief Get depth frame
* @brief Get the depth frame in the FrameSet
*
* @return std::shared_ptr<DepthFrame> returns the depth frame
* \else
* @brief 获取深度帧
*
* @return std::shared_ptr<DepthFrame> 返回深度帧
* \endif
* @return std::shared_ptr<DepthFrame> The depth frame
*/
std::shared_ptr<DepthFrame> depthFrame();
/**
* \if English
* @brief Get color frame
* @brief Get the color frame in the FrameSet
*
* @return std::shared_ptr<ColorFrame> returns the color frame
* \else
* @brief 获取彩色帧
*
* @return std::shared_ptr<ColorFrame> 返回彩色帧
* \endif
* @return std::shared_ptr<ColorFrame> The color frame
*/
std::shared_ptr<ColorFrame> colorFrame();
/**
* \if English
* @brief Get infrared frame
* @brief Get the infrared frame in the FrameSet
*
* @return std::shared_ptr<IRFrame> returns infrared frame
* \else
* @brief 获取红外帧
*
* @return std::shared_ptr<IRFrame> 返回红外帧
* \endif
* @return std::shared_ptr<IRFrame> The infrared frame
*/
std::shared_ptr<IRFrame> irFrame();
/**
* \if English
* @brief Get point cloud frame
* @brief Get the point cloud frame in the FrameSet
*
* @return std::shared_ptr<PointsFrame> returns the point cloud data frame
* \else
* @brief 获取点云帧
*
* @return std::shared_ptr<PointsFrame> 返回点云帧
* \endif
* @return std::shared_ptr<PointsFrame> The point cloud data frame
*/
std::shared_ptr<PointsFrame> pointsFrame();
/**
* \if English
* @brief Get frame by sensor type
* @brief Get a frame of a specific type from the FrameSet
*
* @param frameType Type of sensor
* @return std::shared_ptr<Frame> returns the corresponding type of frame
* \else
* @brief 通过传感器类型获取帧
*
* @param frameType 传感器的类型
* @return std::shared_ptr<Frame> 返回相应类型的帧
* \endif
* @param frameType The type of sensor
* @return std::shared_ptr<Frame> The corresponding type of frame
*/
std::shared_ptr<Frame> getFrame(OBFrameType frameType);
/**
* @brief Get a frame at a specific index from the FrameSet
*
* @param index The index of the frame
* @return std::shared_ptr<Frame> The frame at the specified index
*/
std::shared_ptr<Frame> getFrame(int index);
// Declare Pipeline and Filter classes as friends
friend class Pipeline;
friend class Filter;
};
/**
* @brief Define the AccelFrame class, which inherits from the Frame class
*
*/
class OB_EXTENSION_API AccelFrame : public Frame {
public:
AccelFrame(Frame &frame);
~AccelFrame() noexcept = default;
explicit AccelFrame(Frame &frame);
explicit AccelFrame(std::unique_ptr<FrameImpl> impl);
~AccelFrame() noexcept override = default;
/**
* \if English
* @brief Accelerometer frame data
* @brief Get the accelerometer frame data
*
* @return OBAccelValue
* \else
* @brief 获取加速度帧X数据
*
* @return OBAccelValue
* \endif
* @return OBAccelValue The accelerometer frame data
*/
OBAccelValue value();
/**
* \if English
* @brief Get the temperature when the frame is sampled
* @brief Get the temperature when the frame was sampled
*
* @return float temperature value
* \else
* @brief 获取帧采样时的温度
*
* @return float 温度值
* \endif
* @return float The temperature value
*/
float temperature();
};
/**
* @brief Define the GyroFrame class, which inherits from the Frame class
*/
class OB_EXTENSION_API GyroFrame : public Frame {
public:
GyroFrame(Frame &frame);
~GyroFrame() noexcept = default;
explicit GyroFrame(Frame &frame);
explicit GyroFrame(std::unique_ptr<FrameImpl> impl);
~GyroFrame() noexcept override = default;
/**
* \if English
* @brief Get gyro frame data
* @brief Get the gyro frame data
*
* @return OBAccelValue
* \else
* @brief 获取陀螺仪帧数据
*
* @return OBAccelValue
* \endif
* @return OBAccelValue The gyro frame data
*/
OBGyroValue value();
/**
* \if English
* @brief Get temperature when the frame is sampled.
* @brief Get the temperature when the frame was sampled
*
* @return float temperature value
* \else
* @brief 获取帧采样时的温度
*
* @return float 温度值
* \endif
* @return float The temperature value
*/
float temperature();
};
/**
* @brief Define the FrameHelper class
*/
class OB_EXTENSION_API FrameHelper {
public:
FrameHelper();
~FrameHelper();
/**
* @brief 根据外部创建的Buffer创建帧对象
* @brief Create a Frame object.
*
* @param format 帧对象格式
* @param frameWidth 帧对象宽
* @param frameHeight 帧对象高
* @param buffer 帧对象数据
* @param bufferSize 帧对象数据大小
* @return std::shared_ptr<Frame> 返回帧对象
* @param[in] type The type of frame. See @ref OBFrameType.
* @param[in] format The format of the frame. See @ref OBFormat.
* @param[in] width The width of the frame.
* @param[in] height The height of the frame.
* @param[in] strideBytes The stride of the frame in bytes. If strideBytes > 0, the frame data size = height * strideBytes. If strideBytes = 0, the frame
* datasize = height * width * pixelSize (pixelSize according to the format).
*
* @return std::shared_ptr<Frame> The created frame object.
*/
static std::shared_ptr<Frame> createFrameFromBuffer(OBFormat format, uint32_t frameWidth, uint32_t frameHeight, uint8_t *buffer, uint32_t bufferSize,
static std::shared_ptr<Frame> createFrame(OBFrameType type, OBFormat format, uint32_t width, uint32_t height, uint32_t strideBytes);
/**
* @brief Create a frame object based on an externally created buffer
*
* @param[in] format The format of the frame. See @ref OBFormat.
* @param[in] width The width of the frame.
* @param[in] height The height of the frame.
* @param[in] buffer The frame object buffer
* @param[in] bufferSize The frame object buffer size
* @param[in] destroyCallback The frame object buffer destroy callback
* @param[in] destroyCallbackContext The frame object buffer destroy callback context
*
* @return std::shared_ptr<Frame> The created frame object
*/
static std::shared_ptr<Frame> createFrameFromBuffer(OBFormat format, uint32_t width, uint32_t height, uint8_t *buffer, uint32_t bufferSize,
BufferDestroyCallback destroyCallback, void *destroyCallbackContext);
/**
* @brief 创建空的帧集合对象
* @brief Create an empty FrameSet object
*
* @return std::shared_ptr<Frame> 返回帧集合对象
* @return std::shared_ptr<Frame> The FrameSet object
*/
static std::shared_ptr<Frame> createFrameSet();
static std::shared_ptr<FrameSet> createFrameSet();
/**
* @brief 往帧集合中填入对应类型的帧
* @brief Add a frame of a specific type to the FrameSet
*
* @param frameSet 帧集合对象
* @param frameType 填入帧的类型
* @param frame 填入帧的对象
* @param frameSet The FrameSet object
* @param frameType The type of frame to add
* @param frame The frame object to add
*/
static void pushFrame(std::shared_ptr<Frame> frameSet, OBFrameType frameType, std::shared_ptr<Frame> frame);
/**
* @brief 设置帧的系统时间戳
* @brief Set the system timestamp of the frame.
*
* @param frame 设置的帧对象
* @param systemTimestamp 设置的系统时间戳
* @param frame The frame object.
* @param systemTimestamp The system timestamp to set in milliseconds.
*/
static void setFrameSystemTimestamp(std::shared_ptr<Frame> frame, uint64_t systemTimestamp);
/**
* @brief 设置帧的设备时间戳
* @brief Set the device timestamp of the frame.
*
* @param frame 设置的帧对象
* @param deviceTimestamp 设置的设备时间戳
* @param frame The frame object.
* @param deviceTimestamp The device timestamp to set in milliseconds.
*/
static void setFrameDeviceTimestamp(std::shared_ptr<Frame> frame, uint64_t deviceTimestamp);
/**
* @brief 设置帧的设备时间戳
* @brief Set the device timestamp of the frame.
*
* @param frame 设置的帧对象
* @param deviceTimestampUs 设置的设备时间戳(Us)
* @param frame The frame object.
* @param deviceTimestampUs The device timestamp to set in microseconds.
*/
static void setFrameDeviceTimestampUs(std::shared_ptr<Frame> frame, uint64_t deviceTimestampUs);
};
// Define the is() template function for the Frame class
template <typename T> bool Frame::is() {
switch(this->type()) {
case OB_FRAME_IR_LEFT: // follow
case OB_FRAME_IR_RIGHT: // follow
case OB_FRAME_IR_LEFT: // Follow
case OB_FRAME_IR_RIGHT: // Follow
case OB_FRAME_IR:
return (typeid(T) == typeid(IRFrame) || typeid(T) == typeid(VideoFrame));
case OB_FRAME_DEPTH:
@@ -563,7 +456,7 @@ template <typename T> bool Frame::is() {
case OB_FRAME_POINTS:
return (typeid(T) == typeid(PointsFrame));
default:
std::cout << "ob::Frame::is() not catch frame type: " << (int)this->type() << std::endl;
std::cout << "ob::Frame::is() did not catch frame type: " << (int)this->type() << std::endl;
break;
}
return false;
@@ -1,11 +1,7 @@
/**
* \if English
* @file Pipeline.hpp
* @brief The SDK's advanced API type can quickly implement switching streaming, frame synchronization, software filtering, and generating point cloud
* operations. \else
* @file Pipeline.hpp
* @brief SDK的高级API类型,可以快速实现开关流,帧同步,软件滤波,生成点云等操作
* \endif
* operations.
*/
#pragma once
@@ -35,343 +31,212 @@ private:
public:
/**
* \if English
* @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. \else
* @brief Pipeline 是SDK的高级接口,适用于应用,算法等重点关注RGBD数据流常见,Pipeline在SDK内部可以提供对齐,同步后的FrameSet桢集合
* 直接方便客户使用。
* Pipeline()无参数版本,默认打开连接到OS的设备列表中的第一个设备。若应用已经通过DeviceList获取设备,此时打开Pipeline()会抛出设备已经创建异常。
* 需要开发者捕获异常处理。
* \endif
* obtained the device through the DeviceList, opening the Pipeline() at this time will throw an exception that the device has been created.
*/
Pipeline();
/**
* \if English
* @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. \else
* @brief
* Pipeline(std::shared_ptr< Device > device )函数,适用于多设备操作常见,此时需要通过DeviceList获取多个设备,通过该接口实现device和pipeline绑定。
* \endif
* and pipeline are bound through this interface.
*/
Pipeline(std::shared_ptr<Device> device);
/**
* \if English
* @brief Create a pipeline for playback of recorded stream files
* @brief Construct a pipeline for playback of recorded stream files
*
* @param filename Playback file path
* \else
* @brief 创建pipeline用于回放录制好的流文件
*
* @param filename 回放文件路径
* \endif
* @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;
/**
* \if English
* @brief Start the pipeline with configuration parameters
*
* @param config Parameter configuration of pipeline
* \else
* @brief 启动pipeline并配置参数
*
* @param config pipeline的参数配置
* \endif
* @param config The parameter configuration of the pipeline
*/
void start(std::shared_ptr<Config> config);
/**
* \if English
* @brief Start the pipeline and set the frameset data callback
*
* @param config parameter configuration of pipeline
* @param callback Set the callback to be triggered when all frame data in the frame set arrives
* \else
* @brief 启动pipeline并设置帧集合数据回调
*
* @param config pipeline的参数配置
* @param callback 设置帧集合中的所有帧数据都到达时触发回调
* \endif
* @param config The parameter 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);
/**
* \if English
* @brief Stop pipeline
* \else
* @brief 停止pipeline
* \endif
* @brief Stop the pipeline
*/
void stop();
/**
* \if English
* @brief Get pipeline configuration parameters
* @brief Get the pipeline configuration parameters
*
* @return std::shared_ptr<Config> returns the configured parameters
* \else
* @brief 获取pipeline的配置参数
*
* @return std::shared_ptr<Config> 返回配置的参数
* \endif
* @return std::shared_ptr<Config> The configured parameters
*/
std::shared_ptr<Config> getConfig();
/**
* \if English
* @brief Waiting for frame set data
* @brief Wait for frameset data
*
* @param timeout_ms Waiting timeout (ms)
* @return std::shared_ptr<FrameSet> returns the waiting frame set data
* \else
* @brief 等待帧集合数据
*
* @param timeout_ms 等待超时时间(毫秒)
* @return std::shared_ptr<FrameSet> 返回等待的帧集合数据
* \endif
* @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);
/**
* \if English
* @brief Get device object
* @brief Get the device object
*
* @return std::shared_ptr<Device> returns the device object
* \else
* @brief 获取设备对象
*
* @return std::shared_ptr<Device> 返回设备对象
* \endif
* @return std::shared_ptr<Device> The device object
*/
std::shared_ptr<Device> getDevice();
/**
* \if English
* @brief Get playback object
* @brief Get the playback object
*
* @return std::shared_ptr<Playback> returns the playback object
* \else
* @brief 获取回放对象
*
* @return std::shared_ptr<Playback> 返回回放对象
* \endif
* @return std::shared_ptr<Playback> The playback object
*/
std::shared_ptr<Playback> getPlayback();
/**
* \if English
* @brief Get the stream profile of specified sensor
* @brief Get the stream profile of the specified sensor
*
* @param sensorType Type of sensor
* @return std::shared_ptr<StreamProfileList> returns the stream configuration list
* \else
* @brief 获取指定传感器的流配置
*
* @param sensorType 传感器的类型
* @return std::shared_ptr<StreamProfileList> 返回流配置列表
* \endif
* @param sensorType The type of sensor
* @return std::shared_ptr<StreamProfileList> The stream profile list
*/
std::shared_ptr<StreamProfileList> getStreamProfileList(OBSensorType sensorType);
/**
* \if English
* @brief Turn on frame synchronization
* \else
* @brief 打开帧同步功能
* \endif
*
*/
void enableFrameSync();
/**
* \if English
* @brief Turn off frame synchronization
* \else
* @brief 关闭帧同步功能
* \endif
*/
void disableFrameSync();
/**
* \if English
* @brief Get camera parameters
* @attention If D2C is enabled, it will return the camera parameters after D2C, if not, it will return to the default parameters
* @brief Get the camera parameters
*
* @return OBCameraParam returns camera parameters
* \else
* @brief 获取相机参数
* @attention 如果开启了D2C将返回D2C后的相机参数
* @note If D2C is enabled, it will return the camera parameters after D2C. If not, it will return the default parameters.
*
* @return OBCameraParam返回相机参数
* \endif
* @return OBCameraParam The camera parameters
*/
OBCameraParam getCameraParam();
/**
* \if English
* @brief Return a list of D2C-enabled depth sensor resolutions corresponding to the input color sensor resolution
* @param colorProfile Input color sensor resolution
* @param alignMode Input align mode
*
* @return std::shared_ptr<StreamProfileList> returns a list of depth sensor resolutions
* \else
* @brief 返回与输入的彩色传感器分辨率对应的支持D2C的深度传感器分辨率列表
* @param colorProfile 输入的彩色传感器分辨率
* @param alignMode 输入的对齐模式
*
* @return std::shared_ptr<StreamProfileList> 返回深度传感器分辨率列表
* \endif
* @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);
/**
* \if English
* @brief Get valid area between minimum distance and maximum distance after D2C
* @brief Get the valid area between the minimum distance and maximum distance after D2C
*
* @param minimumDistance minimum working distance
* @param maximumDistance maximum working distance
* @return OBRect returns the area information valid after D2C at the working distance
* \else
* @brief 获取D2C后给定工作范围的有效区域
* 如果需要获取指定距离D2C后的ROI区域,将minimum_distance与maximum_distance设置成一样或者将maximum_distance设置成0
*
* @param minimumDistance 最小工作距离
* @param maximumDistance 最大工作距离
* @return OBRect 返回在工作距离下D2C后有效的区域信息
* \endif
* @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);
/**
* \if English
* @brief Dynamically switch the corresponding config configuration
*
* @param config Updated config configuration
* \else
* @brief 动态切换对应的config配置
*
* @param config 更新后的config配置
* \endif
* @param config The updated config configuration
*/
void switchConfig(std::shared_ptr<Config> config);
/**
* \if English
* @brief start recording
* @brief Start recording
*
* @param filename Record file name
* \else
* @brief 开始录制
*
* @param filename 录制文件名
* \endif
* @param filename The name of the record file
*/
void startRecord(const char *filename);
/**
* \if English
* @brief Stop recording
* \else
* @brief 停止录制
* \endif
*/
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_;
public:
/**
* @brief Construct a new Config object
*/
Config();
/**
* @brief Destroy the Config object
*/
~Config() noexcept;
/**
* \if English
* @brief Configure the stream to be enabled
* @brief Enable a stream to be used in the pipeline
*
* @param streamProfile Stream configuration
* \else
* @brief 设置要打开的流配置
*
* @param streamProfile 流的配置
* \endif
* @param streamProfile The stream configuration to be enabled
*/
void enableStream(std::shared_ptr<StreamProfile> streamProfile);
/**
* \if English
* @brief Configure all streams to be enabled
* \else
* @brief 设置打开所有的流
* \endif
* @brief Enable all streams to be used in the pipeline
*/
void enableAllStream();
/**
* \if English
* @brief Configure the stream to be disabled
* @brief Disable a stream to be used in the pipeline
*
* @param streamType Stream configuration
* \else
* @brief 设置要关闭的流配置
*
* @param streamType 流的配置
* \endif
* @param streamType The stream configuration to be disabled
*/
void disableStream(OBStreamType streamType);
/**
* \if English
* @brief Configure all streams to be disabled
* \else
* @brief 设置关闭所有的流
* \endif
* @brief Disable all streams to be used in the pipeline
*/
void disableAllStream();
/**
* \if English
* @brief Set the alignment mode
*
* @param mode Align State Mode
* \else
* @brief 设置对齐模式
*
* @param mode 对齐状态模式
* \endif
* @param mode The alignment mode
*/
void setAlignMode(OBAlignMode mode);
/**
* \if English
* @brief Whether the depth needs to be scaled after setting D2C
* @brief Set whether the depth needs to be scaled after setting D2C
*
* @param enable Whether scaling is required
* \else
* @brief 设置D2C后是否需要缩放深度
*
* @param enable 是否需要缩放
* \endif
*/
void setDepthScaleRequire(bool enable);
/**
* \if English
* @brief Set the D2C target resolution, which 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 has a wide resolution
* @param d2cTargetHeight The D2C target has a high resolutio
* \else
* @brief 设置D2C目标分辨率,适用于未使用OrbbecSDK开启Color流,且需要对深度进行D2C的情况
* 注意:当使用OrbbecSDK开启Color流时,同时使用了此接口设置了D2C目标分辨率时。优先使用开启的Color流的配置进行D2C。
* @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.
*
* @param d2cTargetWidth D2C目标分辨率宽
* @param d2cTargetHeight D2C目标分辨率高
* \endif
* @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);
@@ -1,13 +1,8 @@
/**
* \if English
*
* @file RecordPlayback.hpp
* @brief For recording and playback functions
* \else
* @file RecordPlayback.hpp
* @brief 用于录制和回放功能
* \endif
* @brief Header file for recording and playback functions.
*/
#pragma once
#include "Types.hpp"
@@ -17,11 +12,12 @@ struct RecorderImpl;
struct PlaybackImpl;
namespace ob {
class Device;
class Frame;
class DeviceInfo;
using PlaybackCallback = std::function<void(std::shared_ptr<Frame> frame)>;
using PlaybackCallback = std::function<void(std::shared_ptr<Frame> frame)>;
using MediaStateCallback = std::function<void(OBMediaState state)>;
class OB_EXTENSION_API Recorder {
@@ -30,62 +26,36 @@ private:
public:
/**
* \if English
* @brief Create a recorder for data recording
* \else
* @brief 创建录制器用于数据的录制
* \endif
* @brief Create a recorder for data recording.
*/
Recorder();
Recorder(std::unique_ptr<RecorderImpl> impl);
/**
* \if English
* @brief Create a recorder for data recording
* @param device Devices that need to record device information
* \else
* @brief 创建录制器用于数据的录制
* @param device 需要录制设备信息的设备
* \endif
* @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;
/**
* \if English
* @brief Enable the recorder, throw an exception after failure
* @brief Enable the recorder. Throws an exception on failure.
*
* @param filename Recorded file name
* @param async Whether to execute asynchronously
* \else
* @brief 开启录制器,失败后抛出异常
*
* @param filename 录制的文件名称
* @param async 是否异步执行
* \endif
* @param filename The name of the recorded file.
* @param async Whether to execute asynchronously.
*/
void start(const char *filename, bool async = false);
/**
* \if English
* @brief Stop the recorder, throw an exception on failure
* \else
* @brief 停止录制器,失败后抛出异常
* \endif
* @brief Stop the recorder. Throws an exception on failure.
*/
void stop();
/**
* \if English
* @brief Write frame data to the recorder
* @brief Write frame data to the recorder.
*
* @param frame Write frame data
* \else
* @brief 向录制器内写入帧数据
*
* @param frame 写入的帧数据
* \endif
* @param frame The frame data to write.
*/
void write(std::shared_ptr<Frame> frame);
};
@@ -96,76 +66,42 @@ private:
public:
/**
* \if English
* @brief Create playback object
* @param filename Playback filename
* \else
* @brief 创建回放对象
* @param filename 回放的文件名
* \endif
* @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;
/**
* \if English
* @brief Start playback, the playback data is returned from the callback, and an exception is thrown after failure
* @param filename Playback filename
* @param callback Callback for playback data
* @param type Type of playback data
* \else
* @brief 开启回放,回放数据从回调中返回,失败后抛出异常
* @param filename 回放的文件名
* @param callback 回放数据的回调
* @param type 回放数据的类型
* \endif
* @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);
/**
* \if English
* @brief Stop playback and throw an exception if it fails
* \else
* @brief 停止回放,失败后抛出异常
* \endif
* @brief Stop playback. Throws an exception on failure.
*/
void stop();
/**
* \if English
* @brief Set playback state
* @param state playback status callback
* \else
* @brief 设置回放状态
* @param state 回放状态回调
* \endif
* @brief Set the playback state.
* @param state The playback status callback.
*/
void setPlaybackStateCallback(MediaStateCallback state);
/**
* \if English
* @brief Get the device information in the recording file
* @brief Get the device information in the recording file.
*
* @return DeviceInfo returns device information
* \else
* @brief 获取录制文件内的设备信息
*
* @return DeviceInfo 返回的设备信息
* \endif
* @return DeviceInfo The device information.
*/
std::shared_ptr<DeviceInfo> getDeviceInfo();
/**
* \if English
* @brief Get the intrinsic and extrinsic parameter information in the recording file
* @brief Get the intrinsic and extrinsic parameter in the recording file.
*
* @return OBCameraParam returns internal and external parameter information
* \else
* @brief 获取录制文件内的内外参信息
*
* @return OBCameraParam 返回的内外参信息
* \endif
* @return OBCameraParam The internal and external parameter.
*/
OBCameraParam getCameraParam();
};
@@ -1,11 +1,6 @@
/**
* \if English
* @file Sensor.hpp
* @brief Sensor related types, used to obtain stream configuration, open and close streams, set and get sensor properties.
* \else
* @file Sensor.hpp
* @brief 传感器相关类型,用于获取流配置,开关流,设置及获取传感器属性等操作
* \endif
* @brief Defines types related to sensors, which are used to obtain stream configurations, open and close streams, and set and get sensor properties.
*/
#pragma once
@@ -25,15 +20,9 @@ class Frame;
class ImuFrame;
/**
* \if English
* @brief frame data callback
* @brief Callback function for frame data.
*
* @param frame frame data
* \else
* @brief 帧数据回调
*
* @param frame 帧数据
* \endif
* @param frame The frame data.
*/
using FrameCallback = std::function<void(std::shared_ptr<Frame> frame)>;
@@ -46,64 +35,36 @@ public:
virtual ~Sensor() noexcept;
/**
* \if English
* @brief sensor type
* @brief Get the sensor type.
*
* @return OBSensorType returns the sensor type
* \else
* @brief 传感器类型
*
* @return OBSensorType 返回传感器类型
* \endif
* @return OBSensorType The sensor type.
*/
OBSensorType type();
/**
* \if English
* @brief Get the list of stream profiles
* @brief Get the list of stream profiles.
*
* @return std::shared_ptr<StreamProfileList> returns the stream configuration list
* \else
* @brief 获取传感器的流配置列表
*
* @return std::shared_ptr<StreamProfileList> 返回流配置列表
* \endif
* @return std::shared_ptr<StreamProfileList> The stream profile list.
*/
const std::shared_ptr<StreamProfileList> getStreamProfileList();
/**
* \if English
* @brief Open frame data stream and set up a callback
* @brief Open a frame data stream and set up a callback.
*
* @param streamProfile Stream configuration
* @param callback Set the callback when frame data arrives
* \else
* @brief 开启流并设置帧数据回调
*
* @param streamProfile 流的配置
* @param callback 设置帧数据到达时的回调
* \endif
* @param streamProfile The stream configuration.
* @param callback The callback to set when frame data arrives.
*/
void start(std::shared_ptr<StreamProfile> streamProfile, FrameCallback callback);
/**
* \if English
* @brief Stop stream
* \else
* @brief 停止流
* \endif
* @brief Stop the stream.
*/
void stop();
/**
* \if English
* @brief Dynamically switch resolutions
* @brief Dynamically switch resolutions.
*
* @param streamProfile Resolution to switch
* \else
* @brief 动态切换分辨率
*
* @param streamProfile 需要切换的分辨率
* \endif
* @param streamProfile The resolution to switch to.
*/
void switchProfile(std::shared_ptr<StreamProfile> streamProfile);
};
@@ -118,61 +79,33 @@ public:
virtual ~SensorList() noexcept;
/**
* \if English
* @brief Get sensor count
* @brief Get the number of sensors.
*
* @return uint32_t returns the number of Sensors
* \else
* @brief 获取Sensor数量
*
* @return uint32_t 返回Sensor的数量
* \endif
* @return uint32_t The number of sensors.
*/
uint32_t count();
/**
* \if English
* @brief Get the type of the specified Sensor
* @brief Get the type of the specified sensor.
*
* @param index Sensor index
* @return OBSensorType returns the Sensor type
* \else
* @brief 获取指定Sensor的类型
*
* @param index Sensor索引
* @return OBSensorType 返回Sensor类型
* \endif
* @param index The sensor index.
* @return OBSensorType The sensor type.
*/
OBSensorType type(uint32_t index);
/**
* \if English
* @brief Get Sensor by index number
* @brief Get a sensor by index number.
*
* @param index To create a device cable, the range is [0, count-1], if the index exceeds the range, an exception will be thrown
* @return std::shared_ptr<Sensor> returns the Sensor object
* \else
* @brief 通过索引号获取Sensor
*
* @param index 要创建设备的索,范围 [0, count-1],如果index超出范围将抛异常
* @return std::shared_ptr<Sensor> 返回Sensor对象
* \endif
* @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);
/**
* \if English
* @brief Obtain the Sensor through the Sensor type
* @brief Get a sensor by sensor type.
*
* @param sensorType Sensor type to be obtained
* @return std::shared_ptr<Sensor> returns a Sensor object, if the specified type of Sensor does not exist, it will return empty
* \else
* @brief 通过Sensor类型获取Sensor
*
* @param sensorType 要获取的Sensor类型
* @return std::shared_ptr<Sensor> 返回Sensor对象,如果指定类型Sensor不存在,将返回空
* \endif
* @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);
};
@@ -1,11 +1,6 @@
/**
* \if English
* @file StreamProfile.hpp
* @brief The stream configuration related type is used to get information such as the width, height, frame rate, and format of the stream.
* \else
* @file StreamProfile.hpp
* @brief 流配置相关类型,用于获取流的宽、高、帧率及格式等信息
* \endif
* @brief The stream profile related type is used to get information such as the width, height, frame rate, and format of the stream.
*/
#pragma once
@@ -31,64 +26,40 @@ protected:
public:
StreamProfile(std::unique_ptr<StreamProfileImpl> impl);
StreamProfile(StreamProfile &streamProfile);
~StreamProfile() noexcept;
virtual ~StreamProfile() noexcept;
/**
* \if English
* @brief Get the format of the stream
*
* @return OBFormat returns the format of the stream
* \else
* @brief 获取流的格式
*
* @return OBFormat 返回流的格式
* \endif
* @return OBFormat return the format of the stream
*/
OBFormat format() const;
/**
* \if English
* @brief Get the type of stream
*
* @return OBStreamType returns the type of the stream
* \else
* @brief 获取流的类型
*
* @return OBStreamType 返回流的类型
* \endif
* @return OBStreamType return the type of the stream
*/
OBStreamType type() const;
/**
* \if English
* @brief Check if frame object is compatible with the given type
*
* @tparam T Given type
* @return bool return result
* \else
* @brief 检查帧对象的运行时类型是否与给定类型兼容
*
* @tparam T 给定的类型
* @return bool 返回结果
* \endif
*/
template <typename T> bool is();
/**
* \if English
* @brief Object type conversion
* @brief Converts object type to target type
*
* @tparam T Target type
* @return std::shared_ptr<T> returns the result, if it cannot be converted, an exception will be thrown
* \else
* @brief 对象类型转换
*
* @tparam T 目标类型
* @return std::shared_ptr<T> 返回结果, 如果不能够转换,将抛异常
* \endif
* @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() {
if(!is<T>())
throw "unsupported operation, object's type is not require type";
if(!is<T>()) {
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()));
}
@@ -98,109 +69,86 @@ public:
friend class Pipeline;
};
/**
* @brief Class representing a video stream profile.
*/
class OB_EXTENSION_API VideoStreamProfile : public StreamProfile {
public:
VideoStreamProfile(StreamProfile &profile);
~VideoStreamProfile() noexcept;
explicit VideoStreamProfile(StreamProfile &profile);
explicit VideoStreamProfile(std::unique_ptr<StreamProfileImpl> impl);
~VideoStreamProfile() noexcept override;
/**
* \if English
* @brief Get stream frame rate
* @brief Return the frame rate of the stream.
*
* @return uint32_t returns the frame rate of the stream
* \else
* @brief 获取流的帧率
*
* @return uint32_t 返回流的帧率
* \endif
* @return uint32_t Return the frame rate of the stream.
*/
uint32_t fps() const;
/**
* \if English
* @brief Get stream width
* @brief Return the width of the stream.
*
* @return uint32_t returns the width of the stream
* \else
* @brief 获取流的宽
*
* @return uint32_t 返回流的宽
* \endif
* @return uint32_t Return the width of the stream.
*/
uint32_t width() const;
/**
* \if English
* @brief Get stream height
* @brief Return the height of the stream.
*
* @return uint32_t returns the high of the stream
* \else
* @brief 获取流的高
*
* @return uint32_t 返回流的高
* \endif
* @return uint32_t Return the height of the stream.
*/
uint32_t height() const;
};
/**
* @brief Class representing an accelerometer stream profile.
*/
class OB_EXTENSION_API AccelStreamProfile : public StreamProfile {
public:
AccelStreamProfile(StreamProfile &profile);
~AccelStreamProfile() noexcept;
explicit AccelStreamProfile(StreamProfile &profile);
explicit AccelStreamProfile(std::unique_ptr<StreamProfileImpl> impl);
~AccelStreamProfile() noexcept override;
/**
* \if English
* @brief Get full scale range
* @brief Return the full scale range.
*
* @return OBAccelFullScaleRange returns the scale range value
* \else
* @brief 获取满量程范围
*
* @return OBAccelFullScaleRange 返回量程范围值
* \endif
* @return OBAccelFullScaleRange Return the scale range value.
*/
OBAccelFullScaleRange fullScaleRange() const;
/**
* \if English
* @brief Get sampling frequency
* @brief Return the sampling frequency.
*
* @return OBAccelFullScaleRange returns the sampling frequency
* \else
* @brief 获取采样频率
*
* @return OBAccelFullScaleRange 返回采样频率
* \endif
* @return OBAccelFullScaleRange Return the sampling frequency.
*/
OBAccelSampleRate sampleRate() const;
};
/**
* @brief Class representing a gyroscope stream profile.
*/
class OB_EXTENSION_API GyroStreamProfile : public StreamProfile {
public:
GyroStreamProfile(StreamProfile &profile);
~GyroStreamProfile() noexcept;
explicit GyroStreamProfile(StreamProfile &profile);
explicit GyroStreamProfile(std::unique_ptr<StreamProfileImpl> impl);
~GyroStreamProfile() noexcept override;
/**
* \if English
* @brief Get full scale range
* @brief Return the full scale range.
*
* @return OBAccelFullScaleRange returns the scale range value
* \else
* @brief 获取满量程范围
*
* @return OBAccelFullScaleRange 返回量程范围值
* \endif
* @return OBAccelFullScaleRange Return the scale range value.
*/
OBGyroFullScaleRange fullScaleRange() const;
/**
* \if English
* @brief Get sampling frequency
* @brief Return the sampling frequency.
*
* @return OBAccelFullScaleRange returns the sampling frequency
* \else
* @brief 获取采样频率
*
* @return OBAccelFullScaleRange 返回采样频率
* \endif
* @return OBAccelFullScaleRange Return the sampling frequency.
*/
OBGyroSampleRate sampleRate() const;
};
@@ -229,58 +177,53 @@ protected:
std::unique_ptr<StreamProfileListImpl> impl_;
public:
StreamProfileList(std::unique_ptr<StreamProfileListImpl> impl);
explicit StreamProfileList(std::unique_ptr<StreamProfileListImpl> impl);
~StreamProfileList() noexcept;
/**
* \if English
* @brief Get stream profile count
* @brief Return the number of StreamProfile objects.
*
* @return uint32_t returns the number of StreamProfile
* \else
* @brief 获取StreamProfile数量
*
* @return uint32_t 返回StreamProfile的数量
* \endif
* @return uint32_t Return the number of StreamProfile objects.
*/
uint32_t count() const;
/**
* \if English
* @brief Get StreamProfile by index number
* @brief Return the StreamProfile object at the specified index.
*
* @param index Device index to be created,the range is [0, count-1],if the index exceeds the range, an exception will be thrown
* @return std::shared_ptr<StreamProfile> returns StreamProfile object
* \else
* @brief 通过索引号获取StreamProfile
*
* @param index 要创建设备的索,范围 [0, count-1],如果index超出范围将抛异常
* @return std::shared_ptr<StreamProfile> 返回StreamProfile对象
* \endif
* @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);
/**
* \if English
* @brief Match the corresponding stream profile through the passed in parameters. If there are multiple matches,
* the first one in the list will be returned by default. If no matched profile found, will throw exception!
* @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
* returned by default. Throws an exception if no matching profile is found.
*
* @param width Width. If no matching condition is required, it can be passed to 0
* @param height Height. If no matching condition is required, it can be passed to 0
* @param format Type. If no matching condition is required, it can be passed to OB_FORMAT_UNKNOWN
* @param fps Frame rate. If no matching condition is required, it can be passed to 0
* @return std::shared_ptr<StreamProfile> Returns the matching resolution
* \else
* @brief 通过传入的参数进行匹配对应的StreamProfile。若有多个匹配项默认返回列表中的第一个, 若没有找到匹配的项,则抛异常
*
* @param width 宽度,如不要求加入匹配条件,可传0
* @param height 高度,如不要求加入匹配条件,可传0
* @param format 类型,如不要求加入匹配条件,可传OB_FORMAT_UNKNOWN
* @param fps 帧率,如不要求加入匹配条件,可传0
* @return std::shared_ptr<StreamProfile> 返回匹配的分辨率
* \endif
* @param width The width of the stream. Pass 0 if no matching condition is required.
* @param height The height of the stream. Pass 0 if no matching condition is required.
* @param format The type of the stream. Pass OB_FORMAT_UNKNOWN if no matching condition is required.
* @param fps The frame rate of the stream. Pass 0 if no matching condition is required.
* @return std::shared_ptr<VideoStreamProfile> Return the matching resolution.
*/
const std::shared_ptr<VideoStreamProfile> getVideoStreamProfile(int width = 0, int height = 0, OBFormat format = OB_FORMAT_UNKNOWN, int fps = 0);
/**
* @brief Match the corresponding accelerometer stream profile based on the passed-in parameters. If multiple Match are found, the first one in the list
* is returned by default. Throws an exception if no matching profile is found.
*
* @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);
/**
* @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
* returned by default. Throws an exception if no matching profile is found.
*
* @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);
};
} // namespace ob
} // namespace ob
@@ -1,14 +1,8 @@
/**
* \if English
* \file Types.hpp
* \brief Provide SDK structure and enumeration constant definition (depending on libobsensor/h/ObTypes.h)
* \else
* \file Types.hpp
* \brief 提供SDK的结构体、枚举常量定义(依赖libobsensor/h/ObTypes.h)
*
* \endif
*
* @file Types.hpp
* @brief Provides SDK structure and enumeration constant definitions (depending on libobsensor/h/ObTypes.h).
*/
#pragma once
#include "libobsensor/h/ObTypes.h"
@@ -20,77 +14,44 @@ extern "C" {
#endif
/**
* \if English
* @brief file transfer callbacks
* @brief Callback function for file transfer status updates.
*
* @param state file transfer status
* @param message status information
* \else
* @brief 文件传输回调
*
* @param state 文件传输状态
* @param message 状态信息
* \endif
* @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)>;
/**
* \if English
* @brief device upgrade callback
* @brief Callback function for device upgrade status updates.
*
* @param state upgrade status
* @param message status information
* \else
* @brief 设备升级回调
*
* @param state 升级状态
* @param message 状态信息
* \endif
* @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)>;
/**
* \if English
* @brief device status callback
* @brief Callback function for device status updates.
*
* @param state device status
* @param message status information
* \else
* @brief 设备状态回调
*
* @param state 设备状态
* @param message 状态信息
* \endif
* @param state The device status.
* @param message Status information.
*/
using DeviceStateChangedCallback = std::function<void(OBDeviceState state, const char *message)>;
/**
* \if English
* @brief get raw data property data when data and progress callbacks
* @brief Callback function for getting raw data property data when data and progress callbacks are made.
*
* @param dataChunk data chunk
* @param state get the data status
* \else
* @brief 获取raw data属性数据时数据及进度回调
*
* @param dataChunk 数据块
* @param state 获取数据状态
* \endif
* @param dataChunk The data chunk.
* @param state The status of getting the data.
*/
using GetDataCallback = std::function<void(OBDataTranState state, OBDataChunk *dataChunk)>;
/**
* \if English
* @brief set the raw data property when the progress callback is made
* @brief Callback function for setting the raw data property when progress callbacks are made.
*
* @param percent progress percentage
* @param state set the data status
* \else
* @brief 设置raw data属性数据时进度回调
*
* @param percent 进度百分比
* @param state 设置数据状态
* \endif
* @param percent The progress percentage.
* @param state The status of setting the data.
*/
using SetDataCallback = std::function<void(OBDataTranState state, uint8_t percent)>;
@@ -1,11 +1,6 @@
/**
* \if English
* @file Version.hpp
* @brief Get the SDK version information
* \else
* @file Version.hpp
* @brief 获取SDK版本号相关信息的类
* \endif
* @brief Provides functions to retrieve version information of the SDK.
*/
#pragma once
@@ -13,53 +8,38 @@ namespace ob {
class OB_EXTENSION_API Version {
public:
/**
* \if English
* @brief Get the SDK major version number
* @brief Get the major version number of the SDK.
*
* @return int returns the SDK major version number
* \else
* @brief 获取SDK主版本号
*
* @return int 返回SDK主版本号
* \endif
* @return int The major version number of the SDK.
*/
static int getMajor();
/**
* \if English
* @brief Get the SDK minor version number
* @brief Get the minor version number of the SDK.
*
* @return int returns the SDK minor version number
* \else
* @brief 获取SDK副版本号
*
* @return int 返回SDK副版本号
* \endif
* @return int The minor version number of the SDK.
*/
static int getMinor();
/**
* \if English
* @brief Get the SDK revision number
* @brief Get the patch version number of the SDK.
*
* @return int returns the SDK revision number
* \else
* @brief 获取SDK修订版本号
*
* @return int 返回SDK修订版本号
* \endif
* @return int The patch version number of the SDK.
*/
static int getPatch();
/**
* \if English
* @brief Get the SDK version number
* @brief Get the full version number of the SDK.
*
* @return int returns the SDK version number
* \else
* @brief 获取SDK版本号
*
* @return int 返回SDK版本号
* \endif
* @return int The full version number of the SDK.
*/
static int getVersion();
/**
* @brief Get the stage version of the SDK.
*
* @return char* The stage version string of the SDK.
*/
static char *getStageVersion();
};
} // namespace ob