Big refactoring code

* Removal of unnecessary files
* Optimized multi-camera launch
* Explicitly list the parameters in the launch file
This commit is contained in:
默存
2023-02-06 17:26:10 +08:00
parent 04e4d4151e
commit 202719bd8c
59 changed files with 4931 additions and 806 deletions
@@ -15,6 +15,7 @@
#include <memory>
#include <string>
#include <vector>
struct DeviceImpl;
struct DeviceInfoImpl;
@@ -27,6 +28,7 @@ class Context;
class DeviceInfo;
class Sensor;
class CameraParamList;
class OBDepthWorkModeList;
class OB_EXTENSION_API Device {
private:
@@ -407,6 +409,66 @@ public:
*/
void getStructuredData(OBPropertyID propertyId, void *data, uint32_t *dataSize);
/**
* \if English
* @brief Get structured data type of device property
*
* @param propertyId Property id
* @param dataBundle Target data
* @param callback Callback of setting
* \else
* @brief Set the Structured Data Ext object
*
* @param propertyId 属性id
* @param dataBundle 设置的目标数据
* @param callback 设置数据回调
* \endif
*/
void setStructuredDataExt(OBPropertyID propertyId, std::shared_ptr<OBDataBundle> dataBundle, SetDataCallback callback);
/**
* \if English
* @brief Get structured data type of device property
*
* @param propertyId Property id
* @return Data bundle
* \else
* @brief 获取structured data类型的数据
*
* @param propertyId 属性id
* @return std::shared_ptr<OBDataBundle> 数据集
* \endif
*/
std::shared_ptr<OBDataBundle> getStructuredDataExt(OBPropertyID propertyId);
/**
* \if English
* @brief Get the property protocol version
*
* @return OBProtocolVersion
* \else
* @brief 获取设备的控制命令协议版本
*
* @return OBProtocolVersion
* \endif
*/
OBProtocolVersion getProtocolVersion();
/**
* \if English
* @brief Get cmdVersion of property
*
* @param propertyId Property id
* @return OBCmdVersion
* \else
* @brief 获取控制命令的版本号
*
* @param propertyId 属性id
* @return OBCmdVersion
* \endif
*/
OBCmdVersion getCmdVersion(OBPropertyID propertyId);
/**
* \if English
* @brief Get number of devices supported property
@@ -563,6 +625,61 @@ public:
*/
std::shared_ptr<CameraParamList> getCalibrationCameraParamList();
/**
* \if English
* @brief Get current depth work mode
*
* @return ob_depth_work_mode Current depth work mode
* \else
* @brief 查询当前的相机深度模式
*
* @return 返回当前的相机深度模式
* \endif
*/
OBDepthWorkMode getCurrentDepthWorkMode();
/**
* \if English
* @brief Switch depth work mode by OBDepthWorkMode. Prefer invoke switchDepthWorkMode(const char *modeName) to switch depth mode
* when known the complete name of depth work mode.
* @param[in] workMode Depth work mode come from ob_depth_work_mode_list which return by ob_device_get_depth_work_mode_list
* \else
* @brief 切换相机深度模式(根据深度工作模式对象),如果知道设备支持的深度工作模式名称,那么推荐用switchDepthWorkMode(const char *modeName)
*
* @param workMode 要切换的相机深度模式
*
* @return 返回指令是否切换成功
* \endif
*/
OBStatus switchDepthWorkMode(const OBDepthWorkMode &workMode);
/**
* \if English
* @brief Switch depth work mode by work mode name.
*
* @param[in] mode name Depth work mode name which equals to ob_depth_work_mode.name
* \else
* @brief 切换相机深度模式(根据深度工作模式名称)
*
* @param workMode
*
* @return ob_status 设置设置结果,OB_STATUS_OK成功,其他:设置失败
* \endif
*/
OBStatus switchDepthWorkMode(const char *modeName);
/**
* \if English
* @brief Request support depth work mode list
* @return OBDepthWorkModeList list of ob_depth_work_mode
* \else
* @brief 查询相机深度模式列表
*
* @return 相机深度模式列表
* \endif
*/
std::shared_ptr<OBDepthWorkModeList> getDepthWorkModeList();
/**
* \if English
* @brief Device restart
@@ -576,6 +693,24 @@ public:
*/
void reboot();
/**
* @brief 获取当前设备同步配置
* @brief 设备同步:包括单机内的不同 Sensor 的曝光同步功能 和 多机同步功能
*
* @return OBDeviceSyncConfig 返回设备同步配置
*/
OBDeviceSyncConfig getSyncConfig();
/**
* @brief 设置设备同步配置
* @brief 用于配置 单机内的不同 Sensor 的曝光同步功能 和 多机同步功能
*
* @attention 调用本函数会直接将配置写入设备Flash,设备重启后依然会生效。为了避免影响Flash寿命,不要频繁更新配置。
*
* @param[out] deviceSyncConfig 设备同步配置
*/
void setSyncConfig(const OBDeviceSyncConfig &deviceSyncConfig);
friend class Pipeline;
friend class Recorder;
};
@@ -934,4 +1069,79 @@ public:
OBCameraParam getCameraParam(uint32_t index);
};
/**
* \if English
* @brief Type contain list of OBDepthWorkMode
* \else
* @brief 相机深度模式列表
* \endif
*
*/
class OB_EXTENSION_API OBDepthWorkModeList {
private:
std::unique_ptr<OBDepthWorkModeListImpl> impl_;
public:
OBDepthWorkModeList(std::unique_ptr<OBDepthWorkModeListImpl> impl_);
~OBDepthWorkModeList();
/**
* \if English
* @brief Get the count of OBDepthWorkMode
*
* @return Count of OBDepthWorkMode
* \else
* @brief 获取相机深度模式的数量
*
* @return 列表中的相机深度模式数量
* \endif
*/
uint32_t count();
/**
* \if English
* @brief Get OBDepthWorkMode at index in OBDepthWorkModeList
*
* @param[in] index Target OBDepthWorkMode's index
*
* @return OBDepthWorkMode at index
* \else
* @brief 根据下标获取相机深度模式
*
* @param index 对应模式列表的下标
* @return 相机深度模式
* \endif
*/
OBDepthWorkMode getOBDepthWorkMode(uint32_t index);
/**
* \if English
* @brief Get depth work mode name at index
*
* @return Depth work mode name
* \else
* @brief 模式名称
*
* @param index 对应模式列表的下标
* @return 模式名称
* \endif
*/
std::string getName(uint32_t index);
/**
* \if English
* @brief Get OBDepthWorkMode at index in OBDepthWorkModeList
*
* @param[in] index Target OBDepthWorkMode's index
*
* @return OBDepthWorkMode at index
* \else
* @brief 运算符重载,根据下标获取相机深度模式
*
* @param index 对应模式列表的下标
* @return 相机深度模式
* \endif
*/
OBDepthWorkMode operator[](uint32_t index);
};
} // namespace ob
@@ -123,28 +123,34 @@ public:
void setFrameAlignState(bool state);
/**
* \if English
* @brief Set point cloud position data scale ratio
* \if English
* @brief Set the point cloud coordinate data zoom factor
*
* @param scale scale ratio
* \else
* @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
*
* @param scale Zoom factor
* \else
* @brief 设置点云坐标数据缩放比例
*
* @attention 调用该函数设置缩放比例会改变输出点云帧的点坐标缩放系数:posScale = posScale / scale;
* 输出点云帧的点坐标缩放系数可通过 @ref PointsFrame::getPositionValueScale 函数获取
*
* @param scale 缩放比例
* \endif
* \endif
*/
void setPositionDataScaled(float scale);
/**
* \if English
* @brief Set point cloud color data normalization
* \if English
* @brief Set point cloud color data normalization
*
* @param state Whether to normalize
* \else
* @param state Whether normalization is required
* \else
* @brief 设置点云颜色数据归一化
*
* @param state 是否需要归一化
* \endif
* \endif
*/
void setColorDataNormalization(bool state);
};
@@ -165,4 +171,29 @@ public:
*/
void setFormatConvertType(OBConvertFormat type);
};
} // namespace ob
class OB_EXTENSION_API CompressionFilter : public Filter {
public:
CompressionFilter();
/**
* \if English
* @brief Set compression params
*
* @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
*/
void setCompressionParams(OBCompressionMode mode, void *params);
};
class OB_EXTENSION_API DecompressionFilter : public Filter {
public:
DecompressionFilter();
};
} // namespace ob
@@ -13,6 +13,7 @@
#include "Types.hpp"
#include <memory>
#include <iostream>
#include <typeinfo>
/**
@@ -26,7 +27,10 @@
* +--+------+---------+
* | | |
* ColorFrame DepthFrame IRFrame
*
* |
* +-----+-----+
* | |
* IRLeftFrame IRRightFrame
*/
struct FrameImpl;
@@ -280,17 +284,15 @@ public:
/**
* \if English
* @brief Get the value scale of the depth frame, the unit is mm/step,
* such as valueScale=0.1, and a certain coordinate pixel value is pixelValue=10000,
* then the depth value 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 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。
*
* @return float
* @return float scale
* \else
* @brief 获取深度帧的值刻度,单位为 mm/step,
* 如valueScale=0.1, 某坐标像素值为pixelValue=10000,
* @brief 获取深度帧的值缩放系数,深度像素值乘以缩放系数后,可以得到单位为毫米的深度值; 如valueScale=0.1, 某坐标像素值为pixelValue=10000,
* 则表示深度值value = pixelValue*valueScale = 10000*0.1=1000mm。
*
* @return float
* @return float 缩放系数
* \endif
*/
float getValueScale();
@@ -300,12 +302,33 @@ class OB_EXTENSION_API IRFrame : public VideoFrame {
public:
IRFrame(Frame &frame);
virtual ~IRFrame() noexcept {};
public:
OBSensorType getDataSource();
};
class OB_EXTENSION_API PointsFrame : public Frame {
public:
PointsFrame(Frame &frame);
~PointsFrame() noexcept {};
/**
* \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.
*
* @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
*/
float getPositionValueScale();
};
class OB_EXTENSION_API FrameSet : public Frame {
@@ -393,7 +416,7 @@ public:
* @return std::shared_ptr<Frame> 返回相应类型的帧
* \endif
*/
std::shared_ptr<Frame> getFrame(OBSensorType sensorType);
std::shared_ptr<Frame> getFrame(OBFrameType frameType);
friend class Pipeline;
friend class Filter;
@@ -523,6 +546,8 @@ public:
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:
return (typeid(T) == typeid(IRFrame) || typeid(T) == typeid(VideoFrame));
case OB_FRAME_DEPTH:
@@ -538,6 +563,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;
break;
}
return false;
@@ -230,13 +230,13 @@ public:
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
* \if English
* @brief Get valid area between 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
* \else
* @brief 获取D2C后给定工作范围的有效区域
* 如果需要获取指定距离D2C后的ROI区域,将minimum_distance与maximum_distance设置成一样或者将maximum_distance设置成0
*
@@ -245,7 +245,7 @@ public:
* @return OBRect 返回在工作距离下D2C后有效的区域信息
* \endif
*/
OBRect getD2CValidArea(uint32_t minimumDistance,uint32_t maximumDistance = 0);
OBRect getD2CValidArea(uint32_t minimumDistance, uint32_t maximumDistance = 0);
/**
* \if English
@@ -346,33 +346,34 @@ public:
void setAlignMode(OBAlignMode mode);
/**
* \if English
* @brief Whether scale depth frame after D2C
* \if English
* @brief Whether the depth needs to be scaled after setting D2C
*
* @param enable Scale or not
* \else
* @param enable Whether scaling is required
* \else
* @brief 设置D2C后是否需要缩放深度
*
* @param enable 是否需要缩放
* \endif
* \endif
*/
void setDepthScaleRequire(bool enable);
/**
* \if English
* @brief
*
* @param d2cTargetWidth D2C target width
* @param d2cTargetHeight D2C target height
* \else
* \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。
*
* @param d2cTargetWidth D2C目标分辨率宽
* @param d2cTargetHeight D2C目标分辨率高
* \endif
* \endif
*/
void setD2CTargetResolution(uint32_t d2cTargetWidth,uint32_t d2cTargetHeight);
void setD2CTargetResolution(uint32_t d2cTargetWidth, uint32_t d2cTargetHeight);
friend class Pipeline;
};
@@ -1,5 +1,6 @@
/**
* \if English
*
* @file RecordPlayback.hpp
* @brief For recording and playback functions
* \else
@@ -11,6 +11,7 @@
#include "Types.hpp"
#include <iostream>
#include <memory>
struct StreamProfileImpl;
@@ -43,7 +44,7 @@ public:
* @return OBFormat 返回流的格式
* \endif
*/
OBFormat format();
OBFormat format() const;
/**
* \if English
* @brief Get the type of stream
@@ -55,7 +56,7 @@ public:
* @return OBStreamType 返回流的类型
* \endif
*/
OBStreamType type();
OBStreamType type() const;
/**
* \if English
@@ -113,7 +114,7 @@ public:
* @return uint32_t 返回流的帧率
* \endif
*/
uint32_t fps();
uint32_t fps() const;
/**
* \if English
* @brief Get stream width
@@ -125,7 +126,7 @@ public:
* @return uint32_t 返回流的宽
* \endif
*/
uint32_t width();
uint32_t width() const;
/**
* \if English
* @brief Get stream height
@@ -137,7 +138,7 @@ public:
* @return uint32_t 返回流的高
* \endif
*/
uint32_t height();
uint32_t height() const;
};
class OB_EXTENSION_API AccelStreamProfile : public StreamProfile {
@@ -156,7 +157,7 @@ public:
* @return OBAccelFullScaleRange 返回量程范围值
* \endif
*/
OBAccelFullScaleRange fullScaleRange();
OBAccelFullScaleRange fullScaleRange() const;
/**
* \if English
@@ -169,7 +170,7 @@ public:
* @return OBAccelFullScaleRange 返回采样频率
* \endif
*/
OBAccelSampleRate sampleRate();
OBAccelSampleRate sampleRate() const;
};
class OB_EXTENSION_API GyroStreamProfile : public StreamProfile {
@@ -188,7 +189,7 @@ public:
* @return OBAccelFullScaleRange 返回量程范围值
* \endif
*/
OBGyroFullScaleRange fullScaleRange();
OBGyroFullScaleRange fullScaleRange() const;
/**
* \if English
@@ -201,13 +202,15 @@ public:
* @return OBAccelFullScaleRange 返回采样频率
* \endif
*/
OBGyroSampleRate sampleRate();
OBGyroSampleRate sampleRate() const;
};
template <typename T> bool StreamProfile::is() {
switch(this->type()) {
case OB_STREAM_VIDEO:
case OB_STREAM_IR:
case OB_STREAM_IR_LEFT:
case OB_STREAM_IR_RIGHT:
case OB_STREAM_COLOR:
case OB_STREAM_DEPTH:
return typeid(T) == typeid(VideoStreamProfile);
@@ -240,7 +243,7 @@ public:
* @return uint32_t 返回StreamProfile的数量
* \endif
*/
uint32_t count();
uint32_t count() const;
/**
* \if English
@@ -280,4 +283,4 @@ public:
const std::shared_ptr<VideoStreamProfile> getVideoStreamProfile(int width = 0, int height = 0, OBFormat format = OB_FORMAT_UNKNOWN, int fps = 0);
};
} // namespace ob
} // namespace ob