Hello,
I am trying to so some processing on a IP Camera (Onvif) output image, and it works well, but I see a lag between the real world and the video capture in about 3~4 seconds.
I am using the rtsp:// protocol.
This camera have a web interface (IE / ActiveX) that shows the image with very low lag. (about 200~300 ms).
I have no idea why it's so slow on OpenCV. I wold like some tips to make the capture faster.
Thank you!
You can see the code I am using bellow, i also included the output:
CODE
#include <stdio.h>
#include <opencv2/opencv.hpp>
#include <thread>
#include <unistd.h>
using namespace cv;
using namespace std;
int main(int argc, char *argv[])
{
cout << getBuildInformation();
VideoCapture cap;
cout << "open stream: " << argv[1] << endl;
if(!cap.open(argv[1]))
exit(-1);
cout << "stream open!\n";
Mat test;
do{
cap >> test;
if(test.empty()){
cout << "Empty!\n";
} else {
imshow("imagem", test);
}
} while(waitKey(1) < 0);
}
Output
leonardo@LeonardoB:~/Desktop/Ether_Test/build$ make ; ./EtherTest rtsp://admin:[email protected]:554/ucast/11
Scanning dependencies of target EtherTest
[ 50%] Building CXX object CMakeFiles/EtherTest.dir/main.cpp.o
[100%] Linking CXX executable EtherTest
[100%] Built target EtherTest
General configuration for OpenCV 3.1.0-dev =====================================
Version control: 3.1.0-1362-gcde9d64
Extra modules:
Location (extra): /home/leonardo/OpenCV/OpenCV3/opencv_contrib/modules
Version control (extra): 3.1.0-297-g246ea8f
Platform:
Timestamp: 2016-09-22T13:20:09Z
Host: Linux 4.7.4-1-ARCH x86_64
CMake: 3.6.2
CMake generator: Unix Makefiles
CMake build tool: /usr/bin/make
Configuration: Release
C/C++:
Built as dynamic libs?: NO
C++ Compiler: /usr/bin/c++ (ver 6.2.1)
C++ flags (Release): -fPIC -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
C++ flags (Debug): -fPIC -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
C Compiler: /usr/bin/cc
C flags (Release): -fPIC -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG
C flags (Debug): -fPIC -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
Linker flags (Release):
Linker flags (Debug):
Precompiled headers: NO
Extra dependencies: /lib64/libwebp.so /lib64/libpng.so /lib64/libtiff.so /lib64/libjasper.so /lib64/libjpeg.so /lib64/libImath.so /lib64/libIlmImf.so /lib64/libIex.so /lib64/libHalf.so /lib64/libIlmThread.so gtk-3 gdk-3 pangocairo-1.0 pango-1.0 atk-1.0 cairo-gobject cairo gdk_pixbuf-2.0 gio-2.0 gthread-2.0 gstvideo-1.0 gstapp-1.0 gstbase-1.0 gstriff-1.0 gstpbutils-1.0 gstreamer-1.0 gobject-2.0 glib-2.0 dc1394 xine gphoto2 gphoto2_port /lib64/libOpenNI.so /lib64/libprotobuf.so /lib64/libhdf5_cpp.so /lib64/libhdf5.so /lib64/libz.so /lib64/libdl.so /lib64/libm.so vtkRenderingOpenGL2 vtkCommonExecutionModel vtkCommonDataModel vtkCommonMath vtkCommonCore vtksys vtkCommonMisc vtkCommonSystem vtkCommonTransforms vtkImagingHybrid vtkIOImage vtkDICOMParser vtkIOCore /usr/lib64/libz.so vtkmetaio /usr/lib64/libjpeg.so /usr/lib64/libpng.so /usr/lib64/libtiff.so vtkImagingCore vtkRenderingCore vtkCommonColor vtkFiltersExtraction vtkFiltersCore vtkFiltersGeneral vtkCommonComputationalGeometry vtkFiltersStatistics vtkImagingFourier vtkalglib vtkFiltersGeometry vtkFiltersSources vtkglew vtkInteractionStyle vtkRenderingLOD vtkFiltersModeling vtkIOPLY vtkIOGeometry vtkFiltersTexture vtkRenderingFreeType /usr/lib64/libfreetype.so vtkIOExport vtkRenderingAnnotation vtkImagingColor vtkRenderingContext2D vtkRenderingLabel stdc++ dl m pthread rt tbb
3rdparty dependencies: ippicv
OpenCV modules:
To be built: core flann hdf imgproc ml photo reg surface_matching video viz dnn fuzzy imgcodecs shape videoio highgui objdetect plot superres xobjdetect xphoto bgsegm bioinspired dpm face features2d line_descriptor saliency text calib3d ccalib datasets rgbd stereo structured_light tracking videostab xfeatures2d ximgproc aruco optflow stitching python2 python3
Disabled: world contrib_world
Disabled by dependency: -
Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java ts cvv matlab sfm
GUI:
QT: NO
GTK+ 3.x: YES (ver 3.20.9)
GThread : YES (ver 2.48.2)
GtkGlExt: NO
OpenGL support: NO
VTK support: YES (ver 7.0.0)
Media I/O:
ZLib: /lib64/libz.so (ver 1.2.8)
JPEG: /lib64/libjpeg.so (ver )
WEBP: /lib64/libwebp.so (ver encoder: 0x0209)
PNG: /lib64/libpng.so (ver 1.6.25)
TIFF: /lib64/libtiff.so (ver 42 - 4.0.6)
JPEG 2000: /lib64/libjasper.so (ver 1.900.1)
OpenEXR: /lib64/libImath.so /lib64/libIlmImf.so /lib64/libIex.so /lib64/libHalf.so /lib64/libIlmThread.so (ver 2.2.0)
GDAL: NO
GDCM: NO
Video I/O:
DC1394 1.x: NO
DC1394 2.x: YES (ver 2.2.4)
FFMPEG: NO
codec: NO
format: NO
util: NO
swscale: NO
resample: NO
gentoo-style: NO
GStreamer:
base: YES (ver 1.8.3)
video: YES (ver 1.8.3)
app: YES (ver 1.8.3)
riff: YES (ver 1.8.3)
pbutils: YES (ver 1.8.3)
OpenNI: YES (ver 1.5.7, build 10)
OpenNI PrimeSensor Modules: YES (/lib64/libXnCore.so)
OpenNI2: NO
PvAPI: NO
GigEVisionSDK: NO
UniCap: NO
UniCap ucil: NO
V4L/V4L2: NO/YES
XIMEA: NO
Xine: YES (ver 1.2.6)
gPhoto2: YES
Parallel framework: TBB (ver 4.4 interface 9005)
Other third-party libraries:
Use IPP: 9.0.1 [9.0.1]
at: /home/leonardo/OpenCV/OpenCV3/opencv/3rdparty/ippicv/unpack/ippicv_lnx
Use IPP Async: NO
Use VA: NO
Use Intel VA-API/OpenCL: NO
Use Lapack: NO
Use Eigen: YES (ver 3.2.9)
Use Cuda: NO
Use OpenCL: YES
Use OpenVX: NO
Use custom HAL: NO
OpenCL: <Dynamic loading of OpenCL library>
Include path: /home/leonardo/OpenCV/OpenCV3/opencv/3rdparty/include/opencl/1.2
Use AMDFFT: NO
Use AMDBLAS: NO
Python 2:
Interpreter: /usr/bin/python2.7 (ver 2.7.12)
Libraries: /lib64/libpython2.7.so (ver 2.7.12)
numpy: /usr/lib/python2.7/site-packages/numpy/core/include (ver 1.11.1)
packages path: lib/python2.7/site-packages
Python 3:
Interpreter: /usr/bin/python3 (ver 3.5.2)
Libraries: /lib64/libpython3.5m.so (ver 3.5.2)
numpy: /usr/lib/python3.5/site-packages/numpy/core/include (ver 1.11.1)
packages path: lib/python3.5/site-packages
Python (for build): /usr/bin/python2.7
Java:
ant: /bin/ant (ver 1.9.7)
JNI: NO
Java wrappers: NO
Java tests: NO
Matlab: Matlab not found or implicitly disabled
Documentation:
Doxygen: /usr/bin/doxygen (ver 1.8.12)
PlantUML: NO
Tests and samples:
Tests: NO
Performance tests: NO
C/C++ Examples: NO
Install path: /usr/local
cvconfig.h is in: /home/leonardo/OpenCV/OpenCV3/build
-----------------------------------------------------------------
open stream: rtsp://admin:[email protected]:554/ucast/11
(ERROR)icvOpenAVI_XINE(): Unable to open source 'rtsp://admin:[email protected]:554/ucast/11'
stream open!