Alturos.Yolo icon indicating copy to clipboard operation
Alturos.Yolo copied to clipboard

Question about Converting Bitmap to imageData

Open futureflsl opened this issue 3 years ago • 2 comments

This program make it a lot easier for me to incorporate the yolov3 tiny into my c# project. Thanks a lot. My images from video is in Bitmap format. What is the best way to convert Bitmap image to imageData to be used in "yoloWrapper.Detect(imageData);". Do you have a function that use Bitmap or Image as input? I notice the function in yoloWrapper.cs: [DllImport(YoloLibraryGpu, EntryPoint = "detect_mat")] internal static extern int DetectImageGpu(IntPtr pArray, int nSize, ref BboxContainer container);

futureflsl avatar Jul 26 '21 14:07 futureflsl

Hey, I'm a noob here but may be it could help you. It's possible to provide image data as byte array. I save image into memory stream and convert it into array with ToArray().

subsneer avatar Jul 31 '21 14:07 subsneer

Make bitmap to image byte array using memorystream

Here is sample.

bitmap image;  //here you should put your bitmap image
byte[] imgByteArray;

using (var stream = new MemoryStream())
{
    image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
    imgByteArray = stream.ToArray();
}

var items = yoloWrapper.Detect(imgByteArray);

KoreanPro avatar Aug 20 '21 08:08 KoreanPro