-
Notifications
You must be signed in to change notification settings - Fork 6
fix incorrect ImageFrame memory ownership handling #11
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
Conversation
sr229
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you would want to copy this pointer before you want to pass this to .NET. Has this been tested and memory profiled?
Speykious
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm really not sure of this change.
If anything, providing a function to create a new image frame with a copied pixel data that MediaPipe owns is a very good idea - however, removing the option to move an existing pixel data? I don't know.
|
Do you know if it's possible to leave a |
Head branch was pushed to by a user without write access
Co-authored-by: Speykious <speykious@gmail.com>
I'm not exactly familiar with C#, but perhaps something like |
|
But tbh I think that's beside the point. If |
It is indeed easier to copy the pixel data, but definitely not more performant. I would prefer, as I said, to have both options available, so going that extra mile to avoid one more O(n) operation is fine by me. I'm familiar with the notion of ownership and borrowing thanks to Rust, so something we can do is to add a property on |
sr229
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering we're aiming for C99-like ABI compatibility, this is alright. ImageFrame* is easier to interpolate than unique_ptr.
Speykious
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll allow the replacement. I think the only way to make the native side own a pixel data from the C# side is by creating an unmanaged array, which requires to either make our own class or to use the UnmanagedArray library, which is kind of a bit of work compared to normal byte[]s. Not to mention that I think it wouldn't work well with libraries such as SeeShark where we already don't have any problem in the first place because of how we deal with the memory, but where it could still very likely bite us back in the future.
Just change the name of the function and we good :)
Co-authored-by: Speykious <speykious@gmail.com>
Speykious
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I approb
|
Thanks for your contributions! Next time, we encourage you to sign your commits so we can authenticate it's really yours to prevent commit masquerading. |
See cosyneco/MediaPipe.NET#29