Can we use Opencv to get live video stream over th

2019-05-20 04:04发布

问题:

I tried giving cvCreateCameraCapture an URL of the camera viewing on internet. However, I can't get any video playing.

I am writing in C language.

回答1:

My camera works to a degree with

CvCapture *camera = cvCreateFileCapture("rtsp://username:password@ip:port/ch1-s1");

Notice that I am using rtsp as opposed to http, I do have another camera that uses the http protocol but I'm not using this one at the moment.

So yes it is possible however different cameras use different urls and even then it is not guaranteed to work.



回答2:

No, we can't. OpenCV is not made for that purpose.

Video streaming using c++

cvCreateCameraCapture

Initializes capturing video from camera

CvCapture* cvCreateCameraCapture( int index );

index Index of the camera to be used. If there is only one camera or it does not matter what camera to use -1 may be passed.

The function cvCreateCameraCapture allocates and initialized the CvCapture structure for reading a video stream from the camera.

Check the documentation.



回答3:

You cannot (not yet) use OpenCV for this, I think.

For C++ based applications, you can also use cv::VideoCapture class to create capture object and then >> operator to grab + output your stream frame-by-frame. I have my own website where I have posted a file called VideoWithOpenCV.cpp. you can get it to see how to do that.

The reason I got curious in your question is that I wanted to make an android app in OpenCV to stream video to my fiance but unfortunately couldn't get anywhere. If you get any luck, let me know.