aforge image comparison with UWP

回眸只為那壹抹淺笑 提交于 2019-12-13 05:36:13

问题


I'm using portable.aforge.imaging for image comparison on a UWP project. The method ProcessImage requires Bitmap type as arguments. I'm using System.Drawing to access Bitmap class, but i'm getting errors when i try to instantiate: "Bitmap does not contains a constructor that takes 1 argument"

Does regular Bitmap class is available on UWP? if yes, what am i doing wrong? if not, what alternatives do i have to use the aforge's ProcessImage for comparison?

 private void TestAForge()
    {

        ExhaustiveTemplateMatching tm = new ExhaustiveTemplateMatching(0);

        Bitmap image, template;

        //fetch Bitmaps

        image = new Bitmap("MyDir/myImage.jpg");
        template = new Bitmap("MyDir/myImage.jpg");

        // compare two images
        TemplateMatch[] matchings = tm.ProcessImage(image, template);
        // check similarity level
        TextBlock.Text = "" + matchings[0].Similarity;
        if (matchings[0].Similarity > 0.95)
        {

            // do something with quite similar images
        }
    }

回答1:


Yes, System.Drawing.Bitmap is available via the Shim.Drawing assembly for AForge on the Universal Windows Platform.

As Clemens suggests, you need to cast from a WriteableBitmap to a System.Drawing.Bitmap, apply the AForge imaging operations on the Bitmap and finally cast back to WriteableBitmap (or BitmapSource or ImageSource).

An example of where this workflow is implemented can be found in the Corner.SURF.Windows sample in the accord-samples repository, in the file MainPage.xaml.cs.



来源:https://stackoverflow.com/questions/36041653/aforge-image-comparison-with-uwp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!