std::vector<cv::Point3f> data;
//loop invoking
//cv::Point3f p; p.x=..; p.y=..; p.z=.. and data.push_back(p)
std::ofstream myFile("data.bin", ios::out || ios::binary);
myFile.write(reinterpret_cast<char*> (&data[0]), sizeof(cv::Point3f)*data.size());
myFile.close();
int size = data.size();
ifstream input("data.bin", ios::binary);
input.read(reinterpret_cast<char*> (&data[0]), sizeof(cv::Point3f)*size);
This always terminates with "debug assertion failed": "vector subscript out of range".
Is this not possible then? My priority here is speed. I want to read and write as fast as possible. (so binary files are needed).
len = readLengthOfVector(); data.resize(len); readData(data,len);This pseudocode shows you how it usually looks like.