ImgDetections
ImgDetections
detections, which contains label, confidence, and the bounding box information (xmin, ymin, xmax, ymax).Remapping
ImgDetections is transformable, which means it can be remapped into another frame's coordinate system. See Remapping transformable messages for details.Examples of functionality
Reference
class
dai::ImgDetections
variable
std::vector< DetectionT > detections
variable
size_t segmentationMaskHeight
variable
size_t segmentationMaskWidth
variable
std::optional< ImgTransformation > transformation
function
~ImgDetections()function
void serialize(std::vector< std::uint8_t > & metadata, DatatypeEnum & datatype)inline function
DatatypeEnum getDatatype()function
ImgDetections transformTo(const ImgTransformation & target)Returns a new ImgDetections message with the detections transformed into the target image transformation.If the target transformation has a different source coordinate system (eg. different camera socket) than the one the detections were originally generated in, the remapping will be inaccurate due to the lack of depth information.The segmentation mask is not transformed. Use ImageAlign node to transform the segmentation mask to the target transformation if needed.
Parameters
- target: Target image transformation.
function
DEPTHAI_SERIALIZE(ImgDetections, sequenceNum, ts, tsDevice, detections, transformation, segmentationMaskWidth, segmentationMaskHeight)enum
ImgDetectionsT< dai::ImgDetection > Base
class
dai::ImgDetectionsT
variable
std::vector< DetectionT > detections
function
ImgDetectionsT()function
~ImgDetectionsT()function
std::size_t getSegmentationMaskWidth()Returns the width of the segmentation mask.
function
std::size_t getSegmentationMaskHeight()Returns the height of the segmentation mask.
function
void setSegmentationMask(const std::vector< std::uint8_t > & mask, size_t width, size_t height)Sets the segmentation mask from a vector of bytes. The size of the vector must be equal to width * height.
function
void setSegmentationMask(dai::ImgFrame & frame)function
std::optional< std::vector< std::uint8_t > > getMaskData()Returns a copy of the segmentation mask data as a vector of bytes. If mask data is not set, returns std::nullopt.
function
std::optional< dai::ImgFrame > getSegmentationMask()function
void setCvSegmentationMask(cv::Mat mask)Parameters
This API only available if OpenCV support is enabled Copies cv::Mat data to Segmentation Mask buffer
Parameters
- frame: Input cv::Mat frame from which to copy the data
Parameters
Throws if mask is not a single channel INT8 type.
function
std::optional< cv::Mat > getCvSegmentationMask(cv::MatAllocator * allocator)Retrieves mask data as a cv::Mat copy with specified width and height. If mask data is not set, returns std::nullopt.
Parameters
- allocator: Allows callers to supply a custom cv::MatAllocator for zero-copy/custom memory management; nullptr uses OpenCV’s default.
function
std::optional< cv::Mat > getCvSegmentationMaskByIndex(uint8_t index, cv::MatAllocator * allocator)Returns a binary mask where pixels belonging to the instance index are set to 1, others to 0. If mask data is not set, returns std::nullopt.
Parameters
- index: Instance index
- allocator: Allows callers to supply a custom cv::MatAllocator for zero-copy/custom memory management; nullptr uses OpenCV’s default.
function
std::optional< cv::Mat > getCvSegmentationMaskByClass(uint8_t semanticClass, cv::MatAllocator * allocator)Retrieves data by the semantic class. If no mask data is not set, returns std::nullopt.
Parameters
- semanticClass: Semantic class index
- allocator: Allows callers to supply a custom cv::MatAllocator for zero-copy/custom memory management; nullptr uses OpenCV’s default.
Need assistance?
Head over to Discussion Forum for technical support or any other questions you might have.