BlobCounter 不支持的像素格式

BlobCounter unsupported pixel format

我收到当前异常:

UnsupportedImageFormatException: Unsupported pixel format of the source image.
AForge.Imaging.BlobCounter.BuildObjectsMap (AForge.Imaging.UnmanagedImage image)
AForge.Imaging.BlobCounterBase.ProcessImage (AForge.Imaging.UnmanagedImage image)
AForge.Imaging.BlobCounterBase.ProcessImage (System.Drawing.Imaging.BitmapData imageData)
AForge.Imaging.BlobCounterBase.ProcessImage (System.Drawing.Bitmap image)
cam.blobCounter (System.Drawing.Bitmap videoOutput, AForge.Imaging.BlobCounter bc) (at Assets/Scripts/cam.cs:127)
cam.Update () (at Assets/Scripts/cam.cs:69)

这是因为我的 blobCounter 不接受我当前的图像格式。为了解决这个问题,我使用了转换方法:Bitmap yellowClone = AForge.Imaging.Image.Clone(originalBm, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

但我仍然遇到错误(尽管尝试了所有可用的格式)。

对于上下文,这是我的代码,其中 originalFeedTexture 是网络摄像头供稿:

byte[] bytes = originalFeedTexture.EncodeToJPG();
        using (var ms = new MemoryStream(bytes))
        {
            originalBm = new Bitmap(ms);
        }

        Bitmap yellowClone = AForge.Imaging.Image.Clone(originalBm, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

yellow = new Bitmap(yellowClone);
yellowFilter(yellow);
BlobCounter bc = new BlobCounter();
        blobCounter(yellowClone, bc);
        Rectangle[] rects = bc.GetObjectsRectangles();

        if (bc.ObjectsCount >= 1)
        {
            Debug.Log("Swedes");
        }

我的 yellowFilter 函数:

 void yellowFilter(Bitmap videoOutput)
    {
        HSLFiltering yellowHslFilter = new HSLFiltering();
        yellowHslFilter.Hue = new IntRange(40, 70);
        yellowHslFilter.Saturation = new DoubleRange(0.3f, 0.9f);
        yellowHslFilter.Luminance = new DoubleRange(0.3f, 0.8f);

        yellowHslFilter.ApplyInPlace(videoOutput);
    }

我的 blobCounter 函数:

void blobCounter(Bitmap videoOutput, BlobCounter bc)
    {
        bc.ObjectsOrder = ObjectsOrder.Size;
        bc.ProcessImage(videoOutput);
    }

编辑:正如我忘记提及的,错误在以下行:blobCounter(yellowClone, bc);

我通过更改 AForge.net 的版本号解决了这个问题。我测试了多个版本,似乎使用这个确切的代码时,问题只出现在 2.0.0 版本上。