Ask Your Question
2

Read h264 stream from an IP camera

asked 2014-10-04 09:45:41 -0600

JCNeves gravatar image

updated 2019-01-18 13:41:17 -0600

Currently, I am trying to use opencv to read a video from my Canon VB-H710F camera.

For this purpose I tried two different solutions:

SOLUTION 1: Read the stream from rtsp address

VideoCapture cam ("rtsp://root:[email protected]/stream/profile1=u"); While(true) cam >> frame;

In this case I am using opencv to directly read from a stream encoded with in H264 (profile1), however this yields the same problem reported here http://answers.opencv.org/question/34012/ip-camera-h264-error-while-decoding/ As suggested in the previous question, I tried to disable FFMPEG support in opencv installation, which solved the h264 decoding errors but raised other problem. When accessing the stream with opencv, supported by gstreamer, there is always a large delay associated. With this solution I achieve 15 FPS but I have a delay of 5 seconds, which is not acceptable considering that I need a real time application.

SOLUTION 2: Read the frames from http address

while(true) { startTime=System.currentTimeMillis();
URL url = new URL("http://10.0.4.127/-wvhttp-01-/image.cgi"); URLConnection con = url.openConnection(); BufferedImage image = ImageIO.read(con.getInputStream());
showImage(image); estimatedTime=System.currentTimeMillis()-startTime; System.out.println(estimatedTime); Thread.sleep(5); }

This strategy simply grabs the frame from the url that the camera provides. The code is in Java but the results are the same in C++ with the curl library. This solution avoids the delay of the first solution however it takes little more than 100 ms to grab each frame, which means that I can only achieve on average 10 FPS.

I would like to know how can I read the video using c++ or another library developed in c++ ?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-07-13 09:56:35 -0600

joecmama gravatar image

I was able to get a video feed using libVLC with OpenCV. I use MS Visual Studio on Windows 7 and 8.1. Details are given here: http://answers.opencv.org/question/65932

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-10-04 09:45:41 -0600

Seen: 11,193 times

Last updated: Jul 13 '15