Skip to content

Commit

Permalink
Merge pull request #43 from luxonis/develop
Browse files Browse the repository at this point in the history
Release 2.6.0
  • Loading branch information
SzabolcsGergely authored Jul 5, 2021
2 parents b98a4d8 + d002edb commit 9b5d920
Show file tree
Hide file tree
Showing 19 changed files with 264 additions and 108 deletions.
11 changes: 0 additions & 11 deletions include/depthai-shared/common/CameraBoardSocket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,3 @@ namespace dai {
enum class CameraBoardSocket : int32_t { AUTO = -1, RGB, LEFT, RIGHT };

} // namespace dai

namespace std {

template <>
struct hash<dai::CameraBoardSocket> {
std::size_t operator()(const dai::CameraBoardSocket& s) const {
using Type = typename underlying_type<dai::CameraBoardSocket>::type;
return std::hash<Type>{}(static_cast<Type>(s));
}
};
} // namespace std
2 changes: 2 additions & 0 deletions include/depthai-shared/datatype/DatatypeEnum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ enum class DatatypeEnum : std::int32_t {
SystemInformation,
SpatialLocationCalculatorConfig,
SpatialLocationCalculatorData,
EdgeDetectorConfig,
Tracklets,
IMUData,
StereoDepthConfig,
};
bool isDatatypeSubclassOf(DatatypeEnum parent, DatatypeEnum children);

Expand Down
4 changes: 2 additions & 2 deletions include/depthai-shared/datatype/RawBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ struct RawBuffer {
virtual ~RawBuffer() = default;
std::vector<std::uint8_t> data;

virtual void serialize(std::vector<std::uint8_t>& metadata, DatatypeEnum& datatype) {
virtual void serialize(std::vector<std::uint8_t>& metadata, DatatypeEnum& datatype) const {
(void)metadata;
datatype = DatatypeEnum::Buffer;
};

// NLOHMANN_DEFINE_TYPE_INTRUSIVE(RawBuffer);
};

} // namespace dai
} // namespace dai
4 changes: 2 additions & 2 deletions include/depthai-shared/datatype/RawCameraControl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ struct RawCameraControl : public RawBuffer {
return !!(cmdMask & (1ull << (uint8_t)cmd));
}

void serialize(std::vector<std::uint8_t>& metadata, DatatypeEnum& datatype) override {
void serialize(std::vector<std::uint8_t>& metadata, DatatypeEnum& datatype) const override {
nlohmann::json j = *this;
metadata = nlohmann::json::to_msgpack(j);
datatype = DatatypeEnum::CameraControl;
Expand Down Expand Up @@ -263,4 +263,4 @@ struct RawCameraControl : public RawBuffer {
chromaDenoise);
};

} // namespace dai
} // namespace dai
43 changes: 43 additions & 0 deletions include/depthai-shared/datatype/RawEdgeDetectorConfig.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#pragma once
#include <cstdint>
#include <nlohmann/json.hpp>
#include <vector>

#include "DatatypeEnum.hpp"
#include "RawBuffer.hpp"
#include "RawImgFrame.hpp"
#include "depthai-shared/common/Rect.hpp"

namespace dai {

/// EdgeDetectorConfigData configuration data structure
struct EdgeDetectorConfigData {
/**
* Used for horizontal gradiant computation in 3x3 Sobel filter
* Format: 3x3 matrix, 2nd column must be 0
* Default: +1 0 -1; +2 0 -2; +1 0 -1
*/
std::vector<std::vector<int>> sobelFilterHorizontalKernel;
/**
* Used for vertical gradiant computation in 3x3 Sobel filter
* Format: 3x3 matrix, 2nd row must be 0
* Default: +1 +2 +1; 0 0 0; -1 -2 -1
*/
std::vector<std::vector<int>> sobelFilterVerticalKernel;
};
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(EdgeDetectorConfigData, sobelFilterHorizontalKernel, sobelFilterVerticalKernel);

/// RawEdgeDetectorConfig configuration structure
struct RawEdgeDetectorConfig : public RawBuffer {
EdgeDetectorConfigData config;

void serialize(std::vector<std::uint8_t>& metadata, DatatypeEnum& datatype) const override {
nlohmann::json j = *this;
metadata = nlohmann::json::to_msgpack(j);
datatype = DatatypeEnum::EdgeDetectorConfig;
};

NLOHMANN_DEFINE_TYPE_INTRUSIVE(RawEdgeDetectorConfig, config);
};

} // namespace dai
2 changes: 1 addition & 1 deletion include/depthai-shared/datatype/RawIMUData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(IMUPacket, acceleroMeter, gyroscope, magnetic
struct RawIMUData : public RawBuffer {
std::vector<IMUPacket> packets;

void serialize(std::vector<std::uint8_t>& metadata, DatatypeEnum& datatype) override {
void serialize(std::vector<std::uint8_t>& metadata, DatatypeEnum& datatype) const override {
nlohmann::json j = *this;
metadata = nlohmann::json::to_msgpack(j);
datatype = DatatypeEnum::IMUData;
Expand Down
4 changes: 2 additions & 2 deletions include/depthai-shared/datatype/RawImageManipConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ struct RawImageManipConfig : public RawBuffer {
bool reusePreviousImage = false;
bool skipCurrentImage = false;

void serialize(std::vector<std::uint8_t>& metadata, DatatypeEnum& datatype) override {
void serialize(std::vector<std::uint8_t>& metadata, DatatypeEnum& datatype) const override {
nlohmann::json j = *this;
metadata = nlohmann::json::to_msgpack(j);
datatype = DatatypeEnum::ImageManipConfig;
Expand All @@ -115,4 +115,4 @@ struct RawImageManipConfig : public RawBuffer {
RawImageManipConfig, cropConfig, resizeConfig, formatConfig, enableCrop, enableResize, enableFormat, reusePreviousImage, skipCurrentImage);
};

} // namespace dai
} // namespace dai
2 changes: 1 addition & 1 deletion include/depthai-shared/datatype/RawImgDetections.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct ImgDetection {
struct RawImgDetections : public RawBuffer {
std::vector<ImgDetection> detections;

void serialize(std::vector<std::uint8_t>& metadata, DatatypeEnum& datatype) override {
void serialize(std::vector<std::uint8_t>& metadata, DatatypeEnum& datatype) const override {
nlohmann::json j = *this;
metadata = nlohmann::json::to_msgpack(j);
datatype = DatatypeEnum::ImgDetections;
Expand Down
52 changes: 26 additions & 26 deletions include/depthai-shared/datatype/RawImgFrame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,24 @@ namespace dai {
/// RawImgFrame structure
struct RawImgFrame : public RawBuffer {
enum class Type {
YUV422i, // interleaved 8 bit
YUV444p, // planar 4:4:4 format
YUV420p, // planar 4:2:0 format
YUV422p, // planar 8 bit
YUV400p, // 8-bit greyscale
RGBA8888, // RGBA interleaved stored in 32 bit word
RGB161616, // Planar 16 bit RGB data
RGB888p, // Planar 8 bit RGB data
BGR888p, // Planar 8 bit BGR data
RGB888i, // Interleaved 8 bit RGB data
BGR888i, // Interleaved 8 bit BGR data
RGBF16F16F16p, // Planar FP16 RGB data
BGRF16F16F16p, // Planar FP16 BGR data
RGBF16F16F16i, // Interleaved FP16 RGB data
BGRF16F16F16i, // Interleaved FP16 BGR data
GRAY8, // 8 bit grayscale (1 plane)
GRAYF16, // FP16 grayscale (normalized)
LUT2, // 1 bit per pixel, Lookup table
LUT4, // 2 bits per pixel, Lookup table
LUT16, // 4 bits per pixel, Lookup table
RAW16, // save any raw type (8, 10, 12bit) on 16 bits
RAW14, // 14bit value in 16bit storage
RAW12, // 12bit value in 16bit storage
RAW10, // 10bit value in 16bit storage
YUV422i, // interleaved 8 bit
YUV444p, // planar 4:4:4 format
YUV420p, // planar 4:2:0 format
YUV422p, // planar 8 bit
YUV400p, // 8-bit greyscale
RGBA8888, // RGBA interleaved stored in 32 bit word
RGB161616, // Planar 16 bit RGB data
RGB888p, // Planar 8 bit RGB data
BGR888p, // Planar 8 bit BGR data
RGB888i, // Interleaved 8 bit RGB data
BGR888i, // Interleaved 8 bit BGR data
LUT2, // 1 bit per pixel, Lookup table (used for graphics layers)
LUT4, // 2 bits per pixel, Lookup table (used for graphics layers)
LUT16, // 4 bits per pixel, Lookup table (used for graphics layers)
RAW16, // save any raw type (8, 10, 12bit) on 16 bits
RAW14, // 14bit value in 16bit storage
RAW12, // 12bit value in 16bit storage
RAW10, // 10bit value in 16bit storage
RAW8,
PACK10, // 10bit packed format
PACK12, // 12bit packed format
Expand All @@ -39,6 +33,12 @@ struct RawImgFrame : public RawBuffer {
NV21,
BITSTREAM, // used for video encoder bitstream
HDR,
RGBF16F16F16p, // Planar FP16 RGB data
BGRF16F16F16p, // Planar FP16 BGR data
RGBF16F16F16i, // Interleaved FP16 RGB data
BGRF16F16F16i, // Interleaved FP16 BGR data
GRAY8, // 8 bit grayscale (1 plane)
GRAYF16, // FP16 grayscale (normalized)
NONE
};
struct Specs {
Expand All @@ -60,7 +60,7 @@ struct RawImgFrame : public RawBuffer {
int sequenceNum; // increments for each frame
Timestamp ts; // generation timestamp

virtual void serialize(std::vector<std::uint8_t>& metadata, DatatypeEnum& datatype) {
void serialize(std::vector<std::uint8_t>& metadata, DatatypeEnum& datatype) const override {
nlohmann::json j = *this;
metadata = nlohmann::json::to_msgpack(j);
datatype = DatatypeEnum::ImgFrame;
Expand All @@ -69,4 +69,4 @@ struct RawImgFrame : public RawBuffer {
NLOHMANN_DEFINE_TYPE_INTRUSIVE(RawImgFrame, fb, category, instanceNum, sequenceNum, ts);
};

} // namespace dai
} // namespace dai
2 changes: 1 addition & 1 deletion include/depthai-shared/datatype/RawNNData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct RawNNData : public RawBuffer {
std::vector<TensorInfo> tensors;
unsigned int batchSize;

void serialize(std::vector<std::uint8_t>& metadata, DatatypeEnum& datatype) override {
void serialize(std::vector<std::uint8_t>& metadata, DatatypeEnum& datatype) const override {
nlohmann::json j = *this;
metadata = nlohmann::json::to_msgpack(j);
datatype = DatatypeEnum::NNData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct SpatialImgDetection : ImgDetection {
struct RawSpatialImgDetections : public RawBuffer {
std::vector<SpatialImgDetection> detections;

void serialize(std::vector<std::uint8_t>& metadata, DatatypeEnum& datatype) override {
void serialize(std::vector<std::uint8_t>& metadata, DatatypeEnum& datatype) const override {
nlohmann::json j = *this;
metadata = nlohmann::json::to_msgpack(j);
datatype = DatatypeEnum::SpatialImgDetections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(SpatialLocationCalculatorConfigData, roi, dep
struct RawSpatialLocationCalculatorConfig : public RawBuffer {
std::vector<SpatialLocationCalculatorConfigData> config;

void serialize(std::vector<std::uint8_t>& metadata, DatatypeEnum& datatype) override {
void serialize(std::vector<std::uint8_t>& metadata, DatatypeEnum& datatype) const override {
nlohmann::json j = *this;
metadata = nlohmann::json::to_msgpack(j);
datatype = DatatypeEnum::SpatialLocationCalculatorConfig;
Expand All @@ -42,4 +42,4 @@ struct RawSpatialLocationCalculatorConfig : public RawBuffer {
NLOHMANN_DEFINE_TYPE_INTRUSIVE(RawSpatialLocationCalculatorConfig, config);
};

} // namespace dai
} // namespace dai
4 changes: 2 additions & 2 deletions include/depthai-shared/datatype/RawSpatialLocations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(SpatialLocations, config, depthAverage, depth
struct RawSpatialLocations : public RawBuffer {
std::vector<SpatialLocations> spatialLocations;

void serialize(std::vector<std::uint8_t>& metadata, DatatypeEnum& datatype) override {
void serialize(std::vector<std::uint8_t>& metadata, DatatypeEnum& datatype) const override {
nlohmann::json j = *this;
metadata = nlohmann::json::to_msgpack(j);
datatype = DatatypeEnum::SpatialLocationCalculatorData;
Expand All @@ -59,4 +59,4 @@ struct RawSpatialLocations : public RawBuffer {
NLOHMANN_DEFINE_TYPE_INTRUSIVE(RawSpatialLocations, spatialLocations);
};

} // namespace dai
} // namespace dai
58 changes: 58 additions & 0 deletions include/depthai-shared/datatype/RawStereoDepthConfig.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#pragma once
#include <cstdint>
#include <nlohmann/json.hpp>
#include <vector>

#include "DatatypeEnum.hpp"
#include "RawBuffer.hpp"

namespace dai {

/**
* Median filter config for disparity post-processing
*/
enum class MedianFilter : int32_t { MEDIAN_OFF = 0, KERNEL_3x3 = 3, KERNEL_5x5 = 5, KERNEL_7x7 = 7 };

/// StereoDepth configuration data structure
struct StereoDepthConfigData {
using MedianFilter = dai::MedianFilter;

/**
* Set kernel size for disparity/depth median filtering, or disable
*/
MedianFilter median = MedianFilter::KERNEL_5x5;

/**
* Confidence threshold for disparity calculation, 0..255
*/
std::int32_t confidenceThreshold = 230;

/**
* Sigma value for bilateral filter. 0 means disabled
* A larger value of the parameter means that farther colors within the pixel neighborhood will be mixed together.
*/
std::int16_t bilateralSigmaValue = 0;

/**
* Left-right check threshold for left-right, right-left disparity map combine, 0..128
* Used only when left-right check mode is enabled.
* Defines the maximum difference between the confidence of pixels from left-right and right-left confidence maps
*/
std::int32_t leftRightCheckThreshold = 4;
};
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(StereoDepthConfigData, median, confidenceThreshold, bilateralSigmaValue, leftRightCheckThreshold);

/// RawStereoDepthConfig configuration structure
struct RawStereoDepthConfig : public RawBuffer {
StereoDepthConfigData config;

void serialize(std::vector<std::uint8_t>& metadata, DatatypeEnum& datatype) const override {
nlohmann::json j = *this;
metadata = nlohmann::json::to_msgpack(j);
datatype = DatatypeEnum::StereoDepthConfig;
};

NLOHMANN_DEFINE_TYPE_INTRUSIVE(RawStereoDepthConfig, config);
};

} // namespace dai
4 changes: 2 additions & 2 deletions include/depthai-shared/datatype/RawSystemInformation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct RawSystemInformation : public RawBuffer {
/// Chip temperatures
ChipTemperature chipTemperature;

void serialize(std::vector<std::uint8_t>& metadata, DatatypeEnum& datatype) override {
void serialize(std::vector<std::uint8_t>& metadata, DatatypeEnum& datatype) const override {
nlohmann::json j = *this;
metadata = nlohmann::json::to_msgpack(j);
datatype = DatatypeEnum::SystemInformation;
Expand All @@ -41,4 +41,4 @@ struct RawSystemInformation : public RawBuffer {
RawSystemInformation, ddrMemoryUsage, cmxMemoryUsage, leonCssMemoryUsage, leonMssMemoryUsage, leonCssCpuUsage, leonMssCpuUsage, chipTemperature);
};

} // namespace dai
} // namespace dai
2 changes: 1 addition & 1 deletion include/depthai-shared/datatype/RawTracklets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct Tracklet {
struct RawTracklets : public RawBuffer {
std::vector<Tracklet> tracklets;

void serialize(std::vector<std::uint8_t>& metadata, DatatypeEnum& datatype) override {
void serialize(std::vector<std::uint8_t>& metadata, DatatypeEnum& datatype) const override {
nlohmann::json j = *this;
metadata = nlohmann::json::to_msgpack(j);
datatype = DatatypeEnum::Tracklets;
Expand Down
31 changes: 31 additions & 0 deletions include/depthai-shared/properties/EdgeDetectorProperties.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#pragma once

#include <depthai-shared/common/optional.hpp>
#include <depthai-shared/datatype/RawEdgeDetectorConfig.hpp>
#include <nlohmann/json.hpp>
#include <vector>

namespace dai {

/**
* Specify properties for EdgeDetector
*/
struct EdgeDetectorProperties {
/// Initial edge detector config
RawEdgeDetectorConfig initialConfig;

/// Whether to wait for config at 'inputConfig' IO
bool inputConfigSync = false;

/**
* Maximum output frame size in bytes (eg: 300x300 BGR image -> 300*300*3 bytes)
*/
int outputFrameSize = 1 * 1024 * 1024;

/// Num frames in output pool
int numFramesPool = 4;
};

NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(EdgeDetectorProperties, initialConfig, inputConfigSync, outputFrameSize, numFramesPool);

} // namespace dai
Loading

0 comments on commit 9b5d920

Please sign in to comment.