【问题标题】:ExhaustiveTemplateMatching ProcessImage return emptyExhaustiveTemplateMatching ProcessImage 返回空
【发布时间】:2017-10-24 03:11:21
【问题描述】:

这是我的代码:

static void Main(string[] args)
        {
            ExhaustiveTemplateMatching tm = new ExhaustiveTemplateMatching(0);

            // Compare two images
            System.Drawing.Bitmap image1 = new System.Drawing.Bitmap("2.jpg");
            System.Drawing.Bitmap image2 = new System.Drawing.Bitmap("2.jpg");
            TemplateMatch[] matchings = tm.ProcessImage(image1, image2);
            MessageBox.Show(matchings[0].Similarity.ToString());
            // Check similarity level
            if (matchings[0].Similarity > 0.95)
            {

            }
        }

附件:

value and exception

value and exception

【问题讨论】:

  • @JohnEphraimTugado 你能帮我解决这个问题吗?谢谢
  • 索引超出范围异常是由于matchings 不包含任何元素。您可能想在TemplateMatch[] matchings = tm.ProcessImage(image1, image2); 中找到原因。我强烈建议您学习如何设置断点和调试您的应用程序。您会感到惊讶,有时一个简单的编码错误会导致您的应用程序失败。
  • @JohnEphraimTugado 你是对的,根本原因是匹配项是空的,我正在寻找它发生的原因,我尝试了其他图片,没关系,并不总是失败。现在我正在检查伪造源代码,没有得到任何有用的信息。
  • 您应该在帖子中指出ExhaustiveTemplateMatching 不是您的。在 SO 中提问时发布所有相关信息。知道答案的人可能因为缺乏信息而忽略了这个问题。

标签: c# image aforge


【解决方案1】:

最终的解决方案是重写 ExhaustiveTemplateMatching 类来改变值类型,因为图片分辨率太大,int32 值不够

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-07-27
    • 2018-12-23
    • 2020-01-11
    • 2021-07-07
    • 2013-09-30
    • 2021-08-23
    • 2013-04-07
    • 2018-05-21
    相关资源
    最近更新 更多