EmguCV Canny 黑色 window

EmguCV Canny black window

我还有一个问题。我不知道发生了什么,但我试图制作 Canny 边缘检测器。问题是当我想检测像正方形这样的简单形状的边缘时,程序能够检测到它。但是当我想在不是很简单的图像程序上检测形状时,只会给我只用黑色填充的图像。你们知道发生了什么事吗?

我在下面使用这段代码:

 public Bitmap CannyEdge(Bitmap bmp)
    {
        Image<Gray, Byte> Cannybmp;
        Image<Gray, Byte> GrayBmp;
        Image<Bgr, Byte> orig = new Image<Bgr, Byte>(bmp);
        Image<Bgr, Byte> imgSmooth;
        Bitmap output;

        imgSmooth = orig.PyrDown().PyrUp();
        imgSmooth._SmoothGaussian(3);
        GrayBmp = imgSmooth.Convert<Gray, byte>();

        Gray grayCannyThreshold = new Gray(160.0);
        Gray grayThreshLinking = new Gray(80.0);

        Cannybmp = GrayBmp.Canny(grayCannyThreshold.Intensity, grayThreshLinking.Intensity);
        output = Cannybmp.ToBitmap();

        //int a = 5;
        return output;

    }

private void button1_Click(object sender, EventArgs e)
    {
        Bitmap bmp = new Bitmap(pictureBox1.Image);
        pictureBox2.Image = CannyEdge(bmp);
    }

您是否尝试将 grayCannyThreshold 设置为小于 grayThreshLinking 的值?

Gray grayCannyThreshold = new Gray(80.0);
Gray grayThreshLinking = new Gray(160.0);