22.7 Live Video to Images
About1 Introduction2 Image Recognition3 TransApplet4 API5 Interface6 Input7 Image Display8 Preprocessing9 Processing10 Normalization11 Parameter Class12 Image Signatures13 Unsupervised Filters14 BioFilters15 NeuralFilters16 Dynamic Library17 NeuralNet Filter18 Parameters19 Input Options20 Database Input21 Video Input22  Live Video Input23  Counting & Tracking24  Counting 25  Batch Job26 ImageFinder for DOS27 ImageHunt 28 Support Packages

22.1  Class Name 
22.2  Link to Class 
22.3 Input 
22.4 Initialization 
22.5 Video Image Design 
22.6 Display Image 
22.7 Live Video to Images 
[Home][22 Live Video Input][22.7 Live Video to Images]

 

22.7    Converting Live Video to Images

The “Live To Image” button in Figure 22.3 will convert the live video to images. The “Live To Image” code is:

        private void button4_Click(object sender, System.EventArgs e)

                {

                if ( ! f.mainMenuToAPI .lv63 .getCaptureStatus () )

                {

                    richTextBox1.Text = "Please set the mode to Live Video\n,

        click the Source button, then Live Button!\n"

                        + "The Mode button is right in front of the Live button.\n";

                    return;

                }

                

        try{

                    f.mainMenuToAPI .lv63.setVideoToImagesDir

        ( f.gui.videoLiveParameters .imageOutputFolder);

                    f.mainMenuToAPI .lv63.setNumOfFrames

         ( f.gui.videoLiveParameters .captureNumberOfFrames  ) ;

                    f.mainMenuToAPI .lv63.setTimeInterval

        ( f.gui.videoLiveParameters .captureTimeInterval   ) ;

                    mer1.Interval =  f.gui.videoLiveParameters .captureTimeInterval ;

                }

        catch (Exception ee)

        {

                    richTextBox1.Text = ee.ToString () + "\n";

                    return;

        }

                if ( !  f.mainMenuToAPI .lv63.getVideoToImagesDirStatus () )

                {

                    richTextBox1.Text = "Set Live Video To Image Directory Fails!" ;

                    return;

                }

         

                richTextBox1.Text = "Output directory:\n"

                    + f.mainMenuToAPI .lv63.getVideoToImagesDir ();

         

                liveID = 0;

                timer1.Enabled = true;

                }

Basically, this button simply starts the timer via the following statement:

        timer1.Enabled = true;

The rest of the statements are for various tests. Figure 22.3 has the following constructor:

        public Parameter_VideoInput(Form1 f1)

                {

                InitializeComponent();

                f = f1;

                img = f.pictureBox2 ;

            }

Here object, img, is the picture box where the live image will be obtained. The timer will convert the live video into images as follows:

            private void timer1_Tick(object sender, System.EventArgs e)

                {

                    string s =

                     f.mainMenuToAPI .lv63.getVideoToImagesDir ()  

                    + DateTime.Now.Year+ "_"

                    + DateTime.Now.Month + "_"

                    + DateTime.Now.Day  + "_"

                    + DateTime.Now.Hour + "_"

                    + DateTime.Now.Minute + "_"

                    + DateTime.Now.Second + "_"

                    + ( DateTime.Now.Millisecond  /10 )

                    + ".jpg";

                richTextBox1.Text = "" + (liveID ++) + ".   " + s;

                try

                {

                    img.Image.Save ( s,System.Drawing.Imaging.ImageFormat.Jpeg );

                }

                catch (Exception ei )

                {

                    richTextBox1.Text = ei.ToString () ;

                }

                if (liveID >= f.mainMenuToAPI .lv63.getNumOfFrames () )

                {

                    timer1.Enabled = false;

                    richTextBox1.Text = "Live Video To Image Conversion End! ";

                }

            }

The key statement is:

            img.Image.Save (  s,System.Drawing.Imaging.ImageFormat.Jpeg );

which will save the image in the Picture Box to a jpeg file. The following statement simply stops the timer when the number of pre-determined frames has been reached:

            if (liveID >= f.mainMenuToAPI .lv63.getNumOfFrames () )

                {

                    timer1.Enabled = false;

                    richTextBox1.Text = "Live Video To Image Conversion End! ";

                }

 

[Home][About][1 Introduction][2 Image Recognition][3 TransApplet][4 API][5 Interface][6 Input][7 Image Display][8 Preprocessing][9 Processing][10 Normalization][11 Parameter Class][12 Image Signatures][13 Unsupervised Filters][14 BioFilters][15 NeuralFilters][16 Dynamic Library][17 NeuralNet Filter][18 Parameters][19 Input Options][20 Database Input][21 Video Input][22 Live Video Input][23 Counting & Tracking][24 Counting ][25 Batch Job][26 ImageFinder for DOS][27 ImageHunt ][28 Support Packages]

Copyright (c) 2006 - 2007 Attrasoft. All rights reserved.

gina@attrasoft.com