Search code examples
c#pinvokeyolo

Send an image to yolo (darknet) and receive object position and type


Is there a possibility to send an image from C# to yolo and receive all detected object positions and types.

For example on the demo image

type      | x   | y   | width | height
-------------------------------------------
bicycle   | 214 | 150 | 450   | 378
dog       | 150 | 260 | 210   | 350
truck     | 540 | 100 | 250   | 150

yolo detection result

Example code

public class Yolo
{
    public ObjectPosition[] GetObjects(Image image)
    {
        //return yolo result
    }
}

public class ObjectPosition
{
    public string Type { get; set; }
    public int X { get; set; }
    public int Y { get; set; }
    public int Width { get; set; }
    public int Height { get; set; }
}

Solution

  • Yes you can use this nuget package Alturos.Yolo for your requirement. More informations you found on the product page.

    Install dependency

    First install this two nuget packages, the first one is the logic with opencv and the c++ yolo project, the second one contains the yolo config data.

    PM> install-package Alturos.Yolo
    PM> install-package Alturos.YoloV2TinyVocData
    

    Code example

    using (var yoloWrapper = new YoloWrapper("yolov2-tiny-voc.cfg", "yolov2-tiny-voc.weights", "voc.names"))
    {
        var items = yoloWrapper.Detect("image.jpg");
    }