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 #89

Merged
merged 4 commits into from
Mar 22, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
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 (millimetre 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 (millimetre 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 { METRE, CENTIMETRE, MILLIMETRE, 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::MILLIMETRE;

/**
* Custom depth unit multiplier, if custom depth unit is enabled, relative to 1 metre.
* A multiplier of 1000 effectively means depth unit in millimetre.
*/
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