c#emgucv,绘制后如何删除矩形 现在我的目的是,在我画了一个矩形之后,我想清除它。但我不知道怎么做!

c#emgucv,绘制后如何删除矩形 现在我的目的是,在我画了一个矩形之后,我想清除它。但我不知道怎么做!,c#,draw,emgucv,C#,Draw,Emgucv,所以我尝试在stackoverflow上搜索,但它们似乎不符合我的问题。 现在我的代码的功能是在imagebox上画一个矩形,当鼠标按下时,它会给矩形一个起点,也就是鼠标移动的状态!当鼠标向上移动时,它将具有端点。 所以使用 {绘制(矩形,TColor,Int32,线型,Int32);} 然后它将生成一个新的矩形; 但我不知道在那之后如何删除矩形 这是我的密码 副本:可能的副本 private void pictureBox1_MouseDown(object sender, MouseEve

所以我尝试在stackoverflow上搜索,但它们似乎不符合我的问题。 现在我的代码的功能是在imagebox上画一个矩形,当鼠标按下时,它会给矩形一个起点,也就是鼠标移动的状态!当鼠标向上移动时,它将具有端点。 所以使用 {绘制(矩形,TColor,Int32,线型,Int32);} 然后它将生成一个新的矩形; 但我不知道在那之后如何删除矩形

这是我的密码 副本:可能的副本
 private void pictureBox1_MouseDown(object sender, MouseEventArgs e)//mousedown
    {
        if (img != null)
        {
           
            mouseStatus = true;
            startPoint.X = e.X;
            startPoint.Y = e.Y;
            //A new rectangle resets in a new coordinate
            minStartX = e.X;
            minStartY = e.Y;
            maxEndX = e.X;
            maxEndY = e.Y;
        }
    }

   
    private void pictureBox1_MouseMove(object sender, MouseEventArgs e)//mousemove
    {
        string StringX, StringY, StringSX, StringSY;
    
        if (mouseStatus)
        {
          
            endPoint.X = e.X;
            endPoint.Y = e.Y;
            //This section is to get the top and bottom left coordinates of the rectangle to be drawn. If not, the rectangle can only be drawn from the top left to the bottom right.
            
            int realStartX = Math.Min(startPoint.X, endPoint.X);
            int realStartY = Math.Min(startPoint.Y, endPoint.Y);
            int realEndX = Math.Max(startPoint.X, endPoint.X);
            int realEndY = Math.Max(startPoint.Y, endPoint.Y);

            minStartX = Math.Min(minStartX, realStartX);
            minStartY = Math.Min(minStartY, realStartY);
            maxEndX = Math.Max(maxEndX, realEndX);
            maxEndY = Math.Max(maxEndY, realEndY);
            currRect = new Rectangle(realStartX, realStartY, realEndX - realStartX, realEndY - realStartY);
            StringX = Convert.ToString(realStartX);
            StringY = Convert.ToString(realStartY);
            StringSX = Convert.ToString(realEndX - realStartX);
            StringSY = Convert.ToString(realEndY - realStartY);
            textBox1.Text = StringX;
            textBox2.Text = StringY;
            textBox3.Text = StringSX;
            textBox4.Text = StringSY;
          

        }
    }

    private void pictureBox1_MouseUp(object sender, MouseEventArgs e)/mouseup
    {
        mouseStatus = false;
        endPoint.X = e.X;
        endPoint.Y = e.Y;
        img.Draw(currRect, new Bgr(Color.Red), 1);
        pictureBox1.Image = img.Bitmap;
    }