twistedfall / opencv-rust

Rust bindings for OpenCV 3 & 4
MIT License
1.86k stars 144 forks source link

Can not open file by videoio::VideoCapture::from_file when chinese characters in filename on Windows 10 #544

Open ayang opened 4 months ago

ayang commented 4 months ago
  1. Operating system Windows 10
  2. I installed Opencv by vcpkg
  3. OpenCV version 4.8.0
  4. rustc version rustc 1.75.0 (82e1608df 2023-12-21)
    let mut cap = videoio::VideoCapture::from_file("d:\\中文文件名.mp4", videoio::CAP_ANY)?;
    let opened = videoio::VideoCapture::is_opened(&cap)?; 

    Then the opened == false

The codes can be compiled, but can't open the file, if I change the filename to an english name, it will be ok. I guess it's an encoding problem.

twistedfall commented 4 months ago

This can happen if your filesystem encoding is not utf-8. I'm going to try to investigate this, maybe there is a solution for this. Thanks for reporting!

hengkx commented 2 months ago

imgcodecs::imread win11 same error