I try to save Mat to binary file:
void WriteRAW(Mat &m)
{
ostringstream filename;
uchar* buffer = m.data;
filename << "e:/1/Frame_" << lNoFrame++ << ".raw";
std::ofstream outfile(filename.str().c_str(), ios::out | ios::binary);
outfile.write((char*)(buffer), m.total() * m.elemSize());
outfile.close();
}
It work fine for CV_8UC(x) Mat, but if I convert Mat to CV_16UC1 (also CV_32FC1 ...) nothing changes. The size of the output file does not change, it remains the same as it was at CV_8UC1. Of course I cant read it as WidthHeightsizeof(type_to_which_I_converted) raw data. convertTo() not enough to change byte per pixel for Mat?