EmguCV 中 Matrix<TDepth> 和 Mat 的根本区别是什么?
What is the fundamental difference between Matrix<TDepth> and Mat in EmguCV?
- 为什么在 EmguCV 中
Mat
还不够?
- 为什么不能
Matrix<>
从文件本身加载图像?
例如,
Mat img = new Mat(path);
是一个有效的操作。但是,
Matrix<byte> img = new Matrix<byte>(path);
或者,
Matrix<byte> img = Matrix<byte>.FromFile(path);
不是有效操作。
根据 Emgu Wiki 中的信息,这两种类型之间的根本区别在于是否管理底层数据数组。
Mat
是 C++ cv::Mat
class. Generally this class acts as a smart pointer which manages the memory allocated for the data array it owns (although it's able to just observe as well -- a good example of this capability is the ability to return a Mat
header for a Matrix
instance in C#). This means that OpenCV is able to (re)allocate the memory as necesssary. The trade-off is that in such cases it's more difficult 的包装器,用于在 C# 中有效访问底层数据。
Matrix
class 使用托管数组来保存数据。这意味着您可以轻松访问 C# 中的底层数据数组。
老实说,告诉您为什么无法从图像文件加载 Matrix
的最佳人选是作者。我的猜测是它旨在代表图像以外的其他事物。从技术上讲,这可以以与加载图像文件的能力相同的方式添加到 Mat
包装器(C++ 等价物没有这样的功能)。
- 为什么在 EmguCV 中
Mat
还不够? - 为什么不能
Matrix<>
从文件本身加载图像?
例如,
Mat img = new Mat(path);
是一个有效的操作。但是,
Matrix<byte> img = new Matrix<byte>(path);
或者,
Matrix<byte> img = Matrix<byte>.FromFile(path);
不是有效操作。
根据 Emgu Wiki 中的信息,这两种类型之间的根本区别在于是否管理底层数据数组。
Mat
是 C++ cv::Mat
class. Generally this class acts as a smart pointer which manages the memory allocated for the data array it owns (although it's able to just observe as well -- a good example of this capability is the ability to return a Mat
header for a Matrix
instance in C#). This means that OpenCV is able to (re)allocate the memory as necesssary. The trade-off is that in such cases it's more difficult 的包装器,用于在 C# 中有效访问底层数据。
Matrix
class 使用托管数组来保存数据。这意味着您可以轻松访问 C# 中的底层数据数组。
老实说,告诉您为什么无法从图像文件加载 Matrix
的最佳人选是作者。我的猜测是它旨在代表图像以外的其他事物。从技术上讲,这可以以与加载图像文件的能力相同的方式添加到 Mat
包装器(C++ 等价物没有这样的功能)。