本文介绍了索引OutOfRange异常在圆检测中未被取消的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

是新的计算机视觉,我有一个错误,索引outofrange异常在for循环条件中未处理。任何人都可以帮我解决吗?这是我的代码........

Hello,
am new one for computer vision , i have an error has index outofrange exception was unhandled in for loop condition. can anyone help me to solve it? here is my code........

namespace circle_detection
{
    public partial class Form1 : Form
    {
        private Capture capturez;
        void InitializeInstanceFields()
        {
            capturez = new Capture();
        }
        public Form1()
        {
            InitializeInstanceFields();
            InitializeComponent();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            double cannyThreshold = 180.0;
            double circleAccumulatorThreshold = 120;
            double cannyThresholdLinking = 160;
  
            Image<Bgr, Byte> imagez5 = capturez.QueryFrame().Resize(400, 400,                                                                                                                              Emgu.CV.CvEnum.INTER.CV_INTER_LINEAR, true);
            pictureBox2.Image = imagez5.Bitmap;
            Image<Gray, Byte> gray = imagez5.Convert<Gray, Byte>                  ().PyrDown().PyrUp();
            Image<Gray, byte> imagez7 = gray.Canny(cannyThreshold, cannyThresholdLinking);
            CircleF[] circlez = imagez7.HoughCircles(
                new Gray(cannyThreshold), new Gray(circleAccumulatorThreshold), 1, 60, 3, 300)[0];
            Image<Bgr, Byte> circleImage = imagez5.CopyBlank();


            for (int i =0; i<=circlez.Length; i++)
            {
                imagez7.Draw(circlez[i], new Gray(255), 3);

            }

                pictureBox1.Image = imagez7.Bitmap;

        }

    }
}

推荐答案


for (int i =0; i<=circlez.Length; i++)
{
imagez7.Draw(circlez[i], new Gray(255), 3);

}







将是








to be


for (int i =0; i<=circlez.Length-1; i++)
{
imagez7.Draw(circlez[i], new Gray(255), 3);

}


这篇关于索引OutOfRange异常在圆检测中未被取消的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 07:16