title: Access mjpeg-streamer in OpenCV 3.0
body: <p>I have a raspberry pi b+ uploading a video stream with the mjpeg-streamer.</p>
  
  <p>On the Raspberry Pi</p>
  
  <pre><code>/usr/local/bin/mjpg_streamer -i "/usr/local/lib/input_uvc.so -y -r 340x240 -f 10 -d /dev/video0" -o "/usr/local/lib/output_http.so -w /usr/local/www"
  </code></pre>
  
  <p>This creates a video stream accessible by </p>
  
  <pre><code>http://10.1.111.150:8080/?action=stream
  </code></pre>
  
  <p>making a jpeg image ->
  <a href="http://i.stack.imgur.com/Z3edf.jpg" rel="nofollow">Live stream on the firefox browser</a></p>
  
  <p>Now, what I would like to do is open this stream with OpenCV 3.0.0 in Visual Studio 2013.</p>
  
  <pre><code>#include &lt;opencv2/core/core.hpp&gt;
  #include &lt;opencv2/highgui/highgui.hpp&gt;
  #include &lt;opencv2/imgproc/imgproc.hpp&gt;
  #include &lt;iostream&gt;
  
  using namespace cv;
  using namespace std;
  
  int main(int argc, char* argv[])
  {
      int q;
      VideoCapture cap; 
  
  //cap.open(0) for internal camera
  //
  cap.open("http://10.1.111.150:8080/?action=stream");
  
  
  if (!cap.isOpened())  // if not success, exit program
  {
      cout &lt;&lt; "Cannot open the video cam" &lt;&lt; endl &lt;&lt; "Press q to continue:";
      cin &gt;&gt; q;
      return -1;
  }
  
  double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video
  double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of frames of the video
  
  cout &lt;&lt; "Frame size : " &lt;&lt; dWidth &lt;&lt; " x " &lt;&lt; dHeight &lt;&lt; endl;
  
  namedWindow("MyVideo", CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"
  namedWindow("MyNegativeVideo", CV_WINDOW_AUTOSIZE);
  
  while (1)
  {
      Mat frame;
      Mat contours;
  
      bool bSuccess = cap.read(frame); // read a new frame from video
  
      if (!bSuccess) //if not success, break loop
      {
          cout &lt;&lt; "Cannot read a frame from video stream" &lt;&lt; endl;
          break;
      }
  
      flip(frame, frame, 1);
      imshow("MyVideo", frame); //show the frame in "MyVideo" window
  
      Canny(frame, contours, 500, 1000, 5, true);
      imshow("MyNegativeVideo", contours);
  
      if (waitKey(30) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
      {
          cout &lt;&lt; "esc key is pressed by user" &lt;&lt; endl;
          break;
      }
  }
  return 0;}
  </code></pre>
  
  <p>This is an example code that works to open the internal webcam on my laptop when I use<code>cap.open(0)</code>
  But trying to open the ip camera from its address<code>cap.open("http://10.1.111.150:8080/?action=stream");</code> 
  is not working.</p>
  
  <p><strong>UPDATE</strong>
  I've made some changes on the RPi by running</p>
  
  <pre><code>/usr/local/bin/mjpg_streamer -i "/usr/local/lib/input_uvc.so -y -r 340x240 -f 10 -d /dev/video0" -o "/usr/local/lib/output_rtsp.so -p /usr/local/www"
  </code></pre>
  
  <p>the difference being the <code>output_rtsp.so -p</code> </p>
  
  <p>By the looks the webcam (active light is on) and the program running in the raspberry pi's terminal, I can assume the stream is working. I can't confirm this through a browser though.</p>
  
  <p>Running</p>
  
  <pre><code>cap.open("rtsp://10.1.111.150:8080/?action=stream");
  </code></pre>
  
  <p>in the openCV code does not open the stream.</p>
  
  <p>Can anyone tell me where I'm going wrong?</p>