Skip to content
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

Load Image #44

Closed
Elliot8212 opened this issue Mar 8, 2024 · 2 comments
Closed

Load Image #44

Elliot8212 opened this issue Mar 8, 2024 · 2 comments

Comments

@Elliot8212
Copy link

Cannot use Image or Bitmap, it necessary need to be a path.

@bobezlolz
Copy link

bobezlolz commented Mar 9, 2024

you can convert the bitmap/image to a byte array and pass it to the predictor

static byte[] ToByteArray(System.Drawing.Image imageIn, System.Drawing.Imaging.ImageFormat fmt)
{
    if (imageIn != null)
    {
        using (MemoryStream ms = new MemoryStream())
        {
            imageIn.Save(ms, fmt);
            return ms.ToArray();
        }
    }

    return new byte[] { };
}

var result = await predictor.DetectAsync(ToByteArray(image, System.Drawing.Imaging.ImageFormat.Png));

@dme-compunet
Copy link
Owner

Bitmap is only in Windows, you can use the code in the comment above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants