-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mat should have non-owning counterpart #110
Comments
IIRC Checking array length cannot be done before Mat is constructed because different CvType require different buffer size. Only |
Oh, I see, so right now it is just undefined behavior if your buffer is the wrong size. I will create the appropriate unit tests then and change this to get back a Result. |
There are some hepers class (CResult, in instance) that helps you to convert C++ Exception into rust Result. See Lines 68 to 87 in b602103
|
In the documentation I found
from_buffer
. This method indicates that it is possible to actually invoke a double-free without doing anything. Additionally, the source offrom_buffer
doesn't check to see if the slice is big enough! This means that undefined behavior and segfaults could happen.To fix this, we should create a
SliceMat
. This would be a cv::Mat that does not own its data. It would be templated with a lifetime param <'a> so that when it is created from a slice it wont be allowed to outlive the slice due to the Rust borrow checker. We then also need to make a newtype wrapper around just thecv::Mat
pointer that opencv has and move all the shared functionality we have into there. We can call this wrapperMatRef
. We thenimpl Deref<MatRef> for Mat
andimpl Deref<MatRef> for SliceMat
.The text was updated successfully, but these errors were encountered: