int __cdecl main() { ChannelSearchInfo searchInfo; while(1) { ::Sleep(200); // Scan the channels every 200 secs bool succ = SearchChannel(&searchInfo); if (succ) { ProcessChannel(&searchInfo); } } return 0; }
/* pass the rgb pixel vector for filtering; the response is returned in the response vector. This vector will be initialized by the Gabor API, but MUST disposed of it by the user. respLen is the address of an int holding the length of the response vector. */ float* ProcessFile( char* file, int*** rgb, int h, int w, float* response, int* respLen ) { char basename[256]; char dirStr[256]; char* fileStr; int i, j, len; float norm, max, min; // extract directory path from filename strcpy( dirStr, file ); fileStr = strrchr( dirStr, '/' ); if ( fileStr != NULL ) { strcpy( basename, fileStr ); // save part after last slash dirStr[fileStr-dirStr+1] = '\0'; // save directory string strcat( dirStr, basename ); strcat( dirStr, "-localGF" ); basename[strlen(basename)-4] = '\0'; // remove extension for ( i = 0; i < strlen( basename ); i++ ) // remove intial slash basename[i] = basename[i+1]; basename[i] = '\0'; } else // we are in working directory { strcpy( basename, file ); basename[strlen(basename)-4] = '\0'; // remove extension strcpy( dirStr, basename ); strcat( dirStr, "-localGF" ); } // create img directory in extracted path if ( kSaveFilter == 1 ) { mkdir( dirStr, S_IRWXU | S_IRWXG ); if ( kVerbosity ) cerr << "Created directory: \"" << dirStr << "\"" << endl; strcat( dirStr, "/" ); } // allocate pixels for rgb matrix float** pixels = CreateMatrix( (float)255.0, h, w ); // convert rgb info to grayscale for ( i = 0; i < h; i++ ) { for ( j = 0; j < w; j++ ) { if (rgb[0][i][j] == 0) { pixels[i][j] = 1; } else { pixels[i][j] = 0; } // pixels[i][j] = sqrt( (float)( rgb[0][i][j]*rgb[0][i][j] + // rgb[1][i][j]*rgb[1][i][j] + // rgb[2][i][j]*rgb[2][i][j] ) ) / sqrt( 3.0 ); cout << pixels[i][j]; } cout << endl; } // process grayscale pixels, get gabor filter response length and allocate the return vector len = 0; strcpy( basename, dirStr ); cout << endl; cout << endl; for ( i = 0; i < h; i++ ) { for ( j = 0; j < w; j++ ) { cout << pixels[i][j]; } cout << endl; } response = ProcessChannel( pixels, h, w, response, &len, basename ); *respLen = len; // original float values scaled to [0,1] if ( kVerbosity ) cerr << "scaling..." << endl; max = min = response[0]; cerr << endl; for ( i = 0; i < len; i++ ) { if( response[i] > max ) max = response[i]; if( response[i] < min ) min = response[i]; } cerr << endl; norm = max - min; for ( i = 0; i < len; i++ ) { response[i] = 1.0 * ( ( response[i] - min ) / norm ); cerr << response[i] << " "; } // dispose of pixel storage if ( pixels != NULL ) DisposeMatrix( pixels, h ); return response; }