error: (-215:Assertion failed) !_img.empty() in function 'imwrite [closed]
I'm facing this issue when using opencv libraries
> terminate called after throwing an
> instance of 'cv::Exception' what():
> OpenCV(4.1.2)
> /home/candrew/opencv-test/opencv/modules/imgcodecs/src/loadsave.cpp:715:
> error: (-215:Assertion failed)
> !_img.empty() in function 'imwrite
Can i know what is it that i'm missing? could it be my below configuration is missing some build parameters?
System information (version)
OpenCV => 4.1.2
Operating System / Platform => Clear Linux OS
Compiler => 9.2.1
Steps to reproduce
Compiled opencv on my machine with below configuration:
-- General configuration for OpenCV 4.1.2 =====================================
-- Version control: 4.1.2
--
-- Platform:
-- Timestamp: 2019-12-16T09:20:16Z
-- Host: Linux 5.3.5-847.native x86_64
-- CMake: 3.15.4
-- CMake generator: Unix Makefiles
-- CMake build tool: /usr/bin/gmake
-- Configuration: ReleaseWithDebInfo
--
-- CPU/HW features:
-- Baseline: SSE SSE2 SSE3 SSSE3 SSE4_1 POPCNT SSE4_2
-- requested: SSE3
-- required: SSE4_2
-- Dispatched code generation: AVX AVX2 AVX512_SKX
-- AVX (5 files): + AVX
-- AVX2 (30 files): + FP16 FMA3 AVX AVX2
-- AVX512_SKX (6 files): + FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
--
-- C/C++:
-- Built as dynamic libs?: YES
-- C++ Compiler: /usr/lib64/ccache/bin/g++ (ver 9.2.1)
-- C++ flags (Release): -g -O3 -feliminate-unused-debug-types -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=32 -Wformat -Wformat-security -m64 -fasynchronous-unwind-tables -Wp,-D_REENTRANT -ftree-loop-distribute-patterns -Wl,-z -Wl,now -Wl,-z -Wl,relro -fno-semantic-interposition -ffat-lto-objects -fno-trapping-math -Wl,-sort-common -Wl,--enable-new-dtags -mtune=skylake -fvisibility-inlines-hidden -Wl,--enable-new-dtags -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 -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -fopenmp -O3 -DNDEBUG -DNDEBUG
-- C++ flags (Debug): -g -O3 -feliminate-unused-debug-types -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=32 -Wformat -Wformat-security -m64 -fasynchronous-unwind-tables -Wp,-D_REENTRANT -ftree-loop-distribute-patterns -Wl,-z -Wl,now -Wl,-z -Wl,relro -fno-semantic-interposition -ffat-lto-objects -fno-trapping-math -Wl,-sort-common -Wl,--enable-new-dtags -mtune=skylake -fvisibility-inlines-hidden -Wl,--enable-new-dtags -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 -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -fopenmp -g -DDEBUG -D_DEBUG
-- C Compiler: /usr/lib64/ccache/bin/gcc
-- C flags (Release): -g -O3 -feliminate-unused-debug-types -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=32 -Wformat -Wformat-security -m64 -fasynchronous-unwind-tables -Wp,-D_REENTRANT -ftree-loop-distribute-patterns -Wl,-z -Wl,now -Wl,-z -Wl,relro -fno-semantic-interposition -ffat-lto-objects -fno-trapping-math -Wl,-sort-common -Wl,--enable-new-dtags -mtune=skylake -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 -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -fopenmp -O3 -DNDEBUG -DNDEBUG
-- C flags (Debug): -g -O3 -feliminate-unused-debug-types -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=32 -Wformat -Wformat-security -m64 -fasynchronous-unwind-tables -Wp,-D_REENTRANT -ftree-loop-distribute-patterns -Wl,-z -Wl,now ...
and the code, leading to your error ?
(it'S probably something very simple, like a wrong file path)
Sample code using python, the files are present on the same folder as this py code
it's like i thought, the image you try to write is invalid
please check the
success
value (don't throw it away, like all python noobs do!).if it is false, you have to break out of the loop (movie's over). also
vidObj.isOpened()