I have a 57X1 double matrix in Matlab and I want to find a way to save that data and then load it to a new OpenCV Mat. For actual images I used to do imwrite
in Matlab and then imread
in OpenCV but, in this current situation, the result was a Mat with all of the values equal to 255.
CodePudding user response:
The simplest way is to just use csvwrite to write as a text file, and then load it in C by reading the numbers from the text file.
If you must have binary exact values, you can use the fopen, fwrite, fclose to write the values in binary format, and then use the equivalent functions (i.e. fread or ifstream::read) to read the binary data directly to the Mat buffer.