title: Convert blob images to Mat images
body: <p>I am using mysql database for my face recognition project.Here I store images into the table and the images are stored as blob images.when  select these images back, i need to write these blob images to separate image files using a file pointer and it will be stored into a folder in which the program resides.And for using those images, i need to read it again from that folder.Then only i can use that images to another function. But i need to use those blob images directly from the database(when we select it from the DB, i need to pass it to another function). So that i can reduce operations like reading it again from the folder.How can i convert bl .So for passing DB images directly to another function, i think we need to convert it's type or something.</p>
  
  <pre><code>void SelectImage()
  {
  MYSQL *conn;
  MYSQL_RES *result;
  MYSQL_ROW row;
  char temp[900];
  char filename[50];
  unsigned long *lengths;
  FILE *fp;
  my_ulonglong    numRows;
  unsigned int    numFields;
  int mysqlStatus = 0;
  MYSQL_RES *mysqlResult = NULL;
  conn = mysql_init(NULL);
  mysql_real_connect(conn, "localhost", "root", "athira@iot", "Athira", 0, NULL, 0);
  int state=mysql_query(conn, "SELECT * FROM ima1");
  mysqlResult=mysql_store_result(conn);
  if(mysqlResult)
  {
      numRows=mysql_num_rows(mysqlResult);
  
  }
  cout&lt;&lt;"rows:"&lt;&lt;numRows&lt;&lt;endl;   
  for(int i=1;i&lt;=numRows;i++){
      sprintf(temp,"SELECT data FROM ima1 WHERE id=%d",i);
      sprintf(filename,"Gen_Image%d.jpeg",i);
      fp = fopen(filename, "wb");// open a file for writing. 
      cout&lt;&lt;temp&lt;&lt;" to "&lt;&lt;filename&lt;&lt;endl;
      mysql_query(conn, temp);//select an image with id
      result = mysql_store_result(conn);
      row = mysql_fetch_row(result);//row contains row data
      lengths = mysql_fetch_lengths(result);//this is the length of th image
      fwrite(row[0], lengths[0], 1, fp);//writing image to a file
      cout&lt;&lt;"selected..."&lt;&lt;endl;
      img.create(100,100,CV_16UC1);
      memcpy(img.data,row.data,lengths);
      mysql_free_result(result);
      fclose(fp);
  }
  
    mysql_close(conn);
    }
  
  I tried to convert it to Mat type but it's showing error..  
  error is this,
   error: request for member ‘data’ in ‘row’, which is of non-class type ‘MYSQL_ROW {aka char**}’
  </code></pre>