DLIB C++如何制作DLIB::矩阵的std::向量

DLIB C++ how to make an std::vector of dlib::matrix

本文关键字:DLIB std 向量 何制作 C++      更新时间:2023-10-16

我需要dlib::matrixstd::vector,但在编译时我不知道矩阵大小;文档告诉我:

// (Note that if you don't know the dimensionality of your vectors at compile time
// you can change the 2 to a 0 and then set the size at runtime)
typedef matrix<double,2,1> sample_type;

好的,但我需要这个对象的std::vector,那么我必须在std::vector上设置什么模板参数?示例(get_dimensionality()给了我正确的维度(:

matrix<double,0,1>  m;
m.set_size(get_dimensionality(),1);
std::vector<matrix<double,????????,1> v;
v.push_back(m);

????????的号码是多少?

您的问题已经得到了答案。将矢量用作

std::vector<matrix<double, 0, 1> v;

因此,您可以在运行时设置每个元素的大小,就像处理矩阵本身一样。