I am compiling and installing OpenCV using the steps in http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_install/linux_install.html
But during "making" it, it has error when it reaches 45%. The error message is
...
[ 43%] Built target pch_Generate_opencv_video
[ 44%] Built target opencv_video
[ 44%] Built target opencv_p erf_video_pch_dephelp
[ 45%] Built target pch_Generate_opencv_perf_video
Linking CXX executable ../../bin/opencv_perf_video
../../lib/libopencv_videoio.so.3.1.0: undefined reference to `avcodec_alloc_frame'
../../lib/libopencv_videoio.so.3.1.0: undefined reference to `avcodec_encode_video'
collect2: error: ld returned 1 exit status
make[2]: *** [bin/opencv_perf_video] Error 1
make[1]: *** [modules/video/CMakeFiles/opencv_perf_video.dir/all] Error 2
make: *** [all] Error 2
I downloaded and installed the latest version of ffmpeg from https://www.ffmpeg.org/. And I installed ffmpeg following the steps on the compilation guide page https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu. I followed the steps and installed all the dependencies and libraries mentioned in the guide.
Anyone knows how can I fix the errors?
Thank you.
↧
“Undefined reference to `avcodec_alloc_frame” Error when compile and install Opencv on linux
↧
Error when compiling videoio/src/cap_ffmpeg_impl.hpp
I am compiling opencv 3.0.0 but I get multiple "xxx was not declared in this scope" errors when compiling cap_ffmpeg_impl.hpp file. (E.g pix_fmt_yuv422p, codec_pix_fmt) I have built ffmpeg using the --enable-shared option (as advised on other forums) and ffmpeg appears to run without any problems.
If a patch has been issued for this please let me know. Any help would be greatly appreciated
↧
↧
Using custom opencv_ffmpeg*.dll version on Windows
From `opencv/3rdparty/ffmpeg/readme.txt`: > On Windows OpenCV uses pre-built> ffmpeg binaries, built with proper> flags (without GPL components) and> wrapped with simple, stable> OpenCV-compatible API. The binaries> are opencv_ffmpeg.dll (version for> 32-bit Windows) and> opencv_ffmpeg_64.dll (version for> 64-bit Windows).>> See build_win32.txt for the build> instructions, if you want to rebuild> opencv_ffmpeg*.dll from scratch.
There is no `build_win32.txt`. The old version removed from repository (why?) gives some hints, but the current process clearly supports only the usage of the downloaded precompiled variants. At least as far as I can tell from the cmake infrastructure, even though `videoio/src/cap_ffmpeg*` still contains wrapper sources. Could someone clarify the necessary steps for MSVC-based Windows builds, in order to utilize custom-build versions of the ffmpeg libraries?
I'm building ffmpeg from sources here. Nowadays, this is much easier, even with a MSVC toolchain. In my opinion everyone should be encouraged to build a system with the components, fitting his needs best. Licensing issues are certainly not neglectable at times, but it should in my opinion not lead to obfuscated or quirky technical solutions.
↧
How to send opencv video's to ffmpeg
I m trying to send the processed opencv Mat as video to ffmpeg. I m encoding the frame and writing it to std output and then piping it to ffmpeg. Here is my code.
**C++:**
if(!cap.isOpened()) {
cout << "Video not accessible" << endl;
return -1;
} else {
cout << "Video is accessible" << endl;
}
while (true) {
cap >> frame;
//some processing
cv::imencode(".jpg", frame, buff);
for (i = buff.begin(); i != buff.end(); ++i)
std::cout << *i ;
}
My input video resolution is 640x418. I do not alter the video size
After building, I use following command to execute.
`./a.out | ffmpeg -f rawvideo -pix_fmt bgr24 -s 640x418 -r 30 -i - -an -f mpegts udp://0.0.0.0:8182`
and also this
`./a.out | ffmpeg -i pipe:0 -f rawvideo -pix_fmt bgr24 -s 640x418 -r 30 -i - -an -f mpegts udp://0.0.0.0:8182`
However none of this seems to work.
Kindly help.
↧
save png with imwrite() - read access violation
Hey there,
I already searched everything I could but only found similar problems, not a single proper solution.
What I'm using:
Win7 x64, QT 5.5.1 x64, VS2013 as compiler, opencv 3.1 x64 (precompiled version from the website).
I already have lots of code using opencv that works well.
Only problem: writing png/jpg with imwrite while in debug mode.
#include "opencv2/opencv.hpp"
...
cv::imwrite("D:/Scans/image.png", matTemp); // crashes
cv::imwrite("D:/Scans/image.bmp", matTemp); // works fine
Error: ... code: 0xc0000005: read access violation at: 0x0, flags=0x0
As said, this only happens when trying to save JPG or PNG in DEBUG mode. Saving as bmp works fine, saving as png and jpg while in release mode works, too. So there's nothing wrong with the Mat, the saved images are ok.
What I've gathered is, that this might have to do with opencv_ffmpeg*.dll. (also I read, that 0xc0...05 usually points to problems with (wrong) dlls)
There's no debug version of that file in the opencv-dl, so it makes sense to me, that it crashes when I try to access dependent methods.
Question is, how can I use ffmpeg in debug mode? I'm not a professional programmer, nor a particularily good hobbyist - I just do image processing and work my way through programming as good as I can - so I'm happy that everything is set up and works (mostly).
Would I need to build a debug dll myself? If so, how, from what? I've no idea about that stuff.
Or is there a simpler way to get it to work with what I already have?
Some mentioned copying the ffmpeg.dll in the debug folder, didn't help. ...\vc12\bin\ is registered as PATH variable, doesn't help.
I'd be very thankful, if anyone could help me with that problem. I'm out of (my very limited) ideas and would really like to solve this.
Photonik
↧
↧
Cannot build OpenCV 3.1.0 from source with FFMPEG
### Short version
**UPDATED MAY 28:** I've tried several more build configurations with FFMPEG. What I've discovered is that when configured with the `--enable-static` option, `make` generates all the necessary `.a` files (e.g. `libavcodec.a`), but I get an error to the effect of "relocation against symbol cannot be used when making a shared object; recompile with fPIC." I already have `--enable-pic` as an option. Then, when I try the configuration with `--disable-static` instead, no `.a` files are generated, which the OpenCV build says are required. How do I direct `make` to use the shared object files instead of looking for the `.a` libraries?
### Long version
I've been trying all week to build OpenCV 3.1.0 from sourcefor Python3.5 and Python2.7 on my local computer (Ubuntu 15.04 Vivid 64-bit), since there does not appear to be a compatible version available through aptitude. However, FFMPEG and libav are the impasses I cannot solve - several other issues with not finding HDF5 or Eigen3 I was able to fix relatively easily. Some of the tutorials and lessons I want to do use video as input, so I need to be the video tools working for OpenCV. I have been able to build OpenCV 3.1.0 successfully using the option `WITH_FFMPEG=OFF` and confirmed I could `import cv2` and use all of its non-video functions without a problem. I have tried installing ffmpeg and the libav dev libraries using aptitude as well as building FFMPEG from source. For the messages below, I'm using the FFMPEG I built myself.
The error I get is the following after calling `make` in the `~/github/opencv/build` directory:
make[2]: *** No rule to make target `/home/grant/github/ffmpeg/libavcodec.a`, needed by 'lib/libopencv_videoio.so.3.1.0'. Stop.
CMakeFiles/Makefile2:6038: recipe for target 'modules/videoio/CMakeFiles/opencv_videoio.dir/all' failed
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
Makefile:147: recipe for target 'all' failed
make: *** [all] Error 2
This is the error I want to solve. The rest of this post provides more information on what I've done and my setup. Note that FFMPEG I built from source (as well as libavcodec, libavfilter, libavutils, etc.) is in the `~/github/ffmpeg` directory.
When looking up this error, the most common suggestions involved static libraries and shared objects, namely that ffmpeg needed to be compiled with `--enable-shared` and `--disable-static` for the opencv build to work. This is why I built FFMPEG from source. Here's the output when I call `./ffmpeg` from the appropriate directory, confirming it was built with those options enabled: see the `configuration` line.
ffmpeg version N-80096-gdefab08 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.9.2 (Ubuntu 4.9.2-10ubuntu13)
configuration: --enable-shared --disable-static
libavutil 55. 24.100 / 55. 24.100
libavcodec 57. 43.100 / 57. 43.100
libavformat 57. 37.100 / 57. 37.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 46.100 / 6. 46.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 0.101 / 2. 0.101
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
The subdirectories `libavcodec`, `libavfilter`, `libavutil`, `libavformat`, `libavdevice`, `libswscale`, and `libswresample` are all in the aforementioned `~/github/ffmpeg` directory. Each of those contains the `.so` shared object file created by `make`, which I *think* is what I should be using to build OpenCV, but it seems to be looking for static `.a` files (e.g. `libavcodec.a`), which is in my `/usr/lib/x86_64-linux-gnu/` directory. I **HAVE** tried pointing the `FFMPEG_LIB_DIR` option to this directory, but this just throws the same error at the same point in compilation. This is what also led me to building FFMPEG with the `--enable-shared` and `--disable-static` options. Should I instead enable static so that `make` creates the `.a` files?
Additionally, I cloned both the opencv and opencv_contrib projects from their respective github repos, then called `git checkout 3.1.0` on both. I suspect the fix I need to make is to add a rule to `Makefile2`specifying to use the `.so` libraries instead of `.a`, though I'm inexperienced with using `make` and with shared objects. Any suggestions for what to modify would be appreciated. For completeness, below is the configuration done by `cmake`. Note that at one point the configuration says `libavcodec`, `libavfilter`, `libavformat`, etc. modules are not found. I don't know if this is related to the error or how to fix it.
> Detected version of GNU GCC: 49 (409)> Found ZLIB:> /usr/lib/x86_64-linux-gnu/libz.so> (found suitable version "1.2.8",> minimum required is "1.2.3") Found> ZLIB:> /usr/lib/x86_64-linux-gnu/libz.so> (found version "1.2.8") Found> OpenEXR:> /usr/lib/x86_64-linux-gnu/libIlmImf.so> CMake Warning at> cmake/OpenCVFindLibsGUI.cmake:18> (find_package): By not providing> "FindQt5Core.cmake" in> CMAKE_MODULE_PATH this project has > asked CMake to find a package> configuration file provided by> "Qt5Core", but CMake did not find> one.>> Could not find a package> configuration file provided by> "Qt5Core" with any of the following> names:>> Qt5CoreConfig.cmake> qt5core-config.cmake>> Add the installation prefix of> "Qt5Core" to CMAKE_PREFIX_PATH or set > "Qt5Core_DIR" to a directory> containing one of the above files. If> "Qt5Core" provides a separate> development package or SDK, be sure it> has been installed. Call Stack (most> recent call first): > CMakeLists.txt:535 (include)>>> CMake Warning at> cmake/OpenCVFindLibsGUI.cmake:19> (find_package): By not providing> "FindQt5Gui.cmake" in> CMAKE_MODULE_PATH this project has > asked CMake to find a package> configuration file provided by> "Qt5Gui", but CMake did not find> one.>> Could not find a package> configuration file provided by> "Qt5Gui" with any of the following> names:>> Qt5GuiConfig.cmake> qt5gui-config.cmake>> Add the installation prefix of> "Qt5Gui" to CMAKE_PREFIX_PATH or set > "Qt5Gui_DIR" to a directory containing> one of the above files. If "Qt5Gui" > provides a separate development> package or SDK, be sure it has been > installed. Call Stack (most recent> call first): CMakeLists.txt:535> (include)>>> CMake Warning at> cmake/OpenCVFindLibsGUI.cmake:20> (find_package): By not providing> "FindQt5Widgets.cmake" in> CMAKE_MODULE_PATH this project has> asked CMake to find a package> configuration file provided by > "Qt5Widgets", but CMake did not find> one.>> Could not find a package> configuration file provided by> "Qt5Widgets" with any of the> following names:>> Qt5WidgetsConfig.cmake> qt5widgets-config.cmake>> Add the installation prefix of> "Qt5Widgets" to CMAKE_PREFIX_PATH or> set "Qt5Widgets_DIR" to a directory> containing one of the above files. If> "Qt5Widgets" provides a separate> development package or SDK, be sure it> has been installed. Call Stack (most> recent call first): > CMakeLists.txt:535 (include)>>> CMake Warning at> cmake/OpenCVFindLibsGUI.cmake:21> (find_package): By not providing> "FindQt5Test.cmake" in> CMAKE_MODULE_PATH this project has > asked CMake to find a package> configuration file provided by> "Qt5Test", but CMake did not find> one.>> Could not find a package> configuration file provided by> "Qt5Test" with any of the following> names:>> Qt5TestConfig.cmake> qt5test-config.cmake>> Add the installation prefix of> "Qt5Test" to CMAKE_PREFIX_PATH or set > "Qt5Test_DIR" to a directory> containing one of the above files. If> "Qt5Test" provides a separate> development package or SDK, be sure it> has been installed. Call Stack (most> recent call first): > CMakeLists.txt:535 (include)>>> CMake Warning at> cmake/OpenCVFindLibsGUI.cmake:22> (find_package): By not providing> "FindQt5Concurrent.cmake" in> CMAKE_MODULE_PATH this project has> asked CMake to find a package> configuration file provided by > "Qt5Concurrent", but CMake did not> find one.>> Could not find a package> configuration file provided by> "Qt5Concurrent" with any of the> following names:>> Qt5ConcurrentConfig.cmake> qt5concurrent-config.cmake>> Add the installation prefix of> "Qt5Concurrent" to CMAKE_PREFIX_PATH> or set "Qt5Concurrent_DIR" to a> directory containing one of the above> files. If "Qt5Concurrent" provides> a separate development package or SDK,> be sure it has been installed. Call> Stack (most recent call first): > CMakeLists.txt:535 (include)>>> checking for module> 'gstreamer-base-1.0' package> 'gstreamer-base-1.0' not found> checking for module> 'gstreamer-video-1.0' package> 'gstreamer-video-1.0' not found> checking for module> 'gstreamer-app-1.0' package> 'gstreamer-app-1.0' not found checking> for module 'gstreamer-riff-1.0' > package 'gstreamer-riff-1.0' not found> checking for module> 'gstreamer-pbutils-1.0' package> 'gstreamer-pbutils-1.0' not found> checking for module> 'gstreamer-base-0.10' package> 'gstreamer-base-0.10' not found> checking for module> 'gstreamer-video-0.10' package> 'gstreamer-video-0.10' not found> checking for module> 'gstreamer-app-0.10' package> 'gstreamer-app-0.10' not found> checking for module> 'gstreamer-riff-0.10' package> 'gstreamer-riff-0.10' not found> checking for module> 'gstreamer-pbutils-0.10' package> 'gstreamer-pbutils-0.10' not found> checking for module 'libdc1394-2' > package 'libdc1394-2' not found> checking for module 'libdc1394' > package 'libdc1394' not found checking> for module 'libv4l1' package> 'libv4l1' not found checking for> module 'libv4l2' package 'libv4l2'> not found Looking for linux/videodev.h> Looking for linux/videodev.h - not> found Looking for linux/videodev2.h> Looking for linux/videodev2.h - found> Looking for sys/videoio.h Looking for> sys/videoio.h - not found checking for> module 'libavcodec' package> 'libavcodec' not found checking for> module 'libavformat' package> 'libavformat' not found checking for> module 'libavutil' package> 'libavutil' not found checking for> module 'libswscale' package> 'libswscale' not found checking for> module 'libavresample' package> 'libavresample' not found Looking for> libavformat/avformat.h Looking for> libavformat/avformat.h - found Looking> for ffmpeg/avformat.h Looking for> ffmpeg/avformat.h - not found checking> for module 'libgphoto2' package> 'libgphoto2' not found found IPP (ICV> version): 9.0.1 [9.0.1] at:> /home/grant/github/opencv/3rdparty/ippicv/unpack/ippicv_lnx> Could NOT find Doxygen (missing: > DOXYGEN_EXECUTABLE) To enable> PlantUML support, set PLANTUML_JAR> environment variable or pass> -DPLANTUML_JAR= option to cmake Found PythonInterp:> /usr/bin/python2.7 (found suitable> version "2.7.9", minimum required is> "2.7") Found PythonLibs:> /usr/lib/x86_64-linux-gnu/libpython2.7.so> (found suitable exact version "2.7.9")> Found PythonInterp:> /usr/local/bin/python3.5 (found> suitable version "3.5", minimum> required is "3.4") Found PythonLibs:> /usr/lib/x86_64-linux-gnu/libpython3.4m.so> (found suitable exact version "3.5.0")> VTK is not found. Please set -DVTK_DIR> in CMake to VTK build directory, or to> VTK install subdirectory with> VTKConfig.cmake file Caffe: NO> Protobuf: NO Glog: NO HDF5: YES> Module opencv_sfm disabled because the> following dependencies are not found:> Glog/Gflags Tesseract: NO HDF5: > YES Could NOT find PROTOBUF (missing: > PROTOBUF_LIBRARY PROTOBUF_INCLUDE_DIR)> Build libprotobuf from sources:> libprotobuf not found into system> The protocol buffer compiler not found Tesseract: NO>> General configuration for OpenCV 3.1.0> ===================================== Version control: 3.1.0>> Platform:> Host: Linux 3.19.0-25-generic x86_64> CMake: 3.0.2> CMake generator: Unix Makefiles> CMake build tool: /usr/bin/make> Configuration: RELEASE>> C/C++:> Built as dynamic libs?: YES> C++ Compiler: /usr/bin/c++ (ver 4.9.2)> C++ flags (Release): -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 -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): -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 -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): -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 -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): -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 -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: YES> Extra dependencies: /usr/lib/x86_64-linux-gnu/libQtGui.so> /usr/lib/x86_64-linux-gnu/libQtTest.so> /usr/lib/x86_64-linux-gnu/libQtCore.so> /usr/lib/x86_64-linux-gnu/libpng.so> /usr/lib/x86_64-linux-gnu/libtiff.so> /usr/lib/x86_64-linux-gnu/libjasper.so> /usr/lib/x86_64-linux-gnu/libjpeg.so> /usr/lib/x86_64-linux-gnu/libImath.so> /usr/lib/x86_64-linux-gnu/libIlmImf.so> /usr/lib/x86_64-linux-gnu/libIex.so> /usr/lib/x86_64-linux-gnu/libHalf.so> /usr/lib/x86_64-linux-gnu/libIlmThread.so> /home/grant/github/ffmpeg//libavcodec.a> /home/grant/github/ffmpeg//libavformat.a> /home/grant/github/ffmpeg//libavutil.a> /home/grant/github/ffmpeg//libswscale.a> /home/grant/github/ffmpeg//libavresample.a> /usr/lib/x86_64-linux-gnu/hdf5/serial/lib/libhdf5.so> /usr/lib/x86_64-linux-gnu/libpthread.so> /usr/lib/x86_64-linux-gnu/libz.so> /usr/lib/x86_64-linux-gnu/libdl.so> /usr/lib/x86_64-linux-gnu/libm.so dl m> pthread rt> 3rdparty dependencies: libwebp libprotobuf>> OpenCV modules:> To be built: core flann hdf imgproc ml photo reg> surface_matching video dnn fuzzy> imgcodecs shape videoio highgui> objdetect plot superres ts 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 viz> cvv matlab sfm>> GUI: > QT 4.x: YES (ver 4.8.6 EDITION = OpenSource)> QT OpenGL support: NO> OpenGL support: NO> VTK support: NO>> Media I/O: > ZLib: /usr/lib/x86_64-linux-gnu/libz.so (ver> 1.2.8)> JPEG: /usr/lib/x86_64-linux-gnu/libjpeg.so> (ver )> WEBP: build (ver 0.3.1)> PNG: /usr/lib/x86_64-linux-gnu/libpng.so> (ver 1.2.51)> TIFF: /usr/lib/x86_64-linux-gnu/libtiff.so> (ver 42 - 4.0.3)> JPEG 2000: /usr/lib/x86_64-linux-gnu/libjasper.so> (ver 1.900.1)> OpenEXR: /usr/lib/x86_64-linux-gnu/libImath.so> /usr/lib/x86_64-linux-gnu/libIlmImf.so> /usr/lib/x86_64-linux-gnu/libIex.so> /usr/lib/x86_64-linux-gnu/libHalf.so> /usr/lib/x86_64-linux-gnu/libIlmThread.so> (ver Unknown)> GDAL: NO>> Video I/O:> DC1394 1.x: NO> DC1394 2.x: NO> FFMPEG: YES> codec: YES (ver Unknown)> format: YES (ver Unknown)> util: YES (ver Unknown)> swscale: YES (ver Unknown)> resample: YES (ver Unknown)> gentoo-style: YES> GStreamer: NO> OpenNI: NO> OpenNI PrimeSensor Modules: NO> OpenNI2: NO> PvAPI: NO> GigEVisionSDK: NO> UniCap: NO> UniCap ucil: NO> V4L/V4L2: NO/YES> XIMEA: NO> Xine: NO> gPhoto2: NO>> Parallel framework: > pthreads>> Other third-party libraries:> Use IPP: 9.0.1 [9.0.1]> at: /home/grant/github/opencv/3rdparty/ippicv/unpack/ippicv_lnx> Use IPP Async: NO> Use VA: NO> Use Intel VA-API/OpenCL: NO> Use Eigen: YES (ver 3.2.2)> Use Cuda: NO> Use OpenCL: YES> Use custom HAL: NO>> OpenCL:> Version: dynamic> Include path: /home/grant/github/opencv/3rdparty/include/opencl/1.2> Use AMDFFT: NO> Use AMDBLAS: NO>> Python 2:> Interpreter: /usr/bin/python2.7 (ver 2.7.9)> Libraries: /usr/lib/x86_64-linux-gnu/libpython2.7.so> (ver 2.7.9)> numpy: /usr/local/lib/python2.7/dist-packages/numpy/core/include> (ver 1.11.0)> packages path: lib/python2.7/dist-packages>> Python 3:> Interpreter: /usr/local/bin/python3.5 (ver 3.5)> Libraries: /usr/lib/x86_64-linux-gnu/libpython3.4m.so> (ver 3.5.0)> numpy: /usr/local/lib/python3.5/site-packages/numpy/core/include> (ver 1.11.0)> packages path: /usr/local/lib/python3.5/site-packages>> Python (for build): > /usr/bin/python2.7>> Java:> ant: NO> JNI: /usr/lib/jvm/default-java/include> /usr/lib/jvm/default-java/include> /usr/lib/jvm/default-java/include> Java wrappers: NO> Java tests: NO>> Matlab: NO>> Documentation:> Doxygen: NO> PlantUML: NO>> Tests and samples:> Tests: YES> Performance tests: YES> C/C++ Examples: YES>> Install path: > /usr/local>> cvconfig.h is in: > /home/grant/github/opencv/build> ----------------------------------------------------------------->> Configuring done Generating done
↧
Processing Camera stream in Opencv, pushing it over RTMP (NGINX RTMP Module) using FFMPEG
Output video:
https://youtu.be/VxfoBQjoY6E
**Explanation:**
I want to: Process camera stream in Opencv and push it over to RTMP server. I already have NGINX (RTMP module) set up and I have tested streaming videos with both RTMP (Flash Player) and HLS.
I am reading the frames in a loop and using 'subprocess' in python to execute ffmpeg command. Here's the command I am using:
command = [ffmpeg,
'-y',
'-f', 'rawvideo',
'-vcodec','rawvideo',
'-pix_fmt', 'bgr24',
'-s', dimension,
'-i', '-',
'-c:v', 'libx264',
'-pix_fmt', 'yuv420p',
'-preset', 'ultrafast',
'-f', 'flv',
'rtmp://10.10.10.80/live/mystream']
import subprocess as sp
...
proc = sp.Popen(command, stdin=sp.PIPE,shell=False)
...
proc.stdin.write(frame.tostring()) #frame is read using opencv
**Problem:**
I can see the stream fine but it freezes and resumes frequently. Here's the output of FFMPEG terminal log:
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
frame= 117 fps= 16 q=22.0 size= 344kB time=00:00:04.04 bitrate= 697.8kbits/s speed=0.543x
It mentions speed at the end. I believe it should be close to 1x. I am not sure how to achieve that.
And I am on the same network as server, I can post my python code if required. Need some ffmpeg guru to give me some advise.
↧
Which one does Opencv supports libav(FFmpeg fork) or FFmpeg
For ubuntu 14.04, which one does OpenCV ( 2.4.9 / 3.0) supports, libav or FFmpeg. Also how to compile OpenCV with FFmpeg/libav enabled.
Right now I have installed Opencv 2.4.9 which gives error while capturing a video in '.mp4' format with 'X264'.
Can I go forward with uninstalling 2.4.9 and upgrading to OpenCV 3 . While upgrading which one should I include FFmpeg or libav.I want gstream also to be enabled.
Can i keep [link text](http://blog.mycodesite.com/compile-opencv-with-ffmpeg-for-ubuntudebian/) as reference for upgrading to Opencv 3
↧
Opencv IP Camera Error
I am using andriod app (IP webcam) as ip camera. i'm running below code in separate thread. because if i run in main thread it crashes the program.
VideoCapture cap; Mat img;
cap.open("http://192.168.0.101:8080/video?x.mjpeg");
while(waitKey(33)!=27)
{
try{
cap>>img;
cout<<"Thread active"<
↧
↧
Cannot compile OpenCV 3.1.0 with FFmpeg using shared libraries in Centos 7
Hello,
I am trying to compile OpenCV 3.1.0 with FFmpeg with Centos 7, and I'm getting the following error:
Linking CXX shared library ../../lib/libopencv_videoio.so
/usr/bin/ld: /usr/local/include/../lib/libswscale.a(swscale.o): relocation R_X86_64_PC32 against symbol `ff_M24A' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [lib/libopencv_videoio.so.3.1.0] Error 1
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
make: *** [all] Error 2
I compiled FFmpeg with the following build script: http://pastebin.com/B1xDTJtF
I have tried the build script with and without the --enable-static and --enable-shared flags, and all of the results appear to be similar. Although, I could be (and probably am) missing something extremely important.
↧
OpenCV VideoCapture does not work as pointer or member variable
I have a very strange hevaviour with opencv3.0.0 c++ in visual studio 2010 on windows7.
I simply want to open a video file to grab/extract frames from it. When i create a local variable in my cpp, everything works fine:
VideoCapture inputVideo;
bool loadOk = inputVideo.open(filename); //loadOk is true
When i do a pointer in my cpp, the open process does not work.
VideoCapture * inputVideo = new VideoCapture();
bool loadOk = inputVideo->open(filename); //loadOk is false
When i create a member variable in my header file, it is also not working
Header:
VideoCapture m_inputVideo;
CPP:
bool loadOk = m_inputVideo.open(filename); //loadOk is false
Header:
VideoCapture * m_inputVideo;
CPP:
m_inputVideo = new VideoCapture();
bool loadOk = m_inputVideo->open(filename); //loadOk is false
Can you help me get rid of this problem? I really need to declare the videocapture as member variable so i can acess it throughout my whole program. greetings, Julian
↧
OpenCV 3.1 VideoCapture ffmpeg
Hello every one. I'm using opencv 3.1
how can I using ffmpeg explicity?
std::string filename = "1440x1072.avi";
capture.open(filename, CAP_FFMPEG);
does not work...
//internally it invoke follow code
//opencv code
bool VideoCapture::open(const String& filename, int apiPreference)
{
if (isOpened()) release();
icap = IVideoCapture_create(filename);
if (!icap.empty())
return true;
cap.reset(cvCreateFileCaptureWithPreference(filename.c_str(), apiPreference)); // !! <- and only here opencv start working with apiPreference!
return isOpened();
}
//opencv code
so how to using apiPreference correctly? In my case, i get cap = IVideoCapture_create(filename) not empty
and cvCreateFileCaptureWithPreference never invoke. Does it bug?
Just in case, I open "ProcessExplorer" app and check what kind of dll was started with my application. There no any ffmpeg dll in list.
Then I rename video file with non english words (some russians symbols) and after that string cap = IVideoCapture_create(filename) make empty, and program go to execute cvCreateFileCaptureWithPreference. I open "ProcessExplorer" and see now application using opencv_ffmpeg310_64.dll
Also the video file has some kind of interlines capture, and after capture.read(mat) procedure, the height ot the output mat is half of original video frame (536 instead of 1072). When opencv_ffmpeg310_64.dll using I get original frame
↧
Tracking an object via OpenCV
I am trying to track an object and mask (a CODE in this case) using OpenCV and Python. As example I am using this video: https://www.dropbox.com/s/eu01hxoxmd3ns5f/capture-3.mp4?dl=0
What I need is to keep track on the CODE without detecting other parts of the video as the code. Tracking by colour doesn't work here.
Any idea for a good approach on this problem?
↧
↧
Control VideoCapture Multithreading
Is there a way to limit the number of threads (or even just cpu cores) that VideoCapture().read() can use?
I am processing h264 encoded videos in a parallelized program and want to be able to control how much system resources my calls to VideoCapture().read() use. It's running on a shared server and to stay friends with my peers, I need to avoid hogging cpus.
I'm running OpenCV 3.1.0 with Python 3 bindings on a Debian machine
↧
Error “sys/videoio.h - not found” OpenCV 3.1.0
I using Elementary OS and I'm trying to install OpenCV 3.1.0, I follow the instructions of http://docs.opencv.org/3.0-beta/doc/tutorials/introduction/linux_install/linux_install.html
Also, I have installed libav 11.7 and ffmpeg 3.1.3
but, after
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
I get:
-- Looking for linux/videodev.h
-- Looking for linux/videodev.h - found
-- Looking for linux/videodev2.h
-- Looking for linux/videodev2.h - found
-- Looking for sys/videoio.h
-- **Looking for sys/videoio.h - not found**
-- Looking for libavformat/avformat.h
-- Looking for libavformat/avformat.h - found
-- Looking for ffmpeg/avformat.h
-- **Looking for ffmpeg/avformat.h - not found**
-- checking for module 'libgphoto2'
-- package 'libgphoto2' not found
And after make,
I get:
../../lib/libopencv_videoio.so.3.1.0: referencia a av_frame_alloc' sin definir
../../lib/libopencv_videoio.so.3.1.0: referencia aav_frame_free' sin definir
collect2: error: ld returned 1 exit status
make[2]: * [bin/opencv_test_video] Error 1
make[1]: * [modules/video/CMakeFiles/opencv_test_video.dir/all] Error 2
someone who can help me ?
but, after
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
I get:
-- Looking for linux/videodev.h
-- Looking for linux/videodev.h - found
-- Looking for linux/videodev2.h
-- Looking for linux/videodev2.h - found
-- Looking for sys/videoio.h
-- **Looking for sys/videoio.h - not found**
-- Looking for libavformat/avformat.h
-- Looking for libavformat/avformat.h - found
-- Looking for ffmpeg/avformat.h
-- **Looking for ffmpeg/avformat.h - not found**
-- checking for module 'libgphoto2'
-- package 'libgphoto2' not found
And after make,
I get:
../../lib/libopencv_videoio.so.3.1.0: referencia a av_frame_alloc' sin definir
../../lib/libopencv_videoio.so.3.1.0: referencia aav_frame_free' sin definir
collect2: error: ld returned 1 exit status
make[2]: * [bin/opencv_test_video] Error 1
make[1]: * [modules/video/CMakeFiles/opencv_test_video.dir/all] Error 2
someone who can help me ?
↧
opencv_ffmpeg2413_64.dll gets loaded, VideoCapture still cannot open files
I'm compiling using VS 2015, and I can see in the debug log that the ffmpeg dll gets properly loaded, but when I try to open a file using `VideoCapture` (`VideoCapture::isOpened()` returns false).
I do have ffmpeg and the K-Lite codec pack installed, and I'm trying to open a H.264 (mp4) or an XviD (avi) file, no dice.
Thanks in advance!
↧
opencv 3.1 ffmpeg should I do shared enable
SO I'm installing opencv 3.1 for c++ use on Ubuntu 16.04 on Rpi 3 opencv with gcc 4.9. In some tutorials they recommend to build ffmpeg from source with shared enable and disable static flag. In others they just build ffmpeg from packages via apt-get. So I wonder whats the right way to do it?
↧
↧
ffmpeg DLL not loaded on Windows 7, working on 8 and 10
I need to maintain a project that uses OpenCV 3.0 for its main processing and based on QT.
The development environment is based around QT Creator on Windows 10 and Visual C++ 2013 64-bit is used for building.
We want to make our app compatible with Windows 7, and there is an issue with this OS specifically.
It is impossible to get video files to load, the same video files getting to load without issues when running the application on Windows 10 and 8.
After investigation, this seems to be related to the ffmpeg DLL (opencv_ffmpeg300_64.dll). Using the Process Explorer tool from MS, I can notice that the mentioned DLL is loaded at the time a video file is opened (VideoCapture::open call) on Windows 10 and 8. On Windows 7, the DLL is never loaded, there is no trace of it in Process Explorer, and VideoCapture::isOpened obviously returns false with the same video files.
The DLL is present in the same directory as the application executable.
Note : I run a standalone, release build of our app on Windows 7 for testing. The development environment is on Windows 10 only.
Do you have any clue about a specific restriction or loading process of DLL loading on Windows 7? Would rolling out my own build of OpenCV address the issue?
↧
Videocapture grab function does not return (blocking call) when IP camera is disconnected.
The problem which I am facing is that the grab function of Videocapture object **gets stuck** when my IP cam is disconnected. Ideally, the grab() function or the isOpened() function should return false on IP cam failure after some timeout but instead function isOpened() returns true and grab() doesn't return anything (**stuck at grabbing**).
I am using python2.7 interpreter and I have tried this on **ubuntu 14.04** and **windows 10** with prebuilt opencv package, manually **compiled opencv 2.4.13 and 3.1.0 with ffmpeg**. Same result on all the versions.
I searched on different forums and dug into the source files to pinpoint the line, function and the file where the grab call is getting stuck. So the function **CvCapture_FFMPEG::grabFrame()** (*sources/modules/highgui/src/cap_ffmpeg_impl.h*) is stuck in while loop when IP camera is disconnected and somehow the timeout interrupt is not working in this case. I have checked this by adding log statements at different points in the CvCapture_FFMPEG::grabFrame() function.
So is this the problem with ffmpeg libraries or the CvCapture_FFMPEG::grabFrame() function or am I missing something?
Note: This **problem does not occur** when I compile **OpenCV with gstreamer** (either 0.10 or 1.0). There grab() function returns false on IP camera disconnect. I have tested this on opencv 2 and 3 on ubuntu 14.04 and windows 10.
↧
opencv_ffmpeg module crash (IP Camera)
I'm using IP webcam android app(It converts mobile camera into IP web camera).
I'm running below code in Visual Studio 2015 with OpenCV 3.1. VideoCapture cap; Mat img; cap.open("http://192.168.0.101:8080/video?x.mjpeg"); while(waitKey(33)!=27) { try{ cap>>img; //code crashes here if(img.empty()) { cout<<"camera Closed"<
**Error:** > Exception thrown at 0x0BF2F6F0 (opencv_ffmpeg310.dll) in test.exe:> 0xC0000005: Access violation reading location 0x00000020.>> If there is a handler for this exception, the program may be safely> continued.
even if the code is wrapped within try catch block, it crashes!
Should I use try {} catch (...) block in source file, if yes, then where should I use this?
I referred this [link][1] but did not find the right answer. [1]: https://github.com/opencv/opencv/issues/6726
I'm running below code in Visual Studio 2015 with OpenCV 3.1. VideoCapture cap; Mat img; cap.open("http://192.168.0.101:8080/video?x.mjpeg"); while(waitKey(33)!=27) { try{ cap>>img; //code crashes here if(img.empty()) { cout<<"camera Closed"<
Should I use try {} catch (...) block in source file, if yes, then where should I use this?
I referred this [link][1] but did not find the right answer. [1]: https://github.com/opencv/opencv/issues/6726
↧