TuttleOFX
1
|
00001 #include <tuttle/common/utils/global.hpp> 00002 00003 #include <tuttle/host/Graph.hpp> 00004 00005 void sam_terminate( void ) 00006 { 00007 TUTTLE_LOG_ERROR( "[io example] Sorry, Sam has encountered a fatal error." ); 00008 TUTTLE_LOG_ERROR( "[io example] Please report this bug." ); 00009 exit( -1 ); 00010 } 00011 00012 void sam_unexpected( void ) 00013 { 00014 TUTTLE_LOG_ERROR( "[io example] Sorry, Sam has encountered a fatal error." ); 00015 TUTTLE_LOG_ERROR( "[io example] Please report this bug." ); 00016 BOOST_THROW_EXCEPTION( std::runtime_error( "Sorry, Sam has encountered an unexpected exception.\nPlease report this bug." ) ); 00017 } 00018 00019 int main( int argc, char** argv ) 00020 { 00021 boost::shared_ptr<tuttle::common::formatters::Formatter> formatter( tuttle::common::formatters::Formatter::get() ); 00022 boost::shared_ptr<tuttle::common::Color> color( tuttle::common::Color::get() ); 00023 formatter->init_logging(); 00024 color->disable(); 00025 00026 std::set_terminate( &sam_terminate ); 00027 std::set_unexpected( &sam_unexpected ); 00028 try 00029 { 00030 using namespace tuttle::host; 00031 TUTTLE_LOG_INFO( "[canny example] Preload plugins" ); 00032 core().preload(); 00033 00034 TUTTLE_TLOG( TUTTLE_INFO, core().getImageEffectPluginCache() ); 00035 00036 TUTTLE_LOG_INFO( "[canny example] Preload done" ); 00037 00038 TUTTLE_LOG_INFO( "[canny example] create plugins" ); 00039 Graph g; 00040 // Graph::Node& read1 = g.createNode( "tuttle.ffmpegreader" ); 00041 Graph::Node& read1 = g.createNode( "tuttle.pngreader" ); 00042 Graph::Node& read2 = g.createNode( "tuttle.dpxreader" ); 00043 Graph::Node& read3 = g.createNode( "tuttle.exrreader" ); 00044 Graph::Node& bitdepth = g.createNode( "tuttle.bitdepth" ); 00045 Graph::Node& invert1 = g.createNode( "tuttle.invert" ); 00046 /*Graph::Node& invert2 = */ g.createNode( "tuttle.invert" ); 00047 /*Graph::Node& invert2 = */ g.createNode( "tuttle.invert" ); 00048 Graph::Node& invert2 = g.createNode( "tuttle.invert" ); 00049 Graph::Node& blur1 = g.createNode( "tuttle.blur" ); 00050 Graph::Node& invert4 = g.createNode( "tuttle.invert" ); 00051 // Graph::Node& crop1 = g.createNode( "tuttle.crop" ); 00052 Graph::Node& merge1 = g.createNode( "tuttle.merge" ); 00053 Graph::Node& bitdepth1 = g.createNode( "tuttle.bitdepth" ); 00054 Graph::Node& write1 = g.createNode( "tuttle.pngwriter" ); 00055 Graph::Node& write2 = g.createNode( "tuttle.dpxwriter" ); 00056 Graph::Node& write3 = g.createNode( "tuttle.exrwriter" ); 00057 Graph::Node& write4 = g.createNode( "tuttle.ffmpegwriter" ); 00058 00059 TUTTLE_LOG_INFO( "[canny example] set plugins parameters" ); 00060 // Setup parameters 00061 // read1.getParam( "filename" ).setValue( "data/input1.avi" ); 00062 read1.getParam( "filename" ).setValue( "data/input.png" ); 00063 read2.getParam( "filename" ).setValue( "data/input.dpx" ); 00064 read3.getParam( "filename" ).setValue( "data/input.exr" ); 00065 bitdepth.getParam( "outputBitDepth" ).setValue( 3 ); 00066 00067 TUTTLE_LOG_VAR( TUTTLE_INFO, bitdepth.getParam( "outputBitDepth" ).getStringValue() ); 00068 00069 blur1.getParam( "size" ).setValue( 6.5, 15.0 ); 00070 // blur1.getParam( "size" ).setAtIndex( 65.43, 1 ); 00071 // crop1.getParam( "Down" ).setValue( 400 ); 00072 write1.getParam( "filename" ).setValue( "data/output1.png" ); 00073 write2.getParam( "filename" ).setValue( "data/output2.dpx" ); 00074 write3.getParam( "filename" ).setValue( "data/output3.exr" ); 00075 write4.getParam( "filename" ).setValue( "data/output4.avi" ); 00076 00077 TUTTLE_LOG_INFO( "[canny example] connect plugins" ); 00078 g.connect( read1, bitdepth ); 00079 g.connect( bitdepth, invert1 ); 00080 g.connect( invert1, invert2 ); 00081 g.connect( invert2, blur1 ); 00082 g.connect( blur1, write1 ); 00083 g.connect( invert1, invert4 ); 00084 g.connect( invert4, write2 ); 00085 g.connect( invert1, write3 ); 00086 00087 g.connect( invert1, bitdepth1 ); 00088 g.connect( bitdepth1, merge1.getAttribute( "SourceA" ) ); 00089 g.connect( read3, merge1.getAttribute( "SourceB" ) ); 00090 // g.connect( merge1, crop1 ); 00091 g.connect( merge1, write4 ); 00092 00093 TUTTLE_LOG_INFO( "[canny example] process graph" ); 00094 std::list<std::string> outputs; 00095 outputs.push_back( write1.getName() ); 00096 // outputs.push_back( write2.getName() ); 00097 // outputs.push_back( write3.getName() ); 00098 outputs.push_back( write4.getName() ); 00099 g.compute( outputs ); 00100 TUTTLE_LOG_INFO( "[canny example] finish" ); 00101 } 00102 catch( tuttle::exception::Common& e ) 00103 { 00104 TUTTLE_LOG_ERROR( "Tuttle Exception : main de sam." ); 00105 TUTTLE_LOG_ERROR( boost::diagnostic_information( e ) ); 00106 return -1; 00107 } 00108 catch(... ) 00109 { 00110 TUTTLE_LOG_ERROR( "Exception ... : main de sam." ); 00111 TUTTLE_LOG_ERROR( boost::current_exception_diagnostic_information() ); 00112 return -1; 00113 } 00114 00115 return 0; 00116 } 00117