from_slice_rows_cols deprecated?
sjbeskur opened this issue · comments
the following method on Mat seems to have been deprecated in the latest update:
from_slice_rows_cols
The suggested workarounds are unclear? Any guidance would be appreciated.
let img: [u16; 81] = [
10, 10, 10, 10, 10, 10, 10, 10, 10, //
10, 10, 10, 10, 10, 10, 10, 10, 10, //
10, 10, 200, 110, 10, 10, 10, 10, 10, //
10, 10, 110, 245, 10, 10, 10, 10, 10, //
10, 10, 10, 245, 10, 10, 10, 10, 10, //
10, 10, 10, 200, 10, 10, 10, 10, 10, //
10, 10, 10, 10, 10, 10, 10, 10, 10, //
10, 10, 10, 10, 10, 10, 10, 10, 10, //
10, 10, 10, 10, 10, 10, 10, 10, 10, //
];
let image_mat = opencv::core::Mat::from_slice_rows_cols(&img, 9,9).unwrap(); // no worky :(
assert_eq!(image_mat.depth(), opencv::core::CV_16U);
assert_eq!(image_mat.dims(), 2);
assert_eq!(image_mat.channels(), 1);
}
I think I forgot to mention this in the changelog, sorry! Yes, it's now been replaced by Mat::new_rows_cols_with_data with slightly different semantics:
- different order of the arguments and types (better follows OpenCV)
- returns a
BoxedRef
so aMat
that references the slice without copying it, if you need a copy call.try_clone()?
or.clone()
Thanks, I'll give it a try.
I hope it worked!