【问题标题】:Ambiguous reference error? [duplicate]模棱两可的参考错误? [复制]
【发布时间】:2018-05-25 16:18:08
【问题描述】:

使用canny 过滤器检测到最大轮廓后,我现在只想提取其中存在的内容。

Rectangle rect = CvInvoke.BoundingRectangle(contours[largest_contour_index]);            
Bitmap target = new Bitmap(rect.Width, rect.Height);

using (Graphics g = Graphics.FromImage(target))
{
    g.DrawImage(imageInput, new Rectangle(0, 0, target.Width, target.Height),
                rect, GraphicsUnit.Pixel);
}

imageBox2.Image = imageInput;

我得到这个错误:

错误 CS0104 'Graphics' 是 'System.Drawing.Graphics' 和 'UnityEngine.Graphics' 之间的模糊引用

有什么办法可以解决的吗?

【问题讨论】:

  • 请更改标题以反映实际问题

标签: c#


【解决方案1】:

其他答案都是正确的;在这些情况下有用的另一种技术是在文件顶部创建别名指令:

using SDGraphics = System.Drawing.Graphics;

现在你可以在平时说Graphics的地方说SDGraphics,而且不会有歧义。

【讨论】:

    【解决方案2】:

    错误信息其实很中肯。将 Graphics 更改为 System.Drawing.Graphics 以解决歧义。

    【讨论】:

    • 或者,可能是UnityEngine.Graphics。这有点模棱两可。哈。哈。
    • 好吧,因为我不是编译器,所以我可以阅读该行的其余部分;)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多