Closed Dirleye closed 5 months ago
If you need an independent Mat
then something like this should work:
let cropped = target_mat.roi(region)?.try_clone()?;
let target_mat = cropped;
Ah so cloning into a new Mat is definitely needed. That is simpler though so thank you.
Yeah, I don't think that OpenCV supports in-place crop at all, so one or the other form of copying is required.
How would you go about cropping a Mat from a Rect?
The simplest way I can think of currently is by creating a whole new Mat and moving it back over (I haven't actually tested this and could be completely misunderstanding what
assign_to_def()
does):But that feels like too much work for something this simple. Am I missing something really obvious?
Thanks for any help.