ImgDetections
最后更新
detections 列表, 其中包含 label、confidence 和边界框信息(xmin、ymin、xmax、ymax)。保存和加载
ImgDetections 消息可以使用 save() 保存到文件,并使用 load() 读回。保存的文件是二进制 protobuf 封装。有关用法,请参阅 消息 save 和 load 函数。重映射
ImgDetections 是可转换的,这意味着它可以重映射到另一个帧的坐标系中。有关详细信息,请参阅 重映射可转换消息。功能示例
参考
class
dai::ImgDetections
using
Base = ImgDetectionsT< dai::ImgDetection >
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()Get the datatype of this specific message.
Returns
DatatypeEnum
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 Align node to transform the segmentation mask to the target transformation if needed.
Parameters
- target: Target image transformation.
function
DEPTHAI_SERIALIZE(ImgDetections, sequenceNum, ts, tsDevice, tsSystem, detections, transformation, segmentationMaskWidth, segmentationMaskHeight)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)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.
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.
需要帮助?
请访问讨论论坛以获取技术支持或您可能有的任何其他问题。