Because some algorithms of MATLAB are used in image processing, some array data (depth data of three-dimensional reconstruction) is obtained.
Using OpenGL drawing in VC requires the use of this data (depth data) for display purposes.
Use the statement under MATLAB: Csvwrite (' Depthmap ', depthmap); //Depthmap is an array variable, and the preceding depthmap is the CSV file name.
The function readcsv is to read a CSV file (a two-dimensional array) to the specified variable Depthmap.
The definition of a variable:
Double depthmap[240][320] = {0}; //depth map
Call Function:
Read CSV file: Depth map depthmap.csv
Readcsv (DEPTHMAP); //Call function to read data from a CSV file
void Readcsv (double depthmap[][320]) {file* fd;errno_t err = fopen_s (&FD, "Depthmap", "R"), if (err) printf_s ("The FILE Depthmap.csv is not opened\n "); else{//Set Pointer to beginning of File://fseek (FD, 0L, seek_set); int i = 0;while (i <) {Int J = 0;double A = 0;while (J < 319) {fscanf (FD, "%lf,", &a);d epthmap[i][j] = a;++ J;} FSCANF (FD, "%lf\n", &a);d epthmap[i][j] = a;++ i;}} Fclose (FD);}
The array in MATLAB is saved as a CSV file and used in VC