27.8 Step 3
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

27.1  Why ImageHunt? 
27.2  Design 
27.3 Web Server 
27.4 Install 
27.5 Web Project 
27.6 Step 1 
27.7 Step 2 
27.8 Step 3 
27.9 DOS Class 
27.10 Step 4 
[Home][27 ImageHunt ][27.8 Step 3]

 

27.8   Step 3. Create Batch File

27.8.1   Cookies or URL

The User will make three clicks:

  •    Select File;
  •    Upload File;
  •    Search.

The third click is the “Search” button, which will lead to a new web form. The code for the “Search” button is:

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

            {

            string fn = TextBox2.Text;

            SaveLocation = Server.MapPath("Data") + "\\" +  fn;

            Response.Redirect ("Attrasoft_ImageHunt2.aspx" + "?p="+ SaveLocation);

            }

The uploaded image is passed to the new web form, “Attrasoft_ImageHunt2.aspx”. You could choose cookies (Post Method):

        Session [ "theFileName" ] = SaveLocation;

Or URL (Get Method):

            Response.Redirect ("Attrasoft_ImageHunt2.aspx" + "?p="+ SaveLocation);

Obviously, we have chosen the URL to pass the location of the uploaded image. If you choose the Cookies, you must inform your client to accept cookies.

 

27.8.2   Create Batch File

At this point, we are redirected to web form, “Attrasoft_ImageHunt2.aspx”. Upon starting this web form, the following code will call function, “start()”:

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

                {

                start();

                }

The first thing “start()” will do is to create a batch file used by the ImageFinder for Dos:

        string master = "master.txt";

            string parameterFile = "abm70.txt";

        bool createFile ()

                {

                StreamWriter sw;

                StreamReader sr;

                string sRead;

                int i = 0;

         

                try

                {

                    sr = new StreamReader ( matchLocation + master );

                    sw = new StreamWriter ( matchLocation + parameterFile );

         

                    i = 0;

                    while ( sr.Peek () != -1 )

                    {

                    sRead = sr.ReadLine ();

                    if ( i == 3 )

                    {

                    //sw.WriteLine ( "trainFileName=" + Session [ "theFileName" ] );

                    sw.WriteLine

        ( "trainFileName=" +Request.QueryString ["p"].ToString () );

                    }

                    else

                        sw.WriteLine (sRead);

                        i++;

                    }

                    sw.Close ();

                    sr.Close ();

                    }

                    catch ( Exception em )

                    {

                        Label1.Text =  em.ToString () +"\n";

                        return false;

                    }

                    return true;

                }//create file

This function basically copies "master.txt” to "abm70.txt" line by line, with the exception of line 3:

        if ( i == 3 )

                    {

                    //sw.WriteLine ( "trainFileName=" + Session [ "theFileName" ] );

                    sw.WriteLine

        ( "trainFileName=" +Request.QueryString ["p"].ToString () );

                    }

This is where the ImageHunt learns where the new image is. There are several other minor things; we will omit them here.

 

[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