Fix Mat/UMat lifetime errors in tests and examples
MODIFY
examples/opencl.rs
examples/opencl.rs
@@ -53,7 +53,8 @@ fn main() -> Result<()> {
println!("{:#?}", start.elapsed());
if opencl_use {
println!("Timing OpenCL implementation... ");
- let img = imgcodecs::imread(&img_file, imgcodecs::IMREAD_COLOR)?.get_umat(ACCESS_READ, UMatUsageFlags::USAGE_DEFAULT)?;
+ let mat = imgcodecs::imread(&img_file, imgcodecs::IMREAD_COLOR)?;
+ let img = mat.get_umat(ACCESS_READ, UMatUsageFlags::USAGE_DEFAULT)?;
let start = time::Instant::now();
for _ in 0..ITERATIONS {
let mut gray = UMat::new(UMatUsageFlags::USAGE_DEFAULT)?;

MODIFY
tests/input_output_array.rs
tests/input_output_array.rs
@@ -32,7 +32,8 @@ fn input_output_array_types() -> Result<()> {
fn input_output_array() -> Result<()> {
{
let mat_expr = Mat::ones(1, 3, u8::typ())?;
- let umat = Mat::new_rows_cols_with_default(1, 3, u8::typ(), Scalar::all(3.))?.get_umat(ACCESS_READ, UMatUsageFlags::USAGE_DEFAULT)?;
+ let mat = Mat::new_rows_cols_with_default(1, 3, u8::typ(), Scalar::all(3.))?;
+ let umat = mat.get_umat(ACCESS_READ, UMatUsageFlags::USAGE_DEFAULT)?;
{
let mut trg = VectorOfu8::new();
core::add(&mat_expr, &umat, &mut trg, &core::no_array()?, -1)?;

MODIFY
tests/umat.rs
tests/umat.rs
@@ -36,7 +36,8 @@ fn umat_to_mat() -> Result<()> {
vec.push(1);
vec.push(2);
vec.push(3);
- let umat = Mat::from_exact_iter(vec.into_iter())?.get_umat(ACCESS_READ, UMatUsageFlags::USAGE_DEFAULT)?;
+ let mat = Mat::from_exact_iter(vec.into_iter())?;
+ let umat = mat.get_umat(ACCESS_READ, UMatUsageFlags::USAGE_DEFAULT)?;
assert_eq!(3, umat.rows());
assert_eq!(1, umat.cols());
assert_eq!(i32::typ(), umat.typ()?);
@@ -48,7 +49,8 @@ fn umat_to_mat() -> Result<()> {
{
let vec: Vec<i32> = vec![1, 2, 3];
- let umat = Mat::from_exact_iter(vec.into_iter())?.get_umat(ACCESS_READ, UMatUsageFlags::USAGE_DEFAULT)?;
+ let mat = Mat::from_exact_iter(vec.into_iter())?;
+ let umat = mat.get_umat(ACCESS_READ, UMatUsageFlags::USAGE_DEFAULT)?;
assert_eq!(3, umat.rows());
assert_eq!(1, umat.cols());
assert_eq!(i32::typ(), umat.typ()?);
@@ -94,7 +96,8 @@ fn umat_continuous() -> Result<()> {
vec![7., 8., 9.],
];
- let umat = Mat::from_slice_2d(&s)?.get_umat(ACCESS_READ, UMatUsageFlags::USAGE_DEFAULT)?;
+ let mat = Mat::from_slice_2d(&s)?;
+ let umat = mat.get_umat(ACCESS_READ, UMatUsageFlags::USAGE_DEFAULT)?;
{
let sub_umat_non_cont = UMat::roi(&umat, Rect::new(1, 1, 2, 2))?;

Fix Mat/UMat lifetime errors in tests and examples