简体   繁体   English

DLIB C ++如何制作dlib :: matrix的std :: vector

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

I need a std::vector of dlib::matrix , but I don't know at compile time the matrix size; 我需要dlib::matrixstd::vector ,但是在编译时我不知道矩阵的大小。 documentation tells me: 文档告诉我:

// (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;

ok, but I need a std::vector of this objects, so what template argument I have to set on my std::vector ? 好的,但是我需要这个对象的std::vector ,所以我必须在std::vector上设置什么模板参数? example ( get_dimensionality() gives me the right dimensionanlity): 示例( get_dimensionality()给我正确的Dimensionanlity):

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

what number at ???????? ???????? ?

You have the answer by your question. 您有自己问题的答案。 Use the vector as 将向量用作

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

so you can set each element size as it runs, the same you do with the matrices themselves. 因此您可以在运行时设置每个元素的大小,就像处理矩阵本身一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM