5 #include <cpPlugins/Interface/Interface.h>
6 #include <cpPlugins/Interface/ProcessObject.h>
8 int main( int argc, char* argv[] )
13 << "Usage: " << argv[ 0 ]
15 << " input_image output_image"
16 << " dimensions pixel_type is_color" << std::endl;
20 std::string plugins_file = argv[ 1 ];
21 std::string input_image_file = argv[ 2 ];
22 std::string output_image_file = argv[ 3 ];
23 std::string dimensions = argv[ 4 ];
24 std::string pixel_type = argv[ 5 ];
25 bool is_color = ( std::atoi( argv[ 6 ] ) == 1 );
28 typedef cpPlugins::Interface::Interface TInterface;
29 typedef TInterface::TClasses TClasses;
32 plugins.Load( plugins_file );
35 typedef cpPlugins::Interface::ProcessObject TProcessObject;
36 typedef TProcessObject::TParameters TParameters;
37 cpPlugins::Interface::ProcessObject* reader;
38 cpPlugins::Interface::ProcessObject* writer;
41 dynamic_cast< TProcessObject* >(
42 plugins.CreateObject( "cpPlugins::Plugins::ImageReader" )
46 std::cerr << "No suitable reader found in plugins." << std::endl;
51 dynamic_cast< TProcessObject* >(
52 plugins.CreateObject( "cpPlugins::Plugins::ImageWriter" )
57 std::cerr << "No suitable writer found in plugins." << std::endl;
63 TParameters reader_params = reader->GetDefaultParameters( );
64 reader_params[ "FileName" ].second = input_image_file;
65 reader_params[ "PixelType" ].second = pixel_type;
66 reader_params[ "ImageDimension" ].second = dimensions;
67 reader_params[ "IsColorImage" ].second = ( is_color )? "1": "0";
68 reader->SetParameters( reader_params );