ios - convert big yml data -
there other way/trick store depth map in database? basically, trying store 300000 double values. if helps can convert array nsmutablearray or similar can serialize it. don’t know yet how it. tried find way convert binary file instead of ascii no luck yet.
you can save lot of memory storing raw binary data in blob.
if don't have fixed rows , cols of matrix, can put @ beginning of file 2 integers rows , cols.
i'll add simple example on how save , load data of matrix, preceded rows , cols.
#include <opencv2/opencv.hpp> #include <fstream> using namespace cv; using namespace std; int main() { mat1d m = (mat1d(3, 3) << 1, 2, 3, 4, 5, 6, 7, 8, 9); mat1d n; { ofstream ofs("test.bin", fstream::binary); ofs.write((char*)&m.rows, sizeof(int)); // save rows ofs.write((char*)&m.cols, sizeof(int)); // save cols ofs.write((char*)m.data, m.total()*sizeof(double)); // save data } { ifstream ifs("test.bin", fstream::binary); int rows, cols; ifs.read((char*)&rows, sizeof(int)); // load rows ifs.read((char*)&cols, sizeof(int)); // load cols n = mat1d(rows, cols); // resize matrix according rows, cols ifs.read((char*)n.data, rows*cols*sizeof(double)); // load data } // m , n equal return 0; }
if need further compression can read , write stream using gzstream
Comments
Post a Comment