TuttleOFX  1
TuttleOFX/libraries/tuttle/tests/time/main.cpp
Go to the documentation of this file.
00001 #include <tuttle/host/Graph.hpp>
00002 
00003 #include <iostream>
00004 
00005 #define BOOST_TEST_MODULE tuttle_time
00006 #include <tuttle/test/unit_test.hpp>
00007 //#include <boost/test/execution_monitor.hpp>
00008 //#include <boost/test/exception_safety.hpp>
00009 
00010 using namespace boost::unit_test;
00011 using namespace tuttle::host;
00012 
00013 BOOST_AUTO_TEST_SUITE( time_tests_suite01 )
00014 
00015 BOOST_AUTO_TEST_CASE( preload )
00016 {
00017         TUTTLE_LOG_INFO( "-------- LOADING OPENFX PLUGINS --------" );
00018         core().getPluginCache().addDirectoryToPath( BOOST_PP_STRINGIZE(TUTTLE_PLUGIN_PATH) );
00019         core().preload();
00020 //      TUTTLE_TLOG( TUTTLE_TRACE, core().getImageEffectPluginCache() );
00021         TUTTLE_LOG_INFO( "----------------- DONE -----------------" );
00022 }
00023 
00024 BOOST_AUTO_TEST_CASE( time_shift_offset_null )
00025 {
00026         TUTTLE_LOG_INFO( "******** PROCESS TIMESHIFT ********" );
00027         try
00028         {
00029                 TUTTLE_LOG_INFO( "--> PLUGINS CREATION" );
00030 
00031                 Graph g;
00032                 Graph::Node& read1 = g.createNode( "tuttle.jpegreader" );
00033                 //Graph::Node& invert1 = g.createNode( "tuttle.invert" );
00034                 Graph::Node& timeshift1 = g.createNode( "tuttle.timeshift" );
00035                 Graph::Node& write1 = g.createNode( "tuttle.jpegwriter" );
00036 
00037                 TUTTLE_LOG_INFO( "--> PLUGINS CONFIGURATION" );
00038                 read1.getParam( "filename" ).setValue( "TuttleOFX-data/image/jpeg/MARS@.JPG" );
00039                 timeshift1.getParam("offset").setValue( 0 );
00040                 write1.getParam( "filename" ).setValue( ".tests/output_####.jpg" );
00041 
00042                 TUTTLE_LOG_INFO( "-------- GRAPH CONNECTION --------" );
00043                 g.connect( read1, timeshift1 );
00044                 g.connect( timeshift1, write1 );
00045 
00046                 TUTTLE_LOG_INFO( "-------- GRAPH PROCESSING --------" );
00047                 std::list<std::string> outputs;
00048                 outputs.push_back( write1.getName() );
00049                 // computing at time 1 with an offset of 0, it require the frame 1
00050                 g.compute( outputs, ComputeOptions( 1 ) );
00051         }
00052         catch(... )
00053         {
00054                 std::cerr << boost::current_exception_diagnostic_information() << std::endl;
00055                 BOOST_FAIL( "Exception" );
00056         }
00057 }
00058 
00059 
00060 BOOST_AUTO_TEST_CASE( time_shift_positive_offset )
00061 {
00062         TUTTLE_LOG_INFO( "******** PROCESS TIMESHIFT ********" );
00063         try
00064         {
00065                 TUTTLE_LOG_INFO( "--> PLUGINS CREATION" );
00066 
00067                 Graph g;
00068                 Graph::Node& read1 = g.createNode( "tuttle.jpegreader" );
00069                 //Graph::Node& invert1 = g.createNode( "tuttle.invert" );
00070                 Graph::Node& timeshift1 = g.createNode( "tuttle.timeshift" );
00071                 Graph::Node& write1 = g.createNode( "tuttle.jpegwriter" );
00072 
00073                 TUTTLE_LOG_INFO( "--> PLUGINS CONFIGURATION" );
00074                 read1.getParam( "filename" ).setValue( "TuttleOFX-data/image/jpeg/MARS@.JPG" );
00075                 timeshift1.getParam("offset").setValue( 1 );
00076                 write1.getParam( "filename" ).setValue( ".tests/output_####.jpg" );
00077 
00078                 TUTTLE_LOG_INFO( "-------- GRAPH CONNECTION --------" );
00079                 g.connect( read1, timeshift1 );
00080                 g.connect( timeshift1, write1 );
00081 
00082                 TUTTLE_LOG_INFO( "-------- GRAPH PROCESSING --------" );
00083                 std::list<std::string> outputs;
00084                 outputs.push_back( write1.getName() );
00085                 // computing at time 2 with an offset of 1, it require the frame 1
00086                 g.compute( outputs, ComputeOptions( 2 ) );
00087         }
00088         catch(... )
00089         {
00090                 std::cerr << boost::current_exception_diagnostic_information() << std::endl;
00091                 BOOST_FAIL( "Exception" );
00092         }
00093 }
00094 
00095 BOOST_AUTO_TEST_CASE( time_shift_negative_offset )
00096 {
00097         TUTTLE_LOG_INFO( "******** PROCESS TIMESHIFT ********" );
00098         try
00099         {
00100                 TUTTLE_LOG_INFO( "--> PLUGINS CREATION" );
00101 
00102                 Graph g;
00103                 Graph::Node& read1 = g.createNode( "tuttle.jpegreader" );
00104                 //Graph::Node& invert1 = g.createNode( "tuttle.invert" );
00105                 Graph::Node& timeshift1 = g.createNode( "tuttle.timeshift" );
00106                 Graph::Node& write1 = g.createNode( "tuttle.jpegwriter" );
00107 
00108                 TUTTLE_LOG_INFO( "--> PLUGINS CONFIGURATION" );
00109                 read1.getParam( "filename" ).setValue( "TuttleOFX-data/image/jpeg/MARS@.JPG" );
00110                 timeshift1.getParam("offset").setValue( 3 );
00111                 write1.getParam( "filename" ).setValue( ".tests/output_####.jpg" );
00112 
00113                 TUTTLE_LOG_INFO( "-------- GRAPH CONNECTION --------" );
00114                 g.connect( read1, timeshift1 );
00115                 g.connect( timeshift1, write1 );
00116 
00117                 TUTTLE_LOG_INFO( "-------- GRAPH PROCESSING --------" );
00118                 std::list<std::string> outputs;
00119                 outputs.push_back( write1.getName() );
00120                 // computing at time 3 with an offset of -2, it require the frame 1
00121                 g.compute( outputs, ComputeOptions( 4 ) );
00122         }
00123         catch(... )
00124         {
00125                 std::cerr << boost::current_exception_diagnostic_information() << std::endl;
00126                 BOOST_FAIL( "Exception" );
00127         }
00128 }
00129 
00130 
00131 BOOST_AUTO_TEST_CASE( time_shift_negative_offset_forceIdentity )
00132 {
00133         TUTTLE_LOG_INFO( "******** PROCESS TIMESHIFT ********" );
00134         try
00135         {
00136                 TUTTLE_LOG_INFO( "--> PLUGINS CREATION" );
00137 
00138                 Graph g;
00139                 Graph::Node& read1 = g.createNode( "tuttle.jpegreader" );
00140                 //Graph::Node& invert1 = g.createNode( "tuttle.invert" );
00141                 Graph::Node& timeshift1 = g.createNode( "tuttle.timeshift" );
00142                 Graph::Node& write1 = g.createNode( "tuttle.jpegwriter" );
00143 
00144                 TUTTLE_LOG_INFO( "--> PLUGINS CONFIGURATION" );
00145                 read1.getParam( "filename" ).setValue( "TuttleOFX-data/image/jpeg/MARS@.JPG" );
00146                 timeshift1.getParam("offset").setValue( 3 );
00147                 write1.getParam( "filename" ).setValue( ".tests/output_####.jpg" );
00148 
00149                 TUTTLE_LOG_INFO( "-------- GRAPH CONNECTION --------" );
00150                 g.connect( read1, timeshift1 );
00151                 g.connect( timeshift1, write1 );
00152 
00153                 TUTTLE_LOG_INFO( "-------- GRAPH PROCESSING --------" );
00154                 std::list<std::string> outputs;
00155                 outputs.push_back( write1.getName() );
00156                 // computing at time 3 with an offset of -2, it require the frame 1
00157                 g.compute( outputs, ComputeOptions( 4 )
00158                                 .setForceIdentityNodesProcess()
00159                         );
00160         }
00161         catch(... )
00162         {
00163                 std::cerr << boost::current_exception_diagnostic_information() << std::endl;
00164                 BOOST_FAIL( "Exception" );
00165         }
00166 }
00167 
00168 
00169 BOOST_AUTO_TEST_SUITE_END()
00170