TePDICorrelationMatching_test.cpp

Go to the documentation of this file.
00001 #define TEAGN_ENABLE_STDOUT_LOG
00002 
00003 #include <TePDIExamplesBase.hpp>
00004 
00005 #include <TePDICorrelationMatching.hpp>
00006 #include <TePDIUtils.hpp>
00007 
00008 #include <TeProgress.h>
00009 #include <TeStdIOProgress.h>
00010 #include <TeAgnostic.h>
00011 
00012 #include <math.h>
00013 
00014 
00015 void raster2Tiff( 
00016   const TePDITypes::TePDIRasterPtrType& input_raster_ptr,
00017   unsigned int raster_channel,
00018   const std::string& out_file_name,
00019   TeSharedPtr< TeCoordPairVect > out_tie_points_ptr,
00020   unsigned int tie_points_space )
00021 {   
00022   TEAGN_TRUE_OR_THROW( ( ! out_file_name.empty() ), 
00023     "Invalid file name" )
00024   TEAGN_TRUE_OR_THROW( ( input_raster_ptr->params().nlines_ > 0 ), 
00025     "Invalid matrix lines" )
00026   TEAGN_TRUE_OR_THROW( ( input_raster_ptr->params().ncols_ > 0 ), 
00027     "Invalid matrix cols" )
00028     
00029   TeRasterParams params;
00030   params.setNLinesNColumns( input_raster_ptr->params().nlines_,
00031     input_raster_ptr->params().ncols_ );
00032   params.nBands( 1 );
00033   params.setDataType( TeUNSIGNEDCHAR, -1 );
00034   params.nBands( 1 );
00035   params.decoderIdentifier_ = "TIF";
00036   params.mode_ = 'c';
00037   params.fileName_ = out_file_name;
00038   
00039   TeRaster out_raster( params );
00040   TEAGN_TRUE_OR_THROW( out_raster.init(), "Error init raster" );
00041   double value = 0;
00042   
00043   for( int line = 0 ; 
00044     line < input_raster_ptr->params().nlines_ ; ++line ) {
00045     for( int col = 0 ; 
00046       col < input_raster_ptr->params().ncols_ ; 
00047       ++col ) {
00048       
00049       input_raster_ptr->getElement( col, line, value, 
00050         raster_channel );
00051       
00052 
00053       TEAGN_TRUE_OR_THROW( out_raster.setElement( col, line, 
00054         value, 0 ),
00055         "Error writing raster" )
00056     }  
00057   }
00058   
00059   /* Draw tie-points */
00060   
00061   if( out_tie_points_ptr.isActive() ) {
00062     TeCoordPairVect::iterator it = out_tie_points_ptr->begin();
00063     TeCoordPairVect::iterator it_end = out_tie_points_ptr->end();
00064     
00065     while( it != it_end ) {
00066       int x = 0;
00067       int y = 0;
00068       
00069       if( tie_points_space == 0 ) {
00070          x = TeRound( it->pt1.x() );
00071          y = TeRound( it->pt1.y() );
00072       } else {
00073          x = TeRound( it->pt2.x() );
00074          y = TeRound( it->pt2.y() );
00075       }
00076       
00077       TEAGN_TRUE_OR_THROW( ( x < input_raster_ptr->params().ncols_ ),
00078         "Invalid maxima column" )
00079       TEAGN_TRUE_OR_THROW( ( x >= 0 ),
00080         "Invalid maxima column" )      
00081       TEAGN_TRUE_OR_THROW( ( y < input_raster_ptr->params().nlines_ ),
00082         "Invalid maxima line" )
00083       TEAGN_TRUE_OR_THROW( ( y >= 0 ),
00084         "Invalid maxima line" )      
00085       
00086       TEAGN_TRUE_OR_THROW( out_raster.setElement( x, y, 
00087         255.0, 0 ),
00088         "Error writing raster" )    
00089     
00090       ++it;
00091     }
00092   
00093   }
00094 }
00095 
00096 void sameImageTest()
00097 {
00098   /* Creating parameters */
00099 
00100   TePDIParameters params;
00101   
00102   TePDITypes::TePDIRasterPtrType input_image1_ptr( new TeRaster(
00103     std::string( TEPDIEXAMPLESRESPATH "cbers_rgb342_crop1.tif" ), 'r' ) );
00104   TEAGN_TRUE_OR_THROW( input_image1_ptr->init(), 
00105     "Unable to init input_image1_ptr" );    
00106   params.SetParameter( "input_image1_ptr" , input_image1_ptr );
00107   
00108   params.SetParameter( "input_channel1" , (unsigned int)0 );
00109     
00110   TePDITypes::TePDIRasterPtrType input_image2_ptr( new TeRaster(
00111     std::string( TEPDIEXAMPLESRESPATH "cbers_rgb342_crop1.tif" ), 'r' ) );
00112   TEAGN_TRUE_OR_THROW( input_image2_ptr->init(), 
00113     "Unable to init input_image2_ptr" ); 
00114   params.SetParameter( "input_image2_ptr" , input_image2_ptr ); 
00115   
00116   params.SetParameter( "input_channel2" , (unsigned int)0 );       
00117     
00118   TeSharedPtr< TeCoordPairVect > out_tie_points_ptr( new TeCoordPairVect );
00119   params.SetParameter( "out_tie_points_ptr" , out_tie_points_ptr );        
00120   
00121   TeBox input_box1( TeCoord2D( 142, 826 ) , 
00122     TeCoord2D( 542, 426 ) );
00123   params.SetParameter( "input_box1" , input_box1 );
00124   
00125   TeBox input_box2( TeCoord2D( 238, 689 ) , 
00126     TeCoord2D( 391, 473 ) );
00127   params.SetParameter( "input_box2" , input_box2 );  
00128   
00129   params.SetParameter( "pixel_x_relation" , (double)1 ); 
00130   params.SetParameter( "pixel_y_relation" , (double)1 ); 
00131   
00132   double best_cor_value = 0;
00133   params.SetParameter( "best_cor_value_ptr" , &best_cor_value ); 
00134   
00135   TePDICorrelationMatching corr_instance; 
00136   corr_instance.ToggleProgInt( true );
00137   TEAGN_TRUE_OR_THROW( corr_instance.Reset( params ),
00138     "Algorithm reset error" )
00139     
00140   TEAGN_LOGMSG( "Algorithm started" )
00141   
00142   time_t init_time = clock() / CLOCKS_PER_SEC;
00143     
00144   TEAGN_TRUE_OR_THROW( corr_instance.Apply(),
00145     "Algorithm apply error" )      
00146     
00147   time_t end_time = clock() / CLOCKS_PER_SEC;
00148   
00149   TEAGN_LOGMSG( "Time elapsed (sameImageDifBoxesTest): " + 
00150     TeAgnostic::to_string( (long int)( end_time - init_time ) ) +
00151     " seconds" );
00152   TEAGN_WATCH( best_cor_value );
00153     
00154   /* Displaying and checking tie-points */
00155   {
00156     TeCoordPairVect::iterator it = out_tie_points_ptr->begin();
00157     TeCoordPairVect::iterator it_end = out_tie_points_ptr->end();
00158     
00159     while( it != it_end ) 
00160     {
00161       TEAGN_CHECK_EPS( it->pt1.x(), it->pt2.x(), 0.00000000000000001,
00162         "Invalid tie-point" );
00163       TEAGN_CHECK_EPS( it->pt1.y(), it->pt2.y(), 0.00000000000000001,
00164         "Invalid tie-point" ); 
00165             
00166       std::cout << "[" + Te2String( it->pt1.x(),1 ) + " , " +
00167         Te2String( it->pt1.y(),1 ) + "] -> [" +
00168         Te2String( it->pt2.x(),1 ) + " , " + 
00169         Te2String( it->pt2.y(),1 ) + "]" << std::endl;
00170       
00171       ++it;
00172     }
00173   }
00174   
00175   /* Tie-points draw */
00176   
00177   raster2Tiff( input_image1_ptr, 0, TEPDIEXAMPLESBINPATH
00178     "TePDICorrelationMatching_test_sameImageTest_input_image1.tif",
00179     out_tie_points_ptr, 0 );
00180   raster2Tiff( input_image2_ptr, 0, TEPDIEXAMPLESBINPATH
00181     "TePDICorrelationMatching_test_sameImageTest_input_image2.tif",
00182     out_tie_points_ptr, 1 );    
00183     
00184   TEAGN_WATCH( (unsigned int)out_tie_points_ptr->size() );
00185   TEAGN_CHECK_EPS( 4, out_tie_points_ptr->size(),
00186     0, "Invalid tie-points number" )    
00187 }
00188 
00189 void sameImageTestWithMultiThread()
00190 {
00191   /* Creating parameters */
00192 
00193   TePDIParameters params;
00194   
00195   // loading raster into memory since multi-thread will be used.
00196   TePDITypes::TePDIRasterPtrType input_image1_ptr;
00197   TEAGN_TRUE_OR_THROW( TePDIUtils::loadRaster( TEPDIEXAMPLESRESPATH 
00198     "cbers_rgb342_crop1.tif", input_image1_ptr, true ),
00199     "raster loading error" );
00200   params.SetParameter( "input_image1_ptr" , input_image1_ptr );
00201   
00202   params.SetParameter( "input_channel1" , (unsigned int)0 );
00203   
00204   // loading raster into memory since multi-thread will be used.
00205   TePDITypes::TePDIRasterPtrType input_image2_ptr;
00206   TEAGN_TRUE_OR_THROW( TePDIUtils::loadRaster( TEPDIEXAMPLESRESPATH 
00207     "cbers_rgb342_crop1.tif", input_image2_ptr, true ),
00208     "raster loading error" );
00209   params.SetParameter( "input_image2_ptr" , input_image2_ptr );  
00210   
00211   params.SetParameter( "input_channel2" , (unsigned int)0 );       
00212     
00213   TeSharedPtr< TeCoordPairVect > out_tie_points_ptr( new TeCoordPairVect );
00214   params.SetParameter( "out_tie_points_ptr" , out_tie_points_ptr );        
00215   
00216   TeBox input_box1( TeCoord2D( 142, 826 ) , 
00217     TeCoord2D( 542, 426 ) );
00218   params.SetParameter( "input_box1" , input_box1 );
00219   
00220   TeBox input_box2( TeCoord2D( 238, 689 ) , 
00221     TeCoord2D( 391, 473 ) );
00222   params.SetParameter( "input_box2" , input_box2 );  
00223   
00224   params.SetParameter( "pixel_x_relation" , (double)1 ); 
00225   params.SetParameter( "pixel_y_relation" , (double)1 ); 
00226   
00227   double best_cor_value = 0;
00228   params.SetParameter( "best_cor_value_ptr" , &best_cor_value ); 
00229   
00230   params.SetParameter( "enable_multi_thread" , (int)1 );
00231   params.SetParameter( "enable_threaded_raster_read" , (int)1 );
00232   
00233   TePDICorrelationMatching corr_instance; 
00234   corr_instance.ToggleProgInt( true );
00235   TEAGN_TRUE_OR_THROW( corr_instance.Reset( params ),
00236     "Algorithm reset error" )
00237     
00238   TEAGN_LOGMSG( "Algorithm started" )
00239   
00240   time_t init_time = clock() / CLOCKS_PER_SEC;
00241     
00242   TEAGN_TRUE_OR_THROW( corr_instance.Apply(),
00243     "Algorithm apply error" )      
00244     
00245   time_t end_time = clock() / CLOCKS_PER_SEC;
00246   
00247   TEAGN_LOGMSG( "Time elapsed (sameImageDifBoxesTest): " + 
00248     TeAgnostic::to_string( (long int)( end_time - init_time ) ) +
00249     " seconds" );
00250   TEAGN_WATCH( best_cor_value );
00251     
00252   /* Displaying and checking tie-points */
00253   {
00254     TeCoordPairVect::iterator it = out_tie_points_ptr->begin();
00255     TeCoordPairVect::iterator it_end = out_tie_points_ptr->end();
00256     
00257     while( it != it_end ) 
00258     {
00259       TEAGN_CHECK_EPS( it->pt1.x(), it->pt2.x(), 0.00000000000000001,
00260         "Invalid tie-point" );
00261       TEAGN_CHECK_EPS( it->pt1.y(), it->pt2.y(), 0.00000000000000001,
00262         "Invalid tie-point" );    
00263     
00264       std::cout << "[" + Te2String( it->pt1.x(),1 ) + " , " +
00265         Te2String( it->pt1.y(),1 ) + "] -> [" +
00266         Te2String( it->pt2.x(),1 ) + " , " + 
00267         Te2String( it->pt2.y(),1 ) + "]" << std::endl;
00268       
00269       ++it;
00270     }
00271   }
00272   
00273   /* Tie-points draw */
00274   
00275   raster2Tiff( input_image1_ptr, 0, TEPDIEXAMPLESBINPATH
00276     "TePDICorrelationMatching_test_sameImageTest_input_image1.tif",
00277     out_tie_points_ptr, 0 );
00278   raster2Tiff( input_image2_ptr, 0, TEPDIEXAMPLESBINPATH
00279     "TePDICorrelationMatching_test_sameImageTest_input_image2.tif",
00280     out_tie_points_ptr, 1 );    
00281     
00282   TEAGN_WATCH( (unsigned int)out_tie_points_ptr->size() );
00283   TEAGN_CHECK_EPS( 4, out_tie_points_ptr->size(),
00284     0, "Invalid tie-points number" )    
00285 }
00286 
00287 void sameImageTest2()
00288 {
00289   /* Creating parameters */
00290 
00291   TePDIParameters params;
00292   
00293   TePDITypes::TePDIRasterPtrType input_image1_ptr( new TeRaster(
00294     std::string( TEPDIEXAMPLESRESPATH "cbers_rgb342_crop1.tif" ), 'r' ) );
00295   TEAGN_TRUE_OR_THROW( input_image1_ptr->init(), 
00296     "Unable to init input_image1_ptr" );    
00297   params.SetParameter( "input_image1_ptr" , input_image1_ptr );
00298   
00299   params.SetParameter( "input_channel1" , (unsigned int)0 );
00300     
00301   TePDITypes::TePDIRasterPtrType input_image2_ptr( new TeRaster(
00302     std::string( TEPDIEXAMPLESRESPATH "cbers_rgb342_crop1.tif" ), 'r' ) );
00303   TEAGN_TRUE_OR_THROW( input_image2_ptr->init(), 
00304     "Unable to init input_image2_ptr" ); 
00305   params.SetParameter( "input_image2_ptr" , input_image2_ptr ); 
00306   
00307   params.SetParameter( "input_channel2" , (unsigned int)0 );       
00308     
00309   TeSharedPtr< TeCoordPairVect > out_tie_points_ptr( new TeCoordPairVect );
00310   params.SetParameter( "out_tie_points_ptr" , out_tie_points_ptr );        
00311   
00312   TeBox input_box2( TeCoord2D( 142, 826 ) , 
00313     TeCoord2D( 542, 426 ) );
00314   params.SetParameter( "input_box2" , input_box2 );
00315   
00316   TeBox input_box1( TeCoord2D( 238, 689 ) , 
00317     TeCoord2D( 391, 473 ) );
00318   params.SetParameter( "input_box1" , input_box1 );  
00319   
00320   params.SetParameter( "pixel_x_relation" , (double)1 ); 
00321   params.SetParameter( "pixel_y_relation" , (double)1 ); 
00322   
00323   double best_cor_value = 0;
00324   params.SetParameter( "best_cor_value_ptr" , &best_cor_value );  
00325   
00326   TePDICorrelationMatching corr_instance; 
00327   corr_instance.ToggleProgInt( true );
00328   TEAGN_TRUE_OR_THROW( corr_instance.Reset( params ),
00329     "Algorithm reset error" )
00330     
00331   TEAGN_LOGMSG( "Algorithm started" )
00332   
00333   time_t init_time = clock() / CLOCKS_PER_SEC;
00334     
00335   TEAGN_TRUE_OR_THROW( corr_instance.Apply(),
00336     "Algorithm apply error" )      
00337     
00338   time_t end_time = clock() / CLOCKS_PER_SEC;
00339   
00340   TEAGN_LOGMSG( "Time elapsed (sameImageDifBoxesTest): " + 
00341     TeAgnostic::to_string( (long int)( end_time - init_time ) ) +
00342     " seconds" );
00343     
00344   TEAGN_WATCH( best_cor_value );    
00345     
00346   /* Displaying and checking tie-points */
00347   {
00348     TeCoordPairVect::iterator it = out_tie_points_ptr->begin();
00349     TeCoordPairVect::iterator it_end = out_tie_points_ptr->end();
00350     
00351     while( it != it_end ) 
00352     {
00353       TEAGN_CHECK_EPS( it->pt1.x(), it->pt2.x(), 0.00000000000000001,
00354         "Invalid tie-point" );
00355       TEAGN_CHECK_EPS( it->pt1.y(), it->pt2.y(), 0.00000000000000001,
00356         "Invalid tie-point" );    
00357     
00358       std::cout << "[" + Te2String( it->pt1.x(),1 ) + " , " +
00359         Te2String( it->pt1.y(),1 ) + "] -> [" +
00360         Te2String( it->pt2.x(),1 ) + " , " + 
00361         Te2String( it->pt2.y(),1 ) + "]" << std::endl;
00362       
00363       ++it;
00364     }
00365   }
00366   
00367   /* Tie-points draw */
00368   
00369   raster2Tiff( input_image1_ptr, 0, TEPDIEXAMPLESBINPATH
00370     "TePDICorrelationMatching_test_sameImageTest2_input_image1.tif",
00371     out_tie_points_ptr, 0 );
00372   raster2Tiff( input_image2_ptr, 0, TEPDIEXAMPLESBINPATH
00373     "TePDICorrelationMatching_test_sameImageTest2_input_image2.tif",
00374     out_tie_points_ptr, 1 );    
00375     
00376   TEAGN_WATCH( (unsigned int)out_tie_points_ptr->size() );
00377   TEAGN_CHECK_EPS( 4, out_tie_points_ptr->size(),
00378     0, "Invalid tie-points number" )    
00379 }
00380 
00381 
00382 void halfsampledImageTest()
00383 {
00384   /* Creating parameters */
00385 
00386   TePDIParameters params;
00387   
00388   TePDITypes::TePDIRasterPtrType input_image1_ptr( new TeRaster(
00389     std::string( TEPDIEXAMPLESRESPATH "cbers_b2_crop.tif" ), 'r' ) );
00390   TEAGN_TRUE_OR_THROW( input_image1_ptr->init(), 
00391     "Unable to init input_image1_ptr" );    
00392   params.SetParameter( "input_image1_ptr" , input_image1_ptr );
00393   
00394   params.SetParameter( "input_channel1" , (unsigned int)0 );
00395     
00396   TePDITypes::TePDIRasterPtrType input_image2_ptr( new TeRaster(
00397     std::string( TEPDIEXAMPLESRESPATH "cbers_b2_crop_contraste_halfsampled.tif" ), 'r' ) );
00398   TEAGN_TRUE_OR_THROW( input_image2_ptr->init(), 
00399     "Unable to init input_image2_ptr" ); 
00400   params.SetParameter( "input_image2_ptr" , input_image2_ptr ); 
00401   
00402   params.SetParameter( "input_channel2" , (unsigned int)0 );       
00403     
00404   TeSharedPtr< TeCoordPairVect > out_tie_points_ptr( new TeCoordPairVect );
00405   params.SetParameter( "out_tie_points_ptr" , out_tie_points_ptr );        
00406   
00407   TeBox input_box1( TeCoord2D( 198, 486 ) , 
00408     TeCoord2D( 577, 186 ) );
00409   params.SetParameter( "input_box1" , input_box1 );
00410   
00411   TeBox input_box2( TeCoord2D( 143, 180 ) , 
00412     TeCoord2D( 227, 113 ) );
00413   params.SetParameter( "input_box2" , input_box2 );  
00414   
00415   params.SetParameter( "pixel_x_relation" , (double)0.5 ); 
00416   params.SetParameter( "pixel_y_relation" , (double)0.5 ); 
00417   
00418   double best_cor_value = 0;
00419   params.SetParameter( "best_cor_value_ptr" , &best_cor_value );   
00420   
00421   TePDICorrelationMatching corr_instance; 
00422   corr_instance.ToggleProgInt( true );
00423   TEAGN_TRUE_OR_THROW( corr_instance.Reset( params ),
00424     "Algorithm reset error" )
00425     
00426   TEAGN_LOGMSG( "Algorithm started" )
00427   
00428   time_t init_time = clock() / CLOCKS_PER_SEC;
00429     
00430   TEAGN_TRUE_OR_THROW( corr_instance.Apply(),
00431     "Algorithm apply error" )      
00432     
00433   time_t end_time = clock() / CLOCKS_PER_SEC;
00434   
00435   TEAGN_LOGMSG( "Time elapsed (sameImageDifBoxesTest): " + 
00436     TeAgnostic::to_string( (long int)( end_time - init_time ) ) +
00437     " seconds" );
00438   TEAGN_WATCH( best_cor_value );    
00439     
00440   /* Displaying tie-points */
00441   {
00442     TeCoordPairVect::iterator it = out_tie_points_ptr->begin();
00443     TeCoordPairVect::iterator it_end = out_tie_points_ptr->end();
00444     
00445     while( it != it_end ) {
00446       std::cout << "[" + Te2String( it->pt1.x(),1 ) + " , " +
00447         Te2String( it->pt1.y(),1 ) + "] -> [" +
00448         Te2String( it->pt2.x(),1 ) + " , " + 
00449         Te2String( it->pt2.y(),1 ) + "]" << std::endl;
00450       
00451       ++it;
00452     }
00453   }
00454   
00455   /* Tie-points draw */
00456   
00457   raster2Tiff( input_image1_ptr, 0, TEPDIEXAMPLESBINPATH
00458     "TePDICorrelationMatching_test_halfsampledImageTest_input_image1.tif",
00459     out_tie_points_ptr, 0 );
00460   raster2Tiff( input_image2_ptr, 0, TEPDIEXAMPLESBINPATH
00461     "TePDICorrelationMatching_test_halfsampledImageTest_input_image2.tif",
00462     out_tie_points_ptr, 1 );    
00463     
00464   TEAGN_WATCH( (unsigned int)out_tie_points_ptr->size() );
00465   TEAGN_CHECK_EPS( 4, out_tie_points_ptr->size(),
00466     0, "Invalid tie-points number" )    
00467 }
00468 
00469 
00470 void halfsampledImageTest2()
00471 {
00472   /* Creating parameters */
00473 
00474   TePDIParameters params;
00475   
00476   TePDITypes::TePDIRasterPtrType input_image1_ptr( new TeRaster(
00477     std::string( TEPDIEXAMPLESRESPATH "cbers_b2_crop_contraste_halfsampled.tif" ), 'r' ) );
00478   TEAGN_TRUE_OR_THROW( input_image1_ptr->init(), 
00479     "Unable to init input_image1_ptr" );    
00480   params.SetParameter( "input_image1_ptr" , input_image1_ptr );
00481   
00482   params.SetParameter( "input_channel1" , (unsigned int)0 );
00483     
00484   TePDITypes::TePDIRasterPtrType input_image2_ptr( new TeRaster(
00485     std::string( TEPDIEXAMPLESRESPATH "cbers_b2_crop.tif" ), 'r' ) );
00486   TEAGN_TRUE_OR_THROW( input_image2_ptr->init(), 
00487     "Unable to init input_image2_ptr" ); 
00488   params.SetParameter( "input_image2_ptr" , input_image2_ptr ); 
00489   
00490   params.SetParameter( "input_channel2" , (unsigned int)0 );       
00491     
00492   TeSharedPtr< TeCoordPairVect > out_tie_points_ptr( new TeCoordPairVect );
00493   params.SetParameter( "out_tie_points_ptr" , out_tie_points_ptr );        
00494   
00495   TeBox input_box2( TeCoord2D( 198, 486 ) , 
00496     TeCoord2D( 577, 186 ) );
00497   params.SetParameter( "input_box2" , input_box2 );
00498   
00499   TeBox input_box1( TeCoord2D( 143, 180 ) , 
00500     TeCoord2D( 227, 113 ) );
00501   params.SetParameter( "input_box1" , input_box1 );  
00502   
00503   params.SetParameter( "pixel_x_relation" , (double)2 ); 
00504   params.SetParameter( "pixel_y_relation" , (double)2 ); 
00505   
00506   double best_cor_value = 0;
00507   params.SetParameter( "best_cor_value_ptr" , &best_cor_value );   
00508   
00509   TePDICorrelationMatching corr_instance; 
00510   corr_instance.ToggleProgInt( true );
00511   TEAGN_TRUE_OR_THROW( corr_instance.Reset( params ),
00512     "Algorithm reset error" )
00513     
00514   TEAGN_LOGMSG( "Algorithm started" )
00515   
00516   time_t init_time = clock() / CLOCKS_PER_SEC;
00517     
00518   TEAGN_TRUE_OR_THROW( corr_instance.Apply(),
00519     "Algorithm apply error" )      
00520     
00521   time_t end_time = clock() / CLOCKS_PER_SEC;
00522   
00523   TEAGN_LOGMSG( "Time elapsed (sameImageDifBoxesTest): " + 
00524     TeAgnostic::to_string( (long int)( end_time - init_time ) ) +
00525     " seconds" );
00526   TEAGN_WATCH( best_cor_value );    
00527     
00528   /* Displaying tie-points */
00529   {
00530     TeCoordPairVect::iterator it = out_tie_points_ptr->begin();
00531     TeCoordPairVect::iterator it_end = out_tie_points_ptr->end();
00532     
00533     while( it != it_end ) {
00534       std::cout << "[" + Te2String( it->pt1.x(),1 ) + " , " +
00535         Te2String( it->pt1.y(),1 ) + "] -> [" +
00536         Te2String( it->pt2.x(),1 ) + " , " + 
00537         Te2String( it->pt2.y(),1 ) + "]" << std::endl;
00538       
00539       ++it;
00540     }
00541   }
00542   
00543   /* Tie-points draw */
00544   
00545   raster2Tiff( input_image1_ptr, 0, TEPDIEXAMPLESBINPATH
00546     "TePDICorrelationMatching_test_halfsampledImageTest2_input_image1.tif",
00547     out_tie_points_ptr, 0 );
00548   raster2Tiff( input_image2_ptr, 0, TEPDIEXAMPLESBINPATH
00549     "TePDICorrelationMatching_test_halfsampledImageTest2_input_image2.tif",
00550     out_tie_points_ptr, 1 );    
00551     
00552   TEAGN_WATCH( (unsigned int)out_tie_points_ptr->size() );
00553   TEAGN_CHECK_EPS( 4, out_tie_points_ptr->size(),
00554     0, "Invalid tie-points number" )    
00555 }
00556 
00557 
00558 int main()
00559 {
00560   TEAGN_LOGMSG( "Test started." );
00561 
00562   try{
00563     TeStdIOProgress pi;
00564     TeProgress::setProgressInterf( dynamic_cast< TeProgressBase* >( &pi ) );     
00565     
00566     time_t init_time = clock() / CLOCKS_PER_SEC;
00567     
00568     sameImageTest();
00569     sameImageTestWithMultiThread();
00570     sameImageTest2();
00571     halfsampledImageTest();
00572     halfsampledImageTest2();
00573     
00574     time_t end_time = clock() / CLOCKS_PER_SEC;
00575     
00576     TEAGN_LOGMSG( "Total elapsed time: " + 
00577       TeAgnostic::to_string( (long int)( end_time - init_time ) ) +
00578       " seconds" );    
00579   }
00580   catch( const TeException& e ){
00581     TEAGN_LOGERR( "Test Failed - " + e.message() );
00582     return EXIT_FAILURE;
00583   }  
00584 
00585   TEAGN_LOGMSG( "Test OK." );
00586   return EXIT_SUCCESS;
00587 }
00588 

Generated on Sun Jul 29 04:01:23 2012 for TerraLib - Development Source by  doxygen 1.5.3