Closed svenne-juul closed 1 year ago
Hi, what is the actual error you are getting as the result of your program?
Currently I get: 'thread 'main' panicked at 'Unable to open video file!2', src\main.rs:20:9 Ultimately I am trying to get get 'let frame_read = videoio::VideoCapture::read(&mut cam, &mut frame)?; ' to return a frame from the video, but I don't get that far because I can't get ' let opened_file = videoio::VideoCapture::open_file(&mut cam, &file_name, videoio::CAP_ANY)?;' to return anything other than that 'opened_file' is false.
It is not obvious to me why we have both the 'videoio::VideoCapture::from_file' and 'videoio::VideoCapture::open_file' functions that take the same parameters. In the openvc - python integration the equivalent function only requires the file name but not the 'api_preference'.
It is entirely possible that I am using the wrong function(s), but I have also tried only using 'videoio::VideoCapture::from_file' without getting to being able to read a frame.
I very much appreciate you looking into this and I hope I am not wasting your time.
Today I worked with a co-worker running apple system. The logic that failed (and still is failing) on my system worked on his system. And a similar issue I am facing when writing video also worked without problems on his system.
I think this suggests that there is something wrong on my system, but of course I don't have the foggiest idea what it is.
It is not obvious to me why we have both the 'videoio::VideoCapture::from_file' and 'videoio::VideoCapture::open_file' functions that take the same parameters.
The former constructs the VideoCapture
instance, the latter operates on the already existing instance.
It is entirely possible that I am using the wrong function(s)
Those seem to be the right functions for what you're trying to do
python integration the equivalent function only requires the file name but not the 'api_preference'.
Rust doesn't have a notion of default values for function parameters so it's not trivial to translate that logic to the bindings.
I think this suggests that there is something wrong on my system, but of course I don't have the foggiest idea what it is.
From the looks of it it may be that your OpenCV (the C++ library) is built without the support for necessary codecs.
Thank you for your comments and suggestion. I will try another full reinstall (number 3) with the hope of getting the codecs 'right'
Regards
On Sat, Oct 1, 2022, 3:33 AM twistedfall @.***> wrote:
It is not obvious to me why we have both the 'videoio::VideoCapture::from_file' and 'videoio::VideoCapture::open_file' functions that take the same parameters.
The former constructs the VideoCapture instance, the latter operates on the already existing instance.
It is entirely possible that I am using the wrong function(s)
Those seem to be the right functions for what you're trying to do
python integration the equivalent function only requires the file name but not the 'api_preference'.
Rust doesn't have a notion of default values for function parameters so it's not trivial to translate that logic to the bindings.
I think this suggests that there is something wrong on my system, but of course I don't have the foggiest idea what it is.
From the looks of it it may be that your OpenCV (the C++ library) is built without the support for necessary codecs.
— Reply to this email directly, view it on GitHub https://github.com/twistedfall/opencv-rust/issues/359#issuecomment-1264277481, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2S6DL2V3NZXIURLBHZ4N3LWA7SOBANCNFSM566N4RRA . You are receiving this because you authored the thread.Message ID: @.***>
Thank you.
On Sun, Jan 15, 2023, 4:36 AM twistedfall @.***> wrote:
Closed #359 https://github.com/twistedfall/opencv-rust/issues/359 as completed.
— Reply to this email directly, view it on GitHub https://github.com/twistedfall/opencv-rust/issues/359#event-8229134496, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2S6DL4MOYKMZDWY3TNOZPTWSPAJXANCNFSM566N4RRA . You are receiving this because you authored the thread.Message ID: @.***>
Hi everyone!
I had the same issue on Windows which I didn't have on MacOs and I managed to work. As @twistedfall wrote:
From the looks of it it may be that your OpenCV (the C++ library) is built without the support for necessary codecs.
this is the main issue. These are the steps that helped me to solve it:
opencv_videoio_ffmpeg470_64.dll
from C:\where_you_have_installed_opencv\opencv\build\x64\vc16\bin
like I found here, do not need to rename it like they mention:cargo build
.You are good to go to use opencv::videioio::VideoCapture
!
I had another issue with writing with opencv::videoio::VideoWriter
on Windows, here is the message:
Failed to load OpenH264 library: openh264-1.8.0-win64.dll
to solve, the same steps as before:
target/debug
into your Rust project;cargo build
.Hope this can help someone make it work on Windows! And thank you @twistedfall for the amazing work.
All the best
Awesome Danilo and twistedfall,
I will try this out. I ended up getting a mac for my rust/opencv development for this reason.
Regards Svenne
On Fri, May 12, 2023 at 5:16 AM Danilo Santitto @.***> wrote:
Hi everyone!
I had the same issue on Windows which I didn't have on MacOs and I managed to work. As @twistedfall https://github.com/twistedfall wrote:
From the looks of it it may be that your OpenCV (the C++ library) is built without the support for necessary codecs.
this is the main issue. These are the steps that helped me to solve it:
- Copied the file opencv_videoio_ffmpeg470_64.dll from C:\where_you_have_installed_opencv\opencv\build\x64\vc16\bin like I found here https://stackoverflow.com/questions/11699298/opencv-2-4-videocapture-not-working-on-windows, do not need to rename it like they mention:
- run cargo build.
You are good to go to use opencv::videioio::VideoCapture!
I had another issue with writing with opencv::videoio::VideoWriter on Windows, here is the message:
Failed to load OpenH264 library: openh264-1.8.0-win64.dll
to solve, the same steps as before:
- you need to go here https://github.com/cisco/openh264/releases and download the correct dll you require;
- unzip it and paste it into target/debug into your Rust project;
- run cargo build.
Hope this can help someone make it work on Windows! And thank you @twistedfall https://github.com/twistedfall for the amazing work.
All the best
— Reply to this email directly, view it on GitHub https://github.com/twistedfall/opencv-rust/issues/359#issuecomment-1545438136, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2S6DL7SC6DL64MIJBH6NRDXFX5YHANCNFSM566N4RRA . You are receiving this because you authored the thread.Message ID: @.***>
Hi everyone!
I had the same issue on Windows which I didn't have on MacOs and I managed to work. As @twistedfall wrote:
From the looks of it it may be that your OpenCV (the C++ library) is built without the support for necessary codecs.
this is the main issue. These are the steps that helped me to solve it:
1. Copied the file `opencv_videoio_ffmpeg470_64.dll` from `C:\where_you_have_installed_opencv\opencv\build\x64\vc16\bin` like I found [here](https://stackoverflow.com/questions/11699298/opencv-2-4-videocapture-not-working-on-windows), do not need to rename it like they mention:
2. run `cargo build`.
You are good to go to use
opencv::videioio::VideoCapture
!I had another issue with writing with
opencv::videoio::VideoWriter
on Windows, here is the message:Failed to load OpenH264 library: openh264-1.8.0-win64.dll
to solve, the same steps as before:
1. you need to go [here](https://github.com/cisco/openh264/releases) and download the correct dll you require; 2. unzip it and paste it into `target/debug` into your Rust project; 3. run `cargo build`.
Hope this can help someone make it work on Windows! And thank you @twistedfall for the amazing work.
All the best
Thank you very much, this worked for me!
I have worked through a good example of how videoio::VideoCapture::new(..) works with live video but I don't seem to be able to get input from an existing mp4 video file to work.
The following lines contain the issue (full logic below):
Operating system: Edition Windows 10 Pro Version 21H2 Installed on 8/10/2022 OS build 19044.1889 Experience Windows Feature Experience Pack 120.2212.4180.0
Installation Installed using the approach relying on chocolatey described under 'Windows package'. I believe the install works correctly as many other opencv-related sample programs work just fine.
RUST_BACKTRACE=full cargo build -vv
PS C:\Users\svenn\rust\pxlit_opencv> cargo build -vv Fresh autocfg v1.1.0 Fresh cfg-if v1.0.0 Fresh once_cell v1.13.0 Fresh scopeguard v1.1.0 Fresh unicode-ident v1.0.3 Fresh glob v0.3.0 Fresh num_cpus v1.13.1 Fresh adler32 v1.2.0 Fresh adler v1.0.2 Fresh regex-syntax v0.6.27 Fresh jobserver v0.1.24 Fresh maplit v1.0.2 Fresh either v1.8.0 Fresh percent-encoding v2.1.0 Fresh dunce v1.0.2 Fresh vcpkg v0.2.15 Fresh futures-sink v0.3.23 Fresh weezl v0.1.7 Fresh pkg-config v0.3.25 Fresh shlex v1.1.0 Fresh bit_field v0.10.1 Fresh half v1.8.2 Fresh bitflags v1.3.2 Fresh lebe v0.5.2 Fresh rawpointer v0.2.1 Fresh smallvec v1.9.0 Fresh color_quant v1.1.0 Fresh bytemuck v1.12.1 Fresh byteorder v1.4.3 Fresh scoped_threadpool v0.1.9 Fresh getrandom v0.2.7 Fresh threadpool v1.8.1 Fresh deflate v1.0.0 Fresh inflate v0.4.5 Fresh miniz_oxide v0.5.3 Fresh cc v1.0.73 Fresh matrixmultiply v0.3.2 Fresh gif v0.11.4 Fresh crossbeam-utils v0.8.11 Fresh proc-macro2 v1.0.43 Fresh winapi v0.3.9 Fresh nanorand v0.7.0 Fresh libc v0.2.129 Fresh memchr v2.5.0 Fresh crc32fast v1.3.2 Fresh semver v1.0.13 Fresh futures-core v0.3.23 Fresh memoffset v0.6.5 Fresh num-traits v0.2.15 Fresh anyhow v1.0.62 Fresh crossbeam-channel v0.5.6 Fresh lock_api v0.4.7 Fresh quote v1.0.21 Fresh libloading v0.7.3 Fresh aho-corasick v0.7.18 Fresh flate2 v1.0.24 Fresh png v0.17.5 Fresh crossbeam-epoch v0.9.10 Fresh num-integer v0.1.45 Fresh num-complex v0.4.2 Fresh syn v1.0.99 Fresh spin v0.9.4 Fresh clang-sys v1.3.3 Fresh regex v1.6.0 Fresh crossbeam-deque v0.8.2 Fresh pin-project-internal v1.0.12 Fresh num-rational v0.4.1 Fresh ndarray v0.15.6 Fresh rayon-core v1.9.3 Fresh clang v2.0.0 Fresh pin-project v1.0.12 Fresh rayon v1.5.3 Fresh opencv-binding-generator v0.45.0 Fresh jpeg-decoder v0.2.6 Fresh flume v0.10.14 Fresh tiff v0.7.3 Fresh exr v1.4.2 Fresh image v0.24.3 Fresh opencv v0.66.0 Compiling pxlit_opencv v0.1.0 (C:\Users\svenn\rust\pxlit_opencv) Running
set CARGO=\\?\C:\Users\svenn\.rustup\toolchains\stable-x86_64-pc-windows-msvc\bin\cargo.exe&& set CARGO_BIN_NAME=pxlit_opencv&& set CARGO_CRATE_NAME=pxlit_opencv&& set CARGO_MANIFEST_DIR=C:\Users\svenn\rust\pxlit_opencv&& set CARGO_PKG_AUTHORS=""&& set CARGO_PKG_DESCRIPTION=""&& set CARGO_PKG_HOMEPAGE=""&& set CARGO_PKG_LICENSE=""&& set CARGO_PKG_LICENSE_FILE=""&& set CARGO_PKG_NAME=pxlit_opencv&& set CARGO_PKG_REPOSITORY=""&& set CARGO_PKG_VERSION=0.1.0&& set CARGO_PKG_VERSION_MAJOR=0&& set CARGO_PKG_VERSION_MINOR=1&& set CARGO_PKG_VERSION_PATCH=0&& set CARGO_PKG_VERSION_PRE=""&& set CARGO_PRIMARY_PACKAGE=1&& set PATH="C:\Users\svenn\rust\pxlit_opencv\target\debug\deps;C:\Users\svenn\.rustup\toolchains\stable-x86_64-pc-windows-msvc\bin;C:\Users\svenn\.rustup\toolchains\stable-x86_64-pc-windows-msvc\bin;C:\Program Files\Dell\DW WLAN Card;;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\Microsoft VS Code\bin;C:\ProgramData\chocolatey\bin;C:\Program Files\LLVM\bin;C:\Users\svenn\.cargo\bin;C:\Users\svenn\AppData\Local\Microsoft\WindowsApps;"&& rustc --crate-name pxlit_opencv --edition=2021 src\main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=a3b9fd79ddabc8b9 --out-dir C:\Users\svenn\rust\pxlit_opencv\target\debug\deps -C incremental=C:\Users\svenn\rust\pxlit_opencv\target\debug\incremental -L dependency=C:\Users\svenn\rust\pxlit_opencv\target\debug\deps --extern anyhow=C:\Users\svenn\rust\pxlit_opencv\target\debug\deps\libanyhow-93e115d4e8bb996a.rlib --extern image=C:\Users\svenn\rust\pxlit_opencv\target\debug\deps\libimage-bd9c5d2de8a0ecf7.rlib --extern ndarray=C:\Users\svenn\rust\pxlit_opencv\target\debug\deps\libndarray-6af201cef50c369f.rlib --extern opencv=C:\Users\svenn\rust\pxlit_opencv\target\debug\deps\libopencv-984bef83365d79f6.rlib -L native=C:\Users\svenn\rust\pxlit_opencv\target\debug\build\opencv-e0385181a2a64e23\out -L C:\tools\opencv\build\x64\vc15\lib
Finished dev [unoptimized + debuginfo] target(s) in 1.56sThe video file I am trying to read from
https://user-images.githubusercontent.com/111534511/185486044-3144b219-87ad-4d12-85b0-51bf9194bfd5.mp4