与UWP进行aforge图像比较 [英] aforge image comparison with UWP

查看:119
本文介绍了与UWP进行aforge图像比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Portable.aforge.imaging在UWP项目上进行图像比较.方法ProcessImage需要位图类型作为参数.我正在使用System.Drawing访问Bitmap类,但是在尝试实例化时出现错误:位图不包含带有1个参数的构造函数"

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"

在UWP上是否可以使用常规的位图类?如果是,我在做什么错?如果没有,我必须使用aforge的ProcessImage进行比较吗?

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
        }
    }

推荐答案

是的,可以通过 AForge 上的 Shim.Drawing 组件使用System.Drawing.Bitmap. >通用Windows平台.

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

正如 Clemens 所建议的,您需要从WriteableBitmap投射到System.Drawing.Bitmap,在Bitmap上应用 AForge 成像操作,最后进行投射到WriteableBitmap(或BitmapSourceImageSource).

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).

可以在Corner.SURF.Windows 示例中找到实现此工作流的示例. rel ="nofollow">一致示例存储库,位于文件

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.

这篇关于与UWP进行aforge图像比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆