2

ドキュメントの画像とロゴ タイプまたは別の画像を比較して、ロゴがドキュメントに含まれているかどうかを確認したいと考えています。

これを行うアプリケーションは、ASP.NET MVC 3 と C# を使用します。

さらに検索した後、AForgeを使用するBitmapの拡張機能を備えたソリューションを見つけました:

public static class BitmapExtensions
{
    /// <summary>
    /// See if bmp is contained in template with a small margin of error.
    /// </summary>
    /// <param name="template">The Bitmap that might contain.</param>
    /// <param name="bmp">The Bitmap that might be contained in.</param>        
    /// <returns>You guess!</returns>
    public static bool Contains(this Bitmap template, Bitmap bmp)
    {
        const Int32 divisor = 4;
        const Int32 epsilon = 10;

        ExhaustiveTemplateMatching etm = new ExhaustiveTemplateMatching(0.9f);

        TemplateMatch[] tm = etm.ProcessImage(
            new ResizeNearestNeighbor(template.Width / divisor, template.Height / divisor).Apply(template),
            new ResizeNearestNeighbor(bmp.Width / divisor, bmp.Height / divisor).Apply(bmp)
            );

        if (tm.Length == 1)
        {
            Rectangle tempRect = tm[0].Rectangle;

            if (Math.Abs(bmp.Width / divisor - tempRect.Width) < epsilon
                &&
                Math.Abs(bmp.Height / divisor - tempRect.Height) < epsilon)
            {
                return true;
            }
        }

        return false;
    }
}
4

1 に答える 1

0

テンプレートマッチング機能を使いたいと思います。そのためにopencvを使用することをお勧めします。これはこの質問に似ています

于 2013-02-18T16:52:53.163 に答える