6.6 Search Source
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

6.1 Class Name 
6.2 Class Overview 
6.3 Chapter Project 
6.4 Class Link 
6.5 Key Segment 
6.6 Search Source 
[Home][6 Input][6.6 Search Source]

 

6.6   Search Source Button

The search source can be:

  •    Search-Directory,
  •    Search-File,
  •    Sub-Directory, and
  •    Segment-File.

For more information, please see the ImageFinder User’s Guide. The “Type” button specifies the search-source:

      string [] strMode = { "Dir", "File", "Sub Dir", "F Segment" };

          internal int iMode = 0;

 

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

        {

            iMode = (iMode + 1 )% strMode.Length ;

 

                  if (iMode == 0 )

                      button3.Text = strMode[0];

                  else if (iMode == 1 )

                      button3.Text = strMode[1];

                  else if (iMode == 2 )

                      button3.Text = strMode[2];

                  else if (iMode == 3 )

                      button3.Text = strMode[3];

          }

Now, we implement the “Source” button:

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

              {

                  input.searchSource( iMode );

              }

which in turn, calls the following function in the Input class:

      public void searchSource (int iMode)

              {

                  if ( iMode == 0 )

                      searchSource0 ();

                  else if ( iMode == 1 )

                      searchSource1 ();

                  else if ( iMode == 2 )

                      searchSource2 ();

                  else if ( iMode == 3 )

                      searchSource3 ();

                  else

                      searchSource0 ();

              }//searchSource

The search source can be:

  •    Search-Directory,
  •    Search-File,
  •    Sub-Directory, and
  •    Segment-File.

For Search-Directory, the implementation is:

    private void searchSource0 ()//dir

          {

              if ( f.openFileDialog1.ShowDialog () != DialogResult.OK )

                  return;

              string cDir = System.IO.Directory.GetCurrentDirectory();

       

              f.textBox2.Text = cDir;

              f.richTextBox1.AppendText ( cDir +"\n" );

       

              filelist = in70.getDirList(cDir);

       

              if ( filelist == null )

                  return;

              if ( filelist.Length == 0 )

                  return;

       

              f.richTextBox1.Text ="";

              for (int i= 0; i < filelist.Length ; i++ )

                  f.richTextBox1.AppendText ("" + i + " " +filelist[i] +"\n" );

       

              f.pictureBox2.Image = new Bitmap  (filelist[0] );

              f.richTextBox1.AppendText ( "Display the first image!\n" );

          }

The first section of code gets the current search directory via the open file dialog:

      if ( f.openFileDialog1.ShowDialog () != DialogResult.OK )

              return;

          string cDir = System.IO.Directory.GetCurrentDirectory();

The next section gets a string list of the image paths:

      filelist = in70.getDirList(cDir);

The third section prints the string list of the image paths:

      f.richTextBox1.Text ="";

          for (int i= 0; i < filelist.Length ; i++ )

              f.richTextBox1.AppendText ("" + i + " " +filelist[i] +"\n" );

The last section displays the first images:

      f.pictureBox2.Image = new Bitmap  (filelist[0] );

To test, run the software and click the first image in folder, “c:\transapplet70\ex_wheel”.

Now, we implement Search-File:

        private void searchSource1 ()//file

        {

            if ( f.openFileDialog1.ShowDialog () != DialogResult.OK )

                return;

            string cDir = f.openFileDialog1.FileName ;

     

            f.textBox2.Text = cDir;

            f.richTextBox1.AppendText ( cDir +"\n" );

     

            filelist = in70.getFileList (cDir);

     

            if ( filelist == null )

                return;

            if ( filelist.Length == 0 )

                return;

     

            f.richTextBox1.Text ="";

            for (int i= 0; i < filelist.Length ; i++ )

                 f.richTextBox1.AppendText ( "" + i + " " +filelist[i] +"\n" );

     

            f.pictureBox2.Image = new Bitmap  (filelist[0] );

            f.richTextBox1.AppendText ( "Display the first image!\n" );

        }

 

There is only one line difference between Search-Directory and Search-File:

    filelist = in70.getFileList (cDir);

The rest of the code is identical to Search Directory.

To test, run the software and select file, “c:\transapplet70\ex_wheel\input_file1.txt”.

Now, we implement Sub-Directory and File-Segment:

          private void searchSource2 ()//sub

          {

              if ( f.openFileDialog1.ShowDialog () != DialogResult.OK )

                  return;

              string cDir = System.IO.Directory.GetCurrentDirectory();

       

              f.textBox2.Text = cDir;

              f.richTextBox1.AppendText ( cDir +"\n" );

       

              filelist = in70.getSubDirList (cDir);

              if ( filelist == null )

                  return;

              if ( filelist.Length == 0 )

                  return;

       

              f.richTextBox1.Text ="";

              for (int i= 0; i < filelist.Length ; i++ )

                  f.richTextBox1.AppendText ( "" + i + " " +filelist[i] +"\n" );

       

              f.pictureBox2.Image = new Bitmap  (filelist[0] );

              f.richTextBox1.AppendText ( "Display the first image!\n" ); 

          }

       

              private void searchSource3 ()

              {

                  if ( f.openFileDialog1.ShowDialog () != DialogResult.OK )

                      return;

                  string cDir = f.openFileDialog1.FileName ;

       

                  f.textBox2.Text = cDir;

                  f.richTextBox1.AppendText ( cDir +"\n" );

       

                  filelist = in70.getFileSegmentList (cDir);

       

                  if ( filelist == null )

                      return;

                  if ( filelist.Length == 0 )

                      return;

       

                  f.richTextBox1.Text ="";

                  for (int i= 0; i < filelist.Length ; i++ )

                      f.richTextBox1.AppendText ( "" + i + " " +filelist[i] +"\n" );

                      

                  f.pictureBox2.Image = new Bitmap  (filelist[0] );

                  f.richTextBox1.AppendText ( "Display the first image!\n" );

              }

Again, there is only one line difference between Search-Directory and these two functions.

To test the Sub-Directory, run the software and click the first image in folder,  “c:\transapplet70\ex_wheel\”.

To test Segment-File, run the software and select file, “c:\transapplet70\ex_wheel\ input_filesegment1.txt”.

 

[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