The array in MATLAB is saved as a CSV file and used in VC

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.