title: OpenCV Creating Video From Text File
body: <p>I am trying to build an application, which get data from webcam or external device, saves Video Frames into text file, then read frames from created text file.</p>
  
  <p>I don't know whether it is a good idea to save to text file, I'm open suggestions.</p>
  
  <p>So far I've done to saving to a text file.</p>
  
  <p>My problem is reading from text file. Basically I read text line by line, but I don't know how to convert this text into Mat object.</p>
  
  <p>So far my code is:</p>
  
  <pre><code>ifstream read_storage(new_vid_frm_path);
  if(!read_storage.is_open()) {
      perror("\n\n\n\t\t\t(-)FAIL : Can't Open SavedVideoFrames.txt\n\n\n\t\t\t");
      return -1;
  }
  
  VideoWriter *vid = new VideoWriter(new_vid_frm_path,CV_FOURCC('P', 'I', 'M', '1'),30,Size(vc.get(CV_CAP_PROP_FRAME_WIDTH),vc.get(CV_CAP_PROP_FRAME_HEIGHT)));
  Mat line;
  vector&lt;Mat&gt; vid_frms;
  while ( getline (read_storage,line) ) {
      cout &lt;&lt; line &lt;&lt; '\n';
  
  }
  
  read_storage.close();
  
  if(vid_frms.size() == 0){
      printf("\n\n\n\t\t\t(-)FAIL: Error In Frame\n\n\n\t\t\t");
      return -1;
  }
  
  for(size_t i = 0; i&lt;vid_frms.size(); i++)
      (*vid).write(vid_frms[i]);
  
  printf("\n\n\n\t\t\t(+)SUCCESS: Video Processing Complete \n\n\n\t\t\t ");
  </code></pre>
  
  <p>Do you have ay suggestions how can I cast or convert this line string to Mat obejct?</p>
  
  <pre><code>while ( getline (read_storage,line) ) {
      cout &lt;&lt; line &lt;&lt; '\n';
  
  }
  </code></pre>
  
  <p>Thanks.</p>
  
  <p>By the way, I looked at this solution, but I couldn't understand.
  <a href="https://stackoverflow.com/questions/13705578/convert-a-string-of-bytes-to-cvmat">Convert a string of bytes to cv::mat</a></p>
  
  <p>I couldn't find the byte type in c++ and I think there might be a direct conversion between String to Mat object.</p>