fast_N_features.cc

Go to the documentation of this file.
00001 /*
00002 
00003     This file is part of the FAST-ER machine learning system.
00004     Copyright (C) 2008  Edward Rosten and Los Alamos National Laboratory
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License along
00017     with this program; if not, write to the Free Software Foundation, Inc.,
00018     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00019 */
00020 /**
00021 \file fast_N_features.cc Main file for the fant_N_features executable.
00022 
00023 \section wpUsage Usage
00024 
00025 <code> ./fast_N_features [--NUM N] | ./learn_fast_tree </code>
00026 
00027 \section Description
00028 
00029 This program generates a list of all possible FAST-N features in an output
00030 format suitable for consumption by \link learn_fast_tree.cc learn_fast_tree\endlink.
00031 The program accepts standarg GVars3 commandline arguments. The only useful argument is
00032 N which specifies the N for which FAST-N features should be generated.
00033 
00034 */
00035 
00036 #include <iostream>
00037 #include <gvars3/instances.h>
00038 
00039 ///\cond never
00040 using namespace std;
00041 using namespace GVars3;
00042 ///\endcond
00043 
00044 
00045 ///Determine if a string has the properties of a FAST-N corner.
00046 ///In other words, if it has enough consecutive characters of the correct
00047 ///type. This function assumes that the string wraps in a circular manner.
00048 ///@param str String to test for cornerness.
00049 ///@param num_for_corner Number of consecutive characters required for corner
00050 ///@param type Character value which must appear consecutively#
00051 ///@return whether the string is a corner.
00052 inline bool is_corner(const char* str, int num_for_corner, char type)
00053 {
00054     int num_consecutive=0;
00055     int first_cons=0;
00056     
00057     for(int i=0; i<16; i++)
00058     {
00059         if(str[i] == type)
00060         {
00061             num_consecutive++;
00062             
00063             if(num_consecutive == num_for_corner)
00064                 return 1;
00065         } 
00066         else
00067         {
00068             if(num_consecutive == i)
00069                 first_cons=i;
00070 
00071             num_consecutive=0;
00072         }
00073     }
00074     
00075     if(first_cons+num_consecutive >=num_for_corner)
00076         return 1;
00077     else 
00078         return 0;
00079 }
00080 
00081 ///This is the main function for this program. It generates all possible FAST pixel rings
00082 ///using brute-force and outputs them along with their class and a uniform weighting over all
00083 ///features.
00084 ///@param argc Number of commandline arguments
00085 ///@param argv List of commandline arguments
00086 int main(int argc, char ** argv)
00087 {   
00088     GUI.parseArguments(argc, argv);
00089 
00090     char types[]="bsd.";
00091     char F[17]="................";
00092 
00093     int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p;
00094     cout << 16 << endl;
00095     cout << "[0 3] [1 3] [2 2] [3 1] [3 0] [3 -1] [2 -2] [1 -3] [0 -3] [-1 -3] [-2 -2] [-3 -1] [-3 0] [-3 1] [-2 2] [-1 3]" << endl;
00096 
00097     int N = GV3::get<int>("N", 9, 1);
00098 
00099     for(a = 0, F[ 0]='b'; a < 3; a++, F[ 0]=types[a])
00100      for(b = 0, F[ 1]='b'; b < 3; b++, F[ 1]=types[b])
00101       for(c = 0, F[ 2]='b'; c < 3; c++, F[ 2]=types[c])
00102        for(d = 0, F[ 3]='b'; d < 3; d++, F[ 3]=types[d])
00103         for(e = 0, F[ 4]='b'; e < 3; e++, F[ 4]=types[e])
00104          for(f = 0, F[ 5]='b'; f < 3; f++, F[ 5]=types[f])
00105           for(g = 0, F[ 6]='b'; g < 3; g++, F[ 6]=types[g])
00106            for(h = 0, F[ 7]='b'; h < 3; h++, F[ 7]=types[h])
00107             for(i = 0, F[ 8]='b'; i < 3; i++, F[ 8]=types[i])
00108              for(j = 0, F[ 9]='b'; j < 3; j++, F[ 9]=types[j])
00109               for(k = 0, F[10]='b'; k < 3; k++, F[10]=types[k])
00110                for(l = 0, F[11]='b'; l < 3; l++, F[11]=types[l])
00111                 for(m = 0, F[12]='b'; m < 3; m++, F[12]=types[m])
00112                  for(n = 0, F[13]='b'; n < 3; n++, F[13]=types[n])
00113                   for(o = 0, F[14]='b'; o < 3; o++, F[14]=types[o])
00114                    for(p = 0, F[15]='b'; p < 3; p++, F[15]=types[p])
00115                     cout << F << " 1 " << (is_corner(F, N, 'b') || is_corner(F, N, 'd')) << endl;
00116 }

Generated on Mon Mar 2 12:47:12 2009 for FAST-ER by  doxygen 1.5.3