title: How can I save Video with Overlay using Dlib?
body: <p>I am using Dlib 19.2 with VS2015 .I was executing the below program as mentioned in this link '<a href="http://dlib.net/webcam_face_pose_ex.cpp" rel="nofollow noreferrer">http://dlib.net/webcam_face_pose_ex.cpp</a>'</p>
  
  <p>I want to save the video with all landmarks on each frame.How can I do this?
  I am running the below code. </p>
  
  <pre><code>int main(){
  
   try{
  
      cv::VideoCapture cap("out.avi");
  
      int count =cap.get(CV_CAP_PROP_FRAME_COUNT);
      if (!cap.isOpened())
      {
          cout &lt;&lt; "Unable to connect to camera" &lt;&lt; endl;
          return 1;
      }
  
      image_window win;
  
      // Load face detection and pose estimation models.
      frontal_face_detector detector = get_frontal_face_detector();
      shape_predictor pose_model;
      deserialize("shape_predictor_68_face_landmarks.dat") &gt;&gt; pose_model;
  
      // Grab and process frames until the main window is closed by the user.
      while (!win.is_closed())
      {
          // Grab a frame
          cv::Mat temp;
          cap &gt;&gt; temp;
  
          // Turn OpenCV's Mat into something dlib can deal with.  Note that this just
          // wraps the Mat object, it doesn't copy anything.  So cimg is only valid as
          // long as temp is valid.  Also don't do anything to temp that would cause it
          // to reallocate the memory which stores the image as that will make cimg
          // contain dangling pointers.  This basically means you shouldn't modify temp
          // while using cimg.
          cv_image&lt;bgr_pixel&gt; cimg(temp);
  
          // Detect faces 
          std::vector&lt;rectangle&gt; faces = detector(cimg);
          // Find the pose of each face.
          std::vector&lt;full_object_detection&gt; shapes;
          for (unsigned long i = 0; i &lt; faces.size(); ++i)
              shapes.push_back(pose_model(cimg, faces[i]));
  
          // Display it all on the screen
          win.clear_overlay();
          win.set_image(cimg);
          win.add_overlay(render_face_detections(shapes));
          waitKey(20);
      }
  }
  catch (serialization_error&amp; e)
  {
      cout &lt;&lt; "You need dlib's default face landmarking model file to run this example." &lt;&lt; endl;
      cout &lt;&lt; "You can get it from the following URL: " &lt;&lt; endl;
      cout &lt;&lt; "   http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2" &lt;&lt; endl;
      cout &lt;&lt; endl &lt;&lt; e.what() &lt;&lt; endl;
  }
  catch (exception&amp; e)
  {
      cout &lt;&lt; e.what() &lt;&lt; endl;
  }
  
  
  getch();
  </code></pre>
  
  <p>}</p>
  
  <p>So please guide me on this.</p>