Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can use the following opencv c++ code for windows to get videostream from your IP WEBCAM app on android phone.

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, char* argv[])
    VideoCapture cap; //"");
    if (!cap.isOpened())  // if not success, exit program
        cout << "Cannot open the video cam" << endl;
        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 << "Frame size : " << dWidth << " x " << dHeight << endl;

    namedWindow("MyVideo",CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"

    while (1)
        Mat frame;
        Mat contours;

        bool bSuccess =; // read a new frame from video

         if (!bSuccess) //if not success, break loop
             cout << "Cannot read a frame from video stream" << endl;

        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 << "esc key is pressed by user" << endl;
    return 0;

Here, replace the ip address ( in"");

with your ip address !! But make sure you have, ?x.mjpeg ,in the end (where x can be any string).

If this doesn't work then you should find out what your full ip address is? i.e. find out what is the string after the ip (In my case it was "/video" as shown in above address)