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
[FEATURE] - Support use of ReadOnly/Span in APIs #923
Comments
Take a look at EmguExtensions.cs search for Span |
@sn4k3 - I'm trying to call |
Ok for that is required the implementation in the method. |
Are you trying to call Imdecode on a Span? The Imdecode function expect a pointer to byte. I don't think you can get a pointer from Span based on the documentation: If you can't get a pointer from a Span, you will need to copy it to a buffer that can give you a pointer. |
That might not be the case - my original code was using
On a You can get a pointer via use of the unsafe
{
int[] numbers = [10, 20, 30, 40, 50];
Span<int> interior = numbers.AsSpan()[1..^1];
fixed (int* p = interior)
{
for (int i = 0; i < interior.Length; i++)
{
Console.Write(p[i]);
}
// output: 203040
}
} |
Describe the feature
I'm writing a program that receives images from a connected device. As part of that, I'm using the new System.IO.Pipelines, which gives me some combination of;
Unfortunately, it's not possible to get the underlying byte array that these types use for actual backing memory (if any such exists), meaning that in order to call, say,
imdecode
I'm required to copy to an array for the decoding to happen.It would be helpful if instead most of the available APIs supported passing Span types.
An additional side option here is, if OpenCV allows access, to wrap the native memory allocated by OpenCV itself, and implement the
MemoryManager
API.The text was updated successfully, but these errors were encountered: