# ImgDetections

[DetectionNetwork](https://docs.luxonis.com/software-v3/depthai/depthai-components/nodes/detection_network.md) outputs this
message. This message contains a list of detections, which contains label, confidence, and the bounding box information (xmin,
ymin, xmax, ymax).

## Examples of functionality

 * [RGB & Yolo](https://docs.luxonis.com/software-v3/depthai/examples/detection_network/detection_network.md)

## Reference

### dai::ImgDetections

Kind: class

ImgDetections message. Carries normalized detections and optional segmentation mask. The segmentation mask is stored as a
single-channel INT8 2-d array, where the value represents the instance index in the list of detections. The value 255 is treated
as a background pixel (no instance).

#### ImgDetectionsT < dai::ImgDetection > Base

Kind: enum

#### std::vector< DetectionT > detections

Kind: variable

#### size_t segmentationMaskHeight

Kind: variable

#### size_t segmentationMaskWidth

Kind: variable

#### std::optional< ImgTransformation > transformation

Kind: variable

#### ~ImgDetections()

Kind: function

#### void serialize(std::vector< std::uint8_t > & metadata, DatatypeEnum & datatype)

Kind: function

#### DatatypeEnum getDatatype()

Kind: function

Get the datatype of this specific message.

return: DatatypeEnum

#### DEPTHAI_SERIALIZE(ImgDetections, Base::Buffer::sequenceNum, Base::Buffer::ts, Base::Buffer::tsDevice, detections,
transformation, segmentationMaskWidth, segmentationMaskHeight)

Kind: function

### dai::ImgDetectionsT

Kind: class

#### std::vector< DetectionT > detections

Kind: variable

#### std::optional< ImgTransformation > transformation

Kind: variable

#### ImgDetectionsT()

Kind: function

#### ~ImgDetectionsT()

Kind: function

#### std::size_t getSegmentationMaskWidth()

Kind: function

Returns the width of the segmentation mask.

#### std::size_t getSegmentationMaskHeight()

Kind: function

Returns the height of the segmentation mask.

#### void setSegmentationMask(const std::vector< std::uint8_t > & mask, size_t width, size_t height)

Kind: function

Sets the segmentation mask from a vector of bytes. The size of the vector must be equal to width * height.

#### void setSegmentationMask(dai::ImgFrame & frame)

Kind: function

Sets the segmentation mask from an ImgFrame . parameters: frame: Frame must be of type GRAY8

#### std::optional< std::vector< std::uint8_t > > getMaskData()

Kind: function

Returns a copy of the segmentation mask data as a vector of bytes. If mask data is not set, returns std::nullopt.

#### std::optional< dai::ImgFrame > getSegmentationMask()

Kind: function

Returns the segmentation mask as an ImgFrame . If mask data is not set, returns std::nullopt.

#### void setCvSegmentationMask(cv::Mat mask)

Kind: function

note: 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 note: Throws if mask is not a single channel INT8 type.

#### std::optional< cv::Mat > getCvSegmentationMask(cv::MatAllocator * allocator)

Kind: function

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.

#### std::optional< cv::Mat > getCvSegmentationMaskByIndex(uint8_t index, cv::MatAllocator * allocator)

Kind: function

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.

#### std::optional< cv::Mat > getCvSegmentationMaskByClass(uint8_t semanticClass, cv::MatAllocator * allocator)

Kind: function

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](https://discuss.luxonis.com/) for technical support or any other questions you might have.
