title: Read h264 stream from an IP camera
body: <p>Currently, I am trying to use opencv to read a video from my Canon VB-H710F camera.</p>
  
  <p>For this purpose I tried two different solutions:</p>
  
  <p>SOLUTION 1:  Read the stream from rtsp address</p>
  
  <pre><code> VideoCapture cam ("rtsp://root:camera@10.0.4.127/stream/profile1=u");
  
   while(true)
    cam &gt;&gt; frame;
  </code></pre>
  
  <p>In this case I am using opencv to directly read from a stream encoded with in H264 (profile1), however this yields the same problem reported here <a href="http://answers.opencv.org/question/34012/ip-camera-h264-error-while-decoding/" rel="noreferrer">http://answers.opencv.org/question/34012/ip-camera-h264-error-while-decoding/</a>
  As suggested in the previous question, I tried to disable FFMPEG support in opencv installation, which solved the h264 decoding errors but raised other problem.
  When accessing the stream with opencv, supported by gstreame, there is always a large delay associated.
  With this solution I achieve 15 FPS but I have a delay of 5 seconds, which is not acceptable considering that I need a real time application.</p>
  
  <p>SOLUTION 2:  Read the frames from http address
  while(true)
      {
              startTime=System.currentTimeMillis();</p>
  
  <pre><code>        URL url = new URL("h t t p://[IP]/-wvhttp-01-/image.cgi");
          URLConnection con = url.openConnection();
          BufferedImage image = ImageIO.read(con.getInputStream());   
          showImage(image);
          estimatedTime=System.currentTimeMillis()-startTime;
          System.out.println(estimatedTime);
          Thread.sleep(5);
  }
  </code></pre>
  
  <p>This strategy simply grabs the frame from the url that the camera provides. The code is in Java but the results are the same in C++ with the curl library.
  This solution avoids the delay of the first solution however it takes little more than 100 ms to grab each frame, which means that I can only achieve on average 10 FPS.</p>
  
  <p>I would like to know how can I read the video using c++ or another library developed in c++ ?</p>