【问题标题】:Template Matching On Images C#图像模板匹配 C#
【发布时间】:2016-09-19 23:56:40
【问题描述】:

假设我有一张图片,我想在我的屏幕上扫描它(截取屏幕截图并在那里查看)。 有谁知道我应该研究什么科目以及在哪里研究? 非常感谢对我的算法的任何帮助。

【问题讨论】:

    标签: c# template-matching


    【解决方案1】:

    就我而言,EmguCV 库给了我最好的结果。这是我如何使它工作的一些示例代码:

            Image<Bgr, byte> Image1 = new Image<Bgr, byte>(Properties.Resources.Image1); //Your first image
            Image<Bgr, byte> Image2 = new Image<Bgr, byte>(Properties.Resources.Image2); //Your second image
    
            double Threshold = 0.8; //set it to a decimal value between 0 and 1.00, 1.00 meaning that the images must be identical
    
            Image<Gray, float> Matches = Image1.MatchTemplate(Image2, TemplateMatchingType.CcoeffNormed);
    
            for (int y = 0; y < Matches.Data.GetLength(0); y++)
            {
                for (int x = 0; x < Matches.Data.GetLength(1); x++)
                {
                     if (Matches.Data[y, x, 0] >= Threshold) //Check if its a valid match
                     {
                         //Image2 found within Image1
                     }
                }
            }
    

    【讨论】:

    • 哇,非常感谢朋友,非常感谢!你知道如何用 C# 保存屏幕截图吗?或者有没有办法把当前屏幕当成图片不用截图?
    • 我以前没试过,但谷歌又是你的朋友:google.com/search?q=c%23+Screen+Capture
    猜你喜欢
    • 1970-01-01
    • 2014-04-05
    • 1970-01-01
    • 2011-06-03
    • 1970-01-01
    • 2013-04-08
    • 1970-01-01
    • 2014-12-18
    • 1970-01-01
    相关资源
    最近更新 更多