Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customizable depth unit #430

Merged
merged 4 commits into from Mar 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmake/Depthai/DepthaiDeviceSideConfig.cmake
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
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
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
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
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