I made sure if the question is asked already but haven't came across similar one. Sorry if this is already asked.
I am trying to read a OpenCV mat_ from a binary file. I am successful in doing it with this code.
out = cv::Mat_<float> (1080,1920);
for(int y = 0; y < 1080; ++y)
{
result = fread(out[y], sizeof(float), 1920, file);
if(result != 1920)
throw std::runtime_error("Short/failed fread on binary file");
}
Most examples I found online were using buffers to read data from the file and then filling the Mat with buffer values but I managed to skip the buffers using Mat's row pointers. But here i am reading row by row. I would like to do it one step. I need to know how to pass the Mat pointer (the whole memory it holds) to fread. Any better alternatives are also welcome.