Skip to content

Commit

Permalink
Merge pull request #89 from luxonis/custom_depth_unit
Browse files Browse the repository at this point in the history
Add customizable depth unit
  • Loading branch information
SzabolcsGergely authored Mar 22, 2022
2 parents 2e3dbf7 + 14eb244 commit be5a9a4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace dai {
/**
* SpatialLocation configuration thresholds structure
*
* Contains configuration data for lower and upper threshold in millimeters for ROI.
* Contains configuration data for lower and upper threshold in depth units (millimeter by default) for ROI.
* Values outside of threshold range will be ignored when calculating spatial coordinates from depth map.
*/
struct SpatialLocationCalculatorConfigThresholds {
Expand Down
2 changes: 1 addition & 1 deletion include/depthai-shared/datatype/RawSpatialLocations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace dai {
*
* Contains configuration data, average depth for the calculated ROI on depth map.
* Together with spatial coordinates: x,y,z relative to the center of depth map.
* Units are in millimeters.
* Units are in depth units (millimeter by default).
*/
struct SpatialLocations {
/**
Expand Down
33 changes: 28 additions & 5 deletions include/depthai-shared/datatype/RawStereoDepthConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,28 @@ struct RawStereoDepthConfig : public RawBuffer {
*/
enum class DepthAlign : int32_t { RECTIFIED_RIGHT, RECTIFIED_LEFT, CENTER };

/**
* Measurement unit for depth data
*/
enum class DepthUnit : int32_t { METER, CENTIMETER, MILLIMETER, INCH, FOOT, CUSTOM };

/**
* Set the disparity/depth alignment to the perspective of a rectified output, or center it
*/
DepthAlign depthAlign = DepthAlign::RECTIFIED_RIGHT;

/**
* Measurement unit for depth data.
* Depth data is integer value, multiple of depth unit.
*/
DepthUnit depthUnit = DepthUnit::MILLIMETER;

/**
* Custom depth unit multiplier, if custom depth unit is enabled, relative to 1 meter.
* A multiplier of 1000 effectively means depth unit in millimeter.
*/
float customDepthUnitMultiplier = 1000.f;

/**
* Computes and combines disparities in both L-R and R-L directions, and combine them.
* For better occlusion handling
Expand Down Expand Up @@ -64,7 +81,15 @@ struct RawStereoDepthConfig : public RawBuffer {
*/
std::int32_t subpixelFractionalBits = 3;

DEPTHAI_SERIALIZE(AlgorithmControl, depthAlign, enableLeftRightCheck, enableExtended, enableSubpixel, leftRightCheckThreshold, subpixelFractionalBits);
DEPTHAI_SERIALIZE(AlgorithmControl,
depthAlign,
depthUnit,
customDepthUnitMultiplier,
enableLeftRightCheck,
enableExtended,
enableSubpixel,
leftRightCheckThreshold,
subpixelFractionalBits);
};

/**
Expand Down Expand Up @@ -135,7 +160,6 @@ struct RawStereoDepthConfig : public RawBuffer {

/**
* Temporal filtering with optional persistence.
* More details about the filter can be found here:
*/
struct TemporalFilter {
static constexpr const std::int32_t DEFAULT_DELTA_VALUE = 3;
Expand Down Expand Up @@ -186,7 +210,6 @@ struct RawStereoDepthConfig : public RawBuffer {

/**
* Temporal filtering with optional persistence.
* More details about the filter can be found here:
*/
TemporalFilter temporalFilter;

Expand All @@ -196,12 +219,12 @@ struct RawStereoDepthConfig : public RawBuffer {
*/
struct ThresholdFilter {
/**
* Minimum range in millimeters.
* Minimum range in depth units.
* Depth values under this value are invalidated.
*/
std::int32_t minRange = 0;
/**
* Maximum range in millimeters.
* Maximum range in depth units.
* Depth values over this value are invalidated.
*/
std::int32_t maxRange = 65535;
Expand Down

0 comments on commit be5a9a4

Please sign in to comment.