Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Read h264 stream from an IP camera

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++ ?

Read h264 stream from an IP camera

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++ ?