Ask Your Question

how to using OpenCv API get web video stream!

asked 2013-11-20 01:30:53 -0500

风飞向何处 gravatar image

Is there have a API we can use to get video stream from web. For example from

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted

answered 2013-11-20 01:54:50 -0500

Haris gravatar image

updated 2014-04-25 03:33:19 -0500

You can use OpenCV VideoCapture class to open video streaming from web


VideoCapture cap;;

And see some links with this thread.

edit flag offensive delete link more


thinks for your replay! my compiler is vs2010 , I used your method! but I can't succeed. whether should i do some setting?

风飞向何处 gravatar image风飞向何处 ( 2013-12-18 03:33:21 -0500 )edit

thanks! I'm using your cord:""); the URL can open in browser,but can not open in vs2010 use you code; whether should I do some setting with my vs2010 ? or the version problem of my opencv . my opencv version is 2.3.0

风飞向何处 gravatar image风飞向何处 ( 2013-12-23 22:07:48 -0500 )edit

Are you able to capture using webcam ?

Haris gravatar imageHaris ( 2013-12-23 23:15:41 -0500 )edit

Mat grains(480,640,CV_8UC3,Scalar::all(0)); const string videoStreamAddress1 = ""; //From mjpeg streamer const string videoStreamAddress2 = ""; //From mjpeg streamer

if(! { cout << "Error opening video stream1" <<endl; }
after execute this cord the screen print Error opening video stream1 , if i'm using browser I can capture webcam. but can't capture using vs2010

风飞向何处 gravatar image风飞向何处 ( 2013-12-23 23:45:02 -0500 )edit

The above code works fine for me on Windows7 vs2010 environment. Make sure that you are able to open video file from your PC. If no there are some issue with ffmpeg. See this link

Haris gravatar imageHaris ( 2013-12-24 02:01:06 -0500 )edit

thank you very mach! I have get webcam .I'm using ubuntu os . the ffmpeg is a encoding lib . it is using for linux not windows , so I think there is some error with my vs 2010 not ffmpeg

风飞向何处 gravatar image风飞向何处 ( 2013-12-24 03:24:35 -0500 )edit

Then just try with command line, so that you can assure is it the problem of vs2010. And this link might be helpful.

Haris gravatar imageHaris ( 2013-12-24 04:09:51 -0500 )edit

answered 2014-04-24 20:52:11 -0500

Talamantez gravatar image

updated 2014-04-24 21:51:44 -0500

Hello. I am able to get the above code to work. I would like to get a different type of stream to pipe in to opencv. I have an html5 canvas on a webpage served at that I am loading a stream into with the following code:

    <div id="droneStream" style="width: 640px; height: 360px"></div>

     new NodecopterStream(document.getElementById("droneStream"));
     var myImage = canvas.toDataURL("image/png");

I want to pipe that stream from the page into opencv in the way that you have accomplished above. Do you know how to structure the url to grab the image stream? Right now I have a URL that I know is wrong, but here is my opencv code:"");

Thanks for your help.

edit flag offensive delete link more



hi Talamantez.

since this is not an answer, but another question, - would you be so nice to remove this, and start your own question ? (else it gets totally confusing)

reading theFAQ will be helpful, too.

berak gravatar imageberak ( 2014-04-24 23:51:00 -0500 )edit

Like @berak suggested ... please do not open cold turkey topics :)

StevenPuttemans gravatar imageStevenPuttemans ( 2014-04-25 03:34:45 -0500 )edit

Question Tools

1 follower


Asked: 2013-11-20 01:30:53 -0500

Seen: 57,728 times

Last updated: Apr 25 '14