Skip to content

Commit

Permalink
Merge pull request #430 from luxonis/custom_depth_unit
Browse files Browse the repository at this point in the history
Customizable depth unit
  • Loading branch information
SzabolcsGergely authored Mar 22, 2022
2 parents 026f870 + 529fc91 commit e9bdf2a
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmake/Depthai/DepthaiDeviceSideConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set(DEPTHAI_DEVICE_SIDE_MATURITY "snapshot")

# "full commit hash of device side binary"
set(DEPTHAI_DEVICE_SIDE_COMMIT "b3bbd4d5a9a8108b654e6e63e0beb21520c2beca")
set(DEPTHAI_DEVICE_SIDE_COMMIT "df5e50e79532ddaa879a6ccf2928fbbe27adeef7")

# "version if applicable"
set(DEPTHAI_DEVICE_SIDE_VERSION "")
12 changes: 12 additions & 0 deletions include/depthai/pipeline/datatype/StereoDepthConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ class StereoDepthConfig : public Buffer {
*/
StereoDepthConfig& setSubpixel(bool enable);

/**
* Set depth unit of depth map.
*
* Meter, centimeter, millimeter, inch, foot or custom unit is available.
*/
StereoDepthConfig& setDepthUnit(AlgorithmControl::DepthUnit depthUnit);

/**
* Get depth unit of depth map.
*/
AlgorithmControl::DepthUnit getDepthUnit();

/**
* Useful for normalization of the disparity map.
* @returns Maximum disparity value that the node can return
Expand Down
4 changes: 2 additions & 2 deletions include/depthai/pipeline/node/SpatialDetectionNetwork.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ class SpatialDetectionNetwork : public NodeCRTP<DetectionNetwork, SpatialDetecti
void setBoundingBoxScaleFactor(float scaleFactor);

/**
* Specifies lower threshold in millimeters for depth values which will used to calculate spatial data
* Specifies lower threshold in depth units (millimeter by default) for depth values which will used to calculate spatial data
* @param lowerThreshold LowerThreshold must be in the interval [0,upperThreshold] and less than upperThreshold.
*/
void setDepthLowerThreshold(uint32_t lowerThreshold);

/**
* Specifies upper threshold in millimeters for depth values which will used to calculate spatial data
* Specifies upper threshold in depth units (millimeter by default) for depth values which will used to calculate spatial data
* @param upperThreshold UpperThreshold must be in the interval (lowerThreshold,65535].
*/
void setDepthUpperThreshold(uint32_t upperThreshold);
Expand Down
2 changes: 1 addition & 1 deletion include/depthai/pipeline/node/StereoDepth.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class StereoDepth : public NodeCRTP<Node, StereoDepth, StereoDepthProperties> {
Input right{*this, "right", Input::Type::SReceiver, false, 8, true, {{DatatypeEnum::ImgFrame, true}}};

/**
* Outputs ImgFrame message that carries RAW16 encoded (0..65535) depth data in millimeters.
* Outputs ImgFrame message that carries RAW16 encoded (0..65535) depth data in depth units (millimeter by default).
*
* Non-determined / invalid depth values are set to 0
*/
Expand Down
9 changes: 9 additions & 0 deletions src/pipeline/datatype/StereoDepthConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ StereoDepthConfig& StereoDepthConfig::setSubpixel(bool enable) {
return *this;
}

StereoDepthConfig& StereoDepthConfig::setDepthUnit(AlgorithmControl::DepthUnit depthUnit) {
cfg.algorithmControl.depthUnit = depthUnit;
return *this;
}

dai::StereoDepthConfig::AlgorithmControl::DepthUnit StereoDepthConfig::getDepthUnit() {
return cfg.algorithmControl.depthUnit;
}

float StereoDepthConfig::getMaxDisparity() const {
float maxDisp = 95.0;
if(cfg.costMatching.disparityWidth == RawStereoDepthConfig::CostMatching::DisparityWidth::DISPARITY_64) {
Expand Down

0 comments on commit e9bdf2a

Please sign in to comment.