title: IP camera acessing using rtsp, visual studio OpenCv 2.4.5?
body: <p>This is the code used to access my IP camera using lan port. (first code works fine). What I need is to get image with Mat(C++) structure. Code number 2 shows what I have done to using Mat structure but when I debug the program, execute cv::namedWindow("Frame"); and then breaks the code giving out an Unhandled exception which shows bellow.
  My Final requirement is to get this job done using Mat instead of iplimage. tip or an appropriate code would be great since I am doing a project on Human detection using HOG. thanks.</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;stdio.h&gt;
  #include &lt;opencv2/opencv.hpp&gt;
  #include &lt;iostream&gt;
  #include &lt;stdio.h&gt;
  #include "opencv.hpp"
  
  int main(){
  
  CvCapture *camera=cvCaptureFromFile("rtsp://192.168.1.19:554/0/1:1/main");
  if (camera==NULL)
  printf("camera is null\n");
  else
  printf("camera is not null");
  
  cvNamedWindow("img");
  while (cvWaitKey(10)!=atoi("q")){
  
  IplImage *img=cvQueryFrame(camera);
  cvShowImage("img",img);
  }
  cvReleaseCapture(&amp;camera);
  }
  </code></pre>
  
  <p>code number 2 : </p>
  
  <pre><code>int main(int argc, char* argv[])
  {
          cv::Ptr&lt;CvCapture&gt; capture = cvCaptureFromFile("rtsp://192.168.1.19:554/0/1:1/main");
          cv::namedWindow("Frame");
          for (;;)
          {
              cv::Mat frame = cvQueryFrame(capture);
              cv::imshow("Frame", frame);
              if (cv::waitKey(1) &gt;= 0)
              break;
          }
      return 0;
  }
  </code></pre>
  
  <p>Exception :
  Unhandled exception at 0x00660598 in Hog with Web cam.exe: 0xC0000005: Access violation reading location 0xcccc0065. </p>