Using the last version of OpenCV 4.5.2 with Java on Windows 10. Below is a short reproducible test case which results in
[ERROR:0] global C:\build\master_winpack-bindings-win64-vc14-static\opencv\modules\videoio\src\cap.cpp (589) cv::VideoWriter::open VIDEOIO(CV_IMAGES): raised OpenCV exception:
OpenCV(4.5.2) C:\build\master_winpack-bindings-win64-vc14-static\opencv\modules\videoio\src\cap_images.cpp:253: error: (-5:Bad argument) CAP_IMAGES: can't find starting number (in the name of file): C:/testfiles/output.avi in function 'cv::icvExtractPattern'
Here is the code:
public class OpenCVError {
public static void main(String[] args) {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
final int fourcc = VideoWriter.fourcc('m', 'j', 'p', 'g');
final double fps = 30.00;
Size frameSize = new Size(1080, 1920);
VideoWriter videoWriter = new VideoWriter("C:/testfiles/output.avi", fourcc, fps, frameSize, true);
}
}
I thought it was all self-contained. I see it has opencv_java451.dll, but I don’t see any other dll’s. What else do I need?
I’m new to OpenCV.
Here are the logs from turning on Debug
[ WARN:0] global C:\build\master_winpack-bindings-win64-vc14-static\opencv\modules\videoio\src\cap.cpp (108) cv::VideoCapture::open VIDEOIO(FFMPEG): trying capture filename=‘file:/C:/VideoSandbox/target/classes/streetsign.mov’ …
[ WARN:0] global C:\build\master_winpack-bindings-win64-vc14-static\opencv\modules\videoio\src\cap.cpp (170) cv::VideoCapture::open VIDEOIO(FFMPEG): backend is not available (plugin is missing, or can’t be loaded due dependencies or it is not compatible)
(120) cv::VideoCapture::open VIDEOIO(MSMF): created, isOpened=1
(524) cv::VideoWriter::open VIDEOIO(FFMPEG): trying writer with filename=‘C:/testfiles/output.avi’ fourcc=0x67706a6d fps=23.976 sz=1280x720 isColor=1…
(583) cv::VideoWriter::open VIDEOIO(FFMPEG): backend is not available (plugin is missing, or can’t be loaded due dependencies or it is not compatible)
(524) cv::VideoWriter::open VIDEOIO(INTEL_MFX): trying writer with filename=‘C:/testfiles/output.avi’ fourcc=0x67706a6d fps=23.976 sz=1280x720 isColor=1…
(583) cv::VideoWriter::open VIDEOIO(INTEL_MFX): backend is not available (plugin is missing, or can’t be loaded due dependencies or it is not compatible)
(524) cv::VideoWriter::open VIDEOIO(MSMF): trying writer with filename=‘C:/testfiles/output.avi’ fourcc=0x67706a6d fps=23.976 sz=1280x720 isColor=1…
cpp:253: error: (-5:Bad argument) CAP_IMAGES: can’t find starting number (in the name of file): C:/testfiles/output.avi in function ‘cv::icvExtractPattern’
(maybe pester the maven folks to pack that, too !)
that means it was compiled with ffmpeg (and this should be used for video files, but again, if the dll is missing, it will fall through trying any other backend possible, ending with the “write single images” one.)
i don’t understand this one. CV_MJPEG is the builtin, native, homegrown mjpg codec, it MUST work out-of-the-box.
‘C:/testfiles
does it exist ? (VideoWriter can’t create intermediate dirs)
Is there a more official maven distribution? I tried pointing to the dll by setting java.library.path or jna.library.path, but it didn’t seem to have any affect