OpenCV: terminate handler is called! The last OpenCV error is:
OpenCV(4.6.0) Error: Assertion failed (size.width>0 && size.height>0) in cv::imshow, file ...\OpenCV\opencv-4.6.0\modules\highgui\src\window.cpp, line 967
Also it is not clear to me how you set these variable in Windows. Is it via UI or PowerShell? Although in both cases the format of this variable seems strange to me.
You need to specify the device name given in device manager, i.e. “HD Webcam”, not the index as you would when using the Direct Show backend (CAP_DSHOW).
You need to build against FFmpeg not use the pre-built binaries, these won’t include any changes you made to cap_ffmpeg_impl.hpp.
I extracted the Build and created an directory /cmake containing the mentioned .cmake file.
Afterwards I set the variables via Windows UI, but Cmake (I use cmake-gui on windows) doesn’t catch the FFMpeg Build.
FFMPEG: Downloading opencv_videoio_ffmpeg.dll from https://raw.githubusercontent.com/opencv/opencv_3rdparty/65ec04d4573dcdfa4531f0b9e67f35d8ffff873e/ffmpeg/opencv_videoio_ffmpeg.dll
FFMPEG: Downloading opencv_videoio_ffmpeg_64.dll from https://raw.githubusercontent.com/opencv/opencv_3rdparty/65ec04d4573dcdfa4531f0b9e67f35d8ffff873e/ffmpeg/opencv_videoio_ffmpeg_64.dll
FFMPEG: Downloading ffmpeg_version.cmake from https://raw.githubusercontent.com/opencv/opencv_3rdparty/65ec04d4573dcdfa4531f0b9e67f35d8ffff873e/ffmpeg/ffmpeg_version.cmake
From the command line, that way I can set FFMPEG_DIR=...
and then run cmake.exe ... .. OPENCV_FFMPEG_USE_FIND_PACKAGE=ON
Although I would have thought you should be able to achieve the same thing in the GUI if you add OPENCV_FFMPEG_USE_FIND_PACKAGE using Add Entry not Environment. The only problem is you then have to configure again and it might not pick up this additional variable.
Yes inside cmake-gui you can edit environment variables. I previously set the varibles in the Windows UI for environmental variables, which led them to appear in the Environment Editor of Cmake-gui. With cmd set you can achieve the same.
This might be the issue. I tried opening the gui with cmd, but added the OPENCV_FFMPEG_USE_FIND_PACKAGE=ON Flag. No difference.
but it set FFMPEG_FOUND to FALSE so package “FFMPEG” is considered to be
NOT FOUND.
Call Stack (most recent call first):
modules/videoio/cmake/init.cmake:7 (include)
modules/videoio/cmake/init.cmake:11 (add_backend)
cmake/OpenCVModule.cmake:298 (include)
cmake/OpenCVModule.cmake:361 (_add_modules_1)
cmake/OpenCVModule.cmake:385 (ocv_glob_modules)
CMakeLists.txt:931 (ocv_register_modules)
I don’t know what you are doing differently, I just tried again from scratch setting OPENCV_FFMPEG_USE_FIND_PACKAGE=ON and FFMPEG_DIR to the directory containing the cmake script inside of the cmake gui and it picked up FFmpeg straight away.
Does your FFmpeg directory sturcture look similar to the below?
bin
- avcodec-59.dll
- ...
cmake
- ffmpeg-config.cmake
doc
...
I must have casually extracted the folder there and forgot about the original zip folder, so the dir cmake was not with bin in one dir.
However, now I moved them in an structure like this:
\bin\
\cmake\
ffmpeg-config.cmake
\docs\
...
This gives me a new output, FFmpeg is found, but disabled:
Found FFMPEG: C:/Users/NvidiaPC/FFMPEG_BUILD/ffmpeg-n5.1-latest-win64-gpl-shared-5.1/include (found version "5.1-9-g4e4cc6e56a-20220821") found components: avutil swresample swscale avcodec avformat avfilter avdevice
FFMPEG is disabled. Can't find suitable libavcodec library (minimal 54.35.0, found #define LIBAVCODEC_VERSION_MINOR 37;#define LIBAVCODEC_VERSION_MICRO 100.37.100).
FFMPEG is disabled. Can't find suitable libavformat library (minimal 54.20.4, found #define LIBAVFORMAT_VERSION_MINOR 27;#define LIBAVFORMAT_VERSION_MICRO 100.27.100).
FFMPEG is disabled. Can't find suitable libswscale library (minimal 2.1.1, found #define LIBSWSCALE_VERSION_MINOR 7;#define LIBSWSCALE_VERSION_MICRO 100.7.100).
FFMPEG libraries version check failed (minimal libav release 9.20, minimal FFMPEG release 1.1.16).
FFMPEG: NO (find_package)
avcodec: YES (#define LIBAVCODEC_VERSION_MINOR 37 #define LIBAVCODEC_VERSION_MICRO 100.37.100)
avformat: YES (#define LIBAVFORMAT_VERSION_MINOR 27 #define LIBAVFORMAT_VERSION_MICRO 100.27.100)
avutil: YES (57.28.100)
swscale: YES (#define LIBSWSCALE_VERSION_MINOR 7 #define LIBSWSCALE_VERSION_MICRO 100.7.100)
avresample: NO