微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

c – 用户定义类型的OpenCV Matrix

有没有办法在OpenCV 2.x中有一个用户定义类型的矩阵?就像是 :
cv::Mat_<KalmanRGBPixel> backgroundModel;

我知道cv :: Mat<>是用于图像和数学,但我想以矩阵形式保存数据.我不打算使用逆,转置,乘法等,它只用于存储数据.我希望它是矩阵形式,因为视频的每个帧的pixel_ij将链接到backgroundModel_ij.

我知道有一个DataType< _Tp> core.hpp中的类需要为我的类型定义,但我不知道该怎么做.

编辑:KalmanRGBPixel只是cv :: KalmanFilter类的包装器.至于现在,它是唯一的成员.

... some functions ...
private:
    cv::KalmanFilter kalman;

谢谢你的帮助.

解决方法

在OpenCV文档中,解释了如何向OpenCV矩阵添加自定义类型.您需要定义相应的cv :: DataType.

https://docs.opencv.org/master/d0/d3a/classcv_1_1DataType.html

The DataType class is basically used to provide a description of such primitive data types without adding any fields or methods to the corresponding classes (and it is actually impossible to add anything to primitive C/C++ data types). This technique is kNown in C++ as class traits. It is not DataType itself that is used but its specialized versions […] The main purpose of this class is to convert compilation-time type information to an OpenCV-compatible data type identifier […]

(是的,最后我在这个帖子中回答了问题!)

原文地址:https://www.jb51.cc/c/118875.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐