I am trying Rust (ver 1.4.0) these days, and coding with opencv-rust library.
这些天我正在尝试Rust(版本1.4.0),并使用opencv-rust库进行编码。
I wrote some code like this.
我写了一些像这样的代码。
extern crate opencv;
use self::opencv::highgui;
use self::opencv::core::Mat;
fn main() {
load("image/test4.jpg");
}
fn load(path: &str) {
let src: Mat = highgui::imread(path, 1).unwrap();
if src.empty().unwrap() {
println!("Img load error");
}
else {
println!("Img load success");
}
}
When I run cargo run
it shows Img load error
.
当我运行货物运行它显示Img负载错误。
However, when I added a println!
at first line in load
function like
但是,当我添加了println!在加载函数的第一行就像
fn load(path: &str) {
println!("whatever");
let src: Mat = highgui::imread(path, 1).unwrap();
if src.empty().unwrap() {
println!("Img load error");
}
else {
println!("Img load success");
}
}
It shows Img load success
.
它显示了Img加载成功。
But when I change it to other code like let a: i32 = 1;
, it shows Img load error
again.
但当我将其更改为其他代码时,例如让a:i32 = 1;,它再次显示Img加载错误。
I have no idea what's going on.
我不知道是怎么回事。
System info:
- OS: Manjaro Linux
- Kernel: 4.3.0
操作系统:Manjaro Linux