update 2.0.3

This commit is contained in:
jj
2024-09-28 19:03:42 +08:00
parent 71ece588b3
commit 9cb729c935
16 changed files with 914 additions and 855 deletions
@@ -97,14 +97,28 @@ public:
return std::make_shared<DeviceInfo>(info);
}
/**
* @brief Check if the extension information is exist
*
* @param infoKey The key of the extension information
* @return bool Whether the extension information exists
*/
bool isExtensionInfoExist(const std::string &infoKey) const {
ob_error *error = nullptr;
auto exist = ob_device_is_extension_info_exist(impl_, infoKey.c_str(), &error);
Error::handle(&error);
return exist;
}
/**
* @brief Get information about extensions obtained from SDK supported by the device
*
* @param infoKey The key of the extension information
* @return const char* Returns extended information about the device
*/
const char *getExtensionInfo(const char *info_key) const {
const char *getExtensionInfo(const std::string &infoKey) const {
ob_error *error = nullptr;
const char *info = ob_device_get_extension_info(impl_, info_key, &error);
const char *info = ob_device_get_extension_info(impl_, infoKey.c_str(), &error);
Error::handle(&error);
return info;
}
@@ -713,6 +727,24 @@ public:
return state;
}
/**
* @brief Send data to the device and receive data from the device.
* @brief This is a factory and debug function, which can be used to send and receive data from the device. The data format is secret and belongs to the
* device vendor.
*
* @attention The send and receive data buffer are managed by the caller, the receive data buffer should be allocated at 1024 bytes or larger.
*
* @param[in] sendData The data to be sent to the device.
* @param[in] sendDataSize The size of the data to be sent to the device.
* @param[out] receiveData The data received from the device.
* @param[in out] receiveDataSize The requeseted size of the data received from the device, and the actual size of the data received from the device.
*/
void sendAndReceiveData(const uint8_t *sendData, uint32_t sendDataSize, uint8_t *receiveData, uint32_t *receiveDataSize) const {
ob_error *error = nullptr;
ob_device_send_and_receive_data(impl_, sendData, sendDataSize, receiveData, receiveDataSize, &error);
Error::handle(&error);
}
private:
static void firmwareUpdateCallback(ob_fw_update_state state, const char *message, uint8_t percent, void *userData) {
auto device = static_cast<Device *>(userData);
@@ -834,8 +866,8 @@ public:
/**
* @brief Get the connection type of the device
*
* @return const char* the connection type of the device,currently supports:"USB", "USB1.0", "USB1.1", "USB2.0", "USB2.1", "USB3.0", "USB3.1", "USB3.2",
* "Ethernet"
* @return const char* the connection type of the device,currently supports:"USB", "USB1.0", "USB1.1", "USB2.0", "USB2.1", "USB3.0", "USB3.1",
* "USB3.2", "Ethernet"
*/
const char *getConnectionType() const {
ob_error *error = nullptr;
@@ -796,7 +796,7 @@ public:
init(impl);
}
~NoiseRemovalFilter() noexcept = default;
~NoiseRemovalFilter() noexcept = default;
/**
* @brief Set the noise removal filter params.
@@ -922,16 +922,76 @@ public:
}
};
/**
* @brief Depth to disparity or disparity to depth
*/
class DisparityTransform : public Filter {
public:
DisparityTransform(const std::string &activationKey = "") {
ob_error *error = nullptr;
auto impl = ob_create_private_filter("DisparityTransform", activationKey.c_str(), &error);
Error::handle(&error);
init(impl);
}
~DisparityTransform() noexcept = default;
};
class OBFilterList {
private:
ob_filter_list_t* impl_;
public:
explicit OBFilterList(ob_filter_list_t *impl) : impl_(impl) {}
~OBFilterList() noexcept {
ob_error *error = nullptr;
ob_delete_filter_list(impl_, &error);
Error::handle(&error, false);
}
/**
* @brief Get the number of filters
*
* @return uint32_t The number of filters
*/
uint32_t getCount() const {
ob_error *error = nullptr;
auto count = ob_filter_list_get_count(impl_, &error);
Error::handle(&error);
return count;
}
/**
* @brief Get the Filter object at the specified index
*
* @param index The filter index. The range is [0, count-1]. If the index exceeds the range, an exception will be thrown.
* @return std::shared_ptr<Filter> The filter object.
*/
std::shared_ptr<Filter> getFilter(uint32_t index) {
ob_error *error = nullptr;
auto filter = ob_filter_list_get_filter(impl_, index, &error);
Error::handle(&error);
return std::make_shared<Filter>(filter);
}
public:
// The following interfaces are deprecated and are retained here for compatibility purposes.
uint32_t count() const {
return getCount();
}
};
/**
* @brief Define the Filter type map
*/
static const std::unordered_map<std::string, std::type_index> typeMap = {
static const std::unordered_map<std::string, std::type_index> obFilterTypeMap = {
{ "PointCloudFilter", typeid(PointCloudFilter) }, { "Align", typeid(Align) },
{ "FormatConverter", typeid(FormatConvertFilter) }, { "HDRMerge", typeid(HdrMerge) },
{ "SequenceIdFilter", typeid(SequenceIdFilter) }, { "DecimationFilter", typeid(DecimationFilter) },
{ "ThresholdFilter", typeid(ThresholdFilter) }, { "SpatialAdvancedFilter", typeid(SpatialAdvancedFilter) },
{ "HoleFillingFilter", typeid(HoleFillingFilter) }, { "NoiseRemovalFilter", typeid(NoiseRemovalFilter) },
{ "TemporalFilter", typeid(TemporalFilter) }
{ "TemporalFilter", typeid(TemporalFilter) }, { "DisparityTransform", typeid(DisparityTransform) }
};
/**
@@ -939,8 +999,8 @@ static const std::unordered_map<std::string, std::type_index> typeMap = {
*/
template <typename T> bool Filter::is() {
std::string name = type();
auto it = typeMap.find(name);
if(it != typeMap.end()) {
auto it = obFilterTypeMap.find(name);
if(it != obFilterTypeMap.end()) {
return std::type_index(typeid(T)) == it->second;
}
return false;
@@ -94,77 +94,6 @@ public:
return result;
}
/**
* @brief Transforms the depth frame into the geometry of the color camera.
*
* @param device Device handle
* @param depthFrame Input depth frame
* @param targetColorCameraWidth Target color camera width
* @param targetColorCameraHeight Target color camera height
*
* @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) {
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
*
* @param calibrationParam Device calibration param,see pipeline::getCalibrationParam
* @param sensorType sensor type
* @param data input data,needs to be allocated externally.During initialization, the external allocation size is 'dataSize', for example, dataSize = 1920 *
* 1080 * 2*sizeof(float) (1920 * 1080 represents the image resolution, and 2 represents two LUTs, one for x-coordinate and one for y-coordinate).
* @param dataSize input data size
* @param xyTables output xy tables
*
* @return bool Transform result
*/
static bool transformationInitXYTables(const OBCalibrationParam calibrationParam, const OBSensorType sensorType, float *data, uint32_t *dataSize,
OBXYTables *xyTables) {
ob_error *error = NULL;
bool result = transformation_init_xy_tables(calibrationParam, sensorType, data, dataSize, xyTables, &error);
Error::handle(&error);
return result;
}
/**
* @brief Transform depth image to point cloud data
*
* @param xyTables input xy tables,see CoordinateTransformHelper::transformationInitXYTables
* @param depthImageData input depth image data
* @param pointCloudData output point cloud data
*
*/
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
*
* @param xyTables input xy tables,see CoordinateTransformHelper::transformationInitXYTables
* @param depthImageData input depth image data
* @param colorImageData input color image data (only RGB888 support)
* @param pointCloudData output RGBD point cloud data
*
*/
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);
}
public:
// The following interfaces are deprecated and are retained here for compatibility purposes.
static bool calibration3dTo3d(const OBCalibrationParam calibrationParam, const OBPoint3f sourcePoint3f, const OBSensorType sourceSensorType,
@@ -198,5 +127,37 @@ public:
Error::handle(&error);
return result;
}
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) {
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);
}
static bool transformationInitXYTables(const OBCalibrationParam calibrationParam, const OBSensorType sensorType, float *data, uint32_t *dataSize,
OBXYTables *xyTables) {
ob_error *error = NULL;
bool result = transformation_init_xy_tables(calibrationParam, sensorType, data, dataSize, xyTables, &error);
Error::handle(&error);
return result;
}
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);
}
static void transformationDepthToRGBDPointCloud(OBXYTables *xyTables, const void *depthImageData, const void *colorImageData, void *pointCloudData){
ob_error *error = NULL;
transformation_depth_to_rgbd_pointcloud(xyTables, depthImageData, colorImageData, pointCloudData, &error);
Error::handle(&error, false);
}
};
} // namespace ob