twistedfall / opencv-rust

Rust bindings for OpenCV 3 & 4
MIT License
1.97k stars 160 forks source link

VideoCapture::from_file is never open #238

Closed Jabulba closed 3 years ago

Jabulba commented 3 years ago

I tried opening a video file for processing using the VideoCapture::from_file but is_opened always returns false (also tried several formats for path):

let mut video_capture = videoio::VideoCapture::from_file("R:\\OBS\\2021-04-29 03-13-11\\2021-04-29 03-13-11.mkv", videoio::CAP_ANY)?;
let opened = video_capture.is_opened()?; // false

Its not the file format because the same code from python works fine:

video_capture = cv2.VideoCapture('R:\\OBS\\2021-04-29 03-13-11\\2021-04-29 03-13-11.mkv')
opened = video_capture.isOpened() # true
  1. Operating system: Window 10 pro
  2. The way you installed OpenCV: chocolatey
  3. OpenCV version: 452
  4. rustc version (rustc --version): rustc 1.51.0-nightly (1d0d76f8d 2021-01-24) and rustc 1.49.0 (e1884a8e3 2020-12-29)
  5. Attach the full output of the following command from your project directory: Builds ok, also works fine when VideoCapture is form camera
    D:\Caio\Documents\Projects\Rust\bdo_gathering_statistics_collector>set RUST_BACKTRACE=full
    D:\Caio\Documents\Projects\Rust\bdo_gathering_statistics_collector>cargo build -vv
       Fresh glob v0.3.0
       Fresh ucd-trie v0.1.3
       Fresh regex-syntax v0.6.23
       Fresh maplit v1.0.2
       Fresh dunce v1.0.1
       Fresh once_cell v1.7.2
       Fresh percent-encoding v2.1.0
       Fresh autocfg v1.0.1
       Fresh jobserver v0.1.22
       Fresh pkg-config v0.3.19
       Fresh vcpkg v0.2.12
       Fresh shlex v1.0.0
       Fresh libc v0.2.94
       Fresh pest v2.1.3
       Fresh cc v1.0.67
       Fresh memchr v2.3.4
       Fresh semver-parser v0.10.2
       Fresh winapi v0.3.9
       Fresh clang-sys v1.2.0
       Fresh aho-corasick v0.7.15
       Fresh semver v0.11.0
       Fresh wio v0.2.2
       Fresh num-traits v0.2.14
       Fresh clang v1.0.3
       Fresh regex v1.4.6
       Fresh dxgcap v0.2.4
       Fresh opencv-binding-generator v0.27.1
       Fresh captrs v0.3.1
       Fresh opencv v0.53.0
       Fresh bdo_gathering_statistics_collector v0.1.0 (D:\Caio\Documents\Projects\Rust\bdo_gathering_statistics_collector)
    Finished dev [unoptimized + debuginfo] target(s) in 0.09s
twistedfall commented 3 years ago

Are you absolutely sure that you are using the same OpenCV installation from Rust and Python?

Jabulba commented 3 years ago

Are you absolutely sure that you are using the same OpenCV installation from Rust and Python?

You are correct, python was using 4.5.1 and rust 4.5.2! But that wasn't the problem When I tried 4.5.1 with Rust the program failed to run with exit code: 0xc0000135, STATUS_DLL_NOT_FOUND because PATH and OPENCV_DIR had not been set.

I'm not sure why 4.5.2 didn't crash that way, but after setting them for 4.5.2 it worked fine!