Using bitmaps for Image-processing with Unity

I’m trying to make AForge.net work with Unity, but it became an issue that AForge needs its images to be Bitmap before I can modify them using their methods, when Unity3D doesn’t really support System.Drawing.Bitmap properly.

Is there something I can do, maybe a shared variable both understand, or am I forced to create constant convertions between Texture2D and Bitmap?

In case I’m on the wrong path regarding my issue, here’s my class:

 void Start()
    {
        webCam = new WebCamTexture();
        webCam.Play();
        originalFeedTexture = new Texture2D(webCam.width, webCam.height);
        originalFeedTexture.SetPixels(webCam.GetPixels());
        originalFeedTexture.Apply();
    }

    // Update is called once per frame
    GameObject blueDisplay;
    Bitmap yellowClone;
    void Update()
    {
        GetComponent<Renderer>().material.mainTexture = webCam;
        byte[] bytes = originalFeedTexture.EncodeToJPG();
        using (var ms = new MemoryStream(bytes))
        {
            yellowClone = AForge.Imaging.Image.Clone(new Bitmap(ms), System.Drawing.Imaging.PixelFormat.Format32bppArgb);
        }

        HSLFiltering hsl = new HSLFiltering();
        hsl.Hue = new IntRange(200, 240);
        hsl.Saturation = new Range(0.2f, 0.5f);
        hsl.Luminance = new Range(0.3f, 0.6f);

        hsl.ApplyInPlace(yellowClone);

        BlobCounter bc = new BlobCounter();
        bc.MinHeight = 50;
        bc.MinWidth = 50;
        bc.ObjectsOrder = ObjectsOrder.Size;
        bc.ProcessImage(yellowClone);
}

I tested for both if it recognized objects or colors in the image, but despite outputting no error this code does not work.

I know the newest version of AForge usies .NET 4, so I’m using AForge 2.0.0, and I haven’t received any direct errors, except this straight up not working.

Hi, Did you find a solution for this problem.

If yes please let me know. I am going through same issue.

Thankyou