Introduction to Object Tracking : Case Study Cricket Ball
Rate this article
5.00 out of 5
Object Tracking technology has long been considered as a challenging area in Artificial Intelligence. Extracting intelligence form videos , and predicting the outcome requires expertise not only form computer science and artificial intelligence but also requires expertise in physics, mathematics and other related areas. In this article we will give you an introduction to object tracking with a basic case study cricket ball tracking form a Video stream. This project was done as part of an academic project by one of the students in our organization.

Basically what it does is the following.

1. Capture the frame from each video
2. Process the frame so as to extract the Object information
3.  Track the object (in this case cricket ball ) by drawing the co-ordinates in the frame.

Basically the Project contains two solutions in Visual Studio.
1. One Frame Tracking component developed in VC++
2. Object Tracking application developed in C#.NET which drives the Object Tracking component developed in VC++.

The software developed makes heavy uses of OpenCV and EmuCV Open source libraries. So in order to compile the source code , you need to install OpenCV and EmuCV and configure for Visual Studio.

Here are some of he code snippets from the application..

 public Form1_ObjectTracking()
        {

            try
            {
                InitializeComponent();



                m_objImageIdentification = new ImageIdentification();

            }

            catch(Exception ex)
            {

                MessageBox.Show(ex.Message);

            }
        }
               
        private void btn_Existing_Click(object sender, EventArgs e)
        {

            try
            {

                DialogResult objDialogResult = openFileDialog1.ShowDialog();

                if (objDialogResult == DialogResult.OK)
                {

                    m_strFilePath = openFileDialog1.FileName;

                }

                iCount = 0;

                capture = new Capture(m_strFilePath);

                Image<Bgr, Byte> img1 = capture.QueryFrame();

                img_Video.Image = img1;

             
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
           

        }

        private void My_Timer_Tick(object sender, EventArgs e)
        {

            Image<Bgr, Byte> img = capture.QueryFrame(); 

            Bitmap bmp = img.ToBitmap();
           

            //p = m_objImageIdentification.FrameTrack(bmp);

           // double[,] x = new double[3,3];

           
            float[] center = new float[4];
            center=m_objImageIdentification.FrameTrack(bmp);


            Int32  x = Convert.ToInt32(center[0]);
            Int32 y = Convert.ToInt32(center[1]);

            if (x > 10)
            {

                m_iPoints[iCount,0] = x;

                m_iPoints[iCount, 1] = y;

                if (iCount > 1)
                {

                    for (int i = 1; i <= iCount; i++)
                    {

                        Point first = new Point(m_iPoints[i-1, 0], m_iPoints[i-1, 1]);

                        Point second = new Point(m_iPoints[i, 0], m_iPoints[i, 1]);

                        LineSegment2D line = new LineSegment2D(first, second);

                        img.Draw(line, new Bgr(Color.Red), 2);


                    }

                }


               Point pcenter = new Point(x, y);

            //    Point psecond=new Point(x+5,y+5);;

                CircleF circle = new CircleF(pcenter, 5);

               img.Draw(circle, new Bgr(Color.Red), 2);

            //    LineSegment2D line = new LineSegment2D(pcenter, psecond);

               iCount = iCount + 1;
              
               
            }
            img_Video.Image = img;

           

        }

              private void btn_Play_Click(object sender, EventArgs e)
        {



            time.Interval = 2500 / ifps;



            time.Tick += new EventHandler(My_Timer_Tick);

            time.Start();

        }

        private void btn_Track_Click(object sender, EventArgs e)
        {

            time.Interval = 2500 / ifps;



            time.Tick += new EventHandler(My_Timer_Tick1);

            time.Start();

        }

        private void My_Timer_Tick1(object sender, EventArgs e)
        {

            Image<Bgr, Byte> img = capture.QueryFrame();

            img_Video.Image = img;


        }
    }  


Download Source Code
Download Source Code form the Link Below.

Joined Date :14-Nov-2012
Articles
Posted
60
Messages
Posted
3

KTS InfoTech Training division offers various short-term programming courses for Students and Professionals who are looking for a bright career in the field of Software development.

The programming video tutorials presented in this web site are taken from some of the training sessions conducted by KTS InfoTech.

You can also learn the Programming packages through Internet directly form our English Speaking Technical experts at an affordable rate.

For more details click here and submit your training requirements.




   
Messages
Posted:
Post Your Comments
Name (Max 50 Chars)
Comments
   Design  HTML

TekTipsDownload
GateExam
Academic Projects
TekTipsExperts



 
Site optimized for IE7, 1280 X 768 and above. Copyright © 2010 - 2018 KTS InfoTech
Site Developed Using KTS WebCloud