I am currently trying to use opencv to read video from a Canon VB-H710F camera.
To this end, I tried two different solutions:
SOLUTION 1: Reading a stream from an rtsp address
VideoCapture cam ("rtsp://root: camera@10.0.4.127 /stream/profile1=u"); while(true) cam >> frame;
In this case, I use opencv to read directly from the stream encoded in H264 (profile1), however this gives the same problem that was 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 resolved h264 decoding errors, but posed another problem. There is always a long delay when accessing a stream with opencv supported by gstreame. With this solution, I achieve 15 FPS, but I have a delay of 5 seconds, which is unacceptable, given that I need a real-time application.
SOLUTION 2: reading frames from an http address while (true) {= System.currentTimeMillis starting span ();
URL url = new URL("http://[IP]/-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 captures the frame from the URL that the camera provides. The code is in Java, but the results in C ++ are the same as the curl library. This solution avoids the delay of the first solution, however, no more than 100 ms is required for each frame, which means that I can only achieve an average of 10 FPS.
I would like to know how can I read a video using C ++ or another library developed in C ++?
source share