I currently have some .bin files, each of which contains a matrix of size AxBxC. I would like to load it into a 3d vector vector<vector<vector<float>>> in C++, but encountered some problems.
I tried to flatten the matrix and load it into a buffer first, but the size of the buffer was weird so I got stuck there.
My code was:
vector<vector<vector<float>>> load_3d_bin(const std::string& path){
vector<vector<vector<float>>> r;
std::ifstream binary_feat(path.c_str(),std::ios::in | std::ios::binary);
std::vector<float> flattened_feat((std::istream_iterator<char>(binary_feat)),std::istream_iterator<char>());
for(auto i: flattened_feat){
int value = i;
}
std::cout<<flattened_feat.size()<<endl;
// code to be written
return r;
}
Ideally r would be a 3d vector, but I am stuck at the iterator part as the .size() outputs differently from total length = AxBxC, which was what I expected...
Any solution or feedback? Thanks in advance!