00001
00026 #include <hugin_config.h>
00027 #include <hugin_version.h>
00028 #include <../hugin1/hugin/config_defaults.h>
00029
00030 #include <fstream>
00031 #include <sstream>
00032
00033 #include <algorithm>
00034 #include <cctype>
00035 #include <string>
00036
00037 #include <vigra/error.hxx>
00038 #include <vigra/impex.hxx>
00039
00040 #ifdef WIN32
00041 #include <getopt.h>
00042 #else
00043 #include <unistd.h>
00044 #endif
00045
00046 #include <hugin_basic.h>
00047 #include <hugin_utils/platform.h>
00048 #include <algorithms/panorama_makefile/PanoramaMakefilelibExport.h>
00049
00050 #include <tiffio.h>
00051
00052
00053 using namespace vigra;
00054 using namespace HuginBase;
00055 using namespace hugin_utils;
00056 using namespace std;
00057
00058 static void usage(const char * name)
00059 {
00060 cerr << name << ": create a makefile for stitching" << std::endl
00061 << std::endl
00062 << "pto2mk version " << DISPLAY_VERSION << std::endl
00063 << std::endl
00064 << "Usage: " << name << " -o <output_makefile> -p <output_prefix> project_file" << std::endl
00065 << " Options: " << std::endl
00066 << " -o file output makefile" << std::endl
00067 << " -p output_prefix prefix of output panorama" << std::endl
00068 << std::endl;
00069 }
00070
00071 int main(int argc, char *argv[])
00072 {
00073
00074 const char * optstring = "ho:p:";
00075 int c;
00076
00077 opterr = 0;
00078 std::string mkfile;
00079 std::string prefix;
00080 while ((c = getopt (argc, argv, optstring)) != -1)
00081 {
00082 switch (c) {
00083 case 'o':
00084 mkfile = optarg;
00085 break;
00086 case 'p':
00087 prefix = optarg;
00088 break;
00089 case 'h':
00090 usage(argv[0]);
00091 return 0;
00092 default:
00093 usage(argv[0]);
00094 abort ();
00095 }
00096 }
00097
00098 if (prefix == "" || mkfile == "") {
00099 std::cerr << "Please specify output makefile and prefix" << std::endl;
00100 usage(argv[0]);
00101 return 1;
00102 }
00103
00104 unsigned nCmdLineImgs = argc - optind;
00105 cout << "number of cmdline args: " << nCmdLineImgs << endl;
00106 if ( nCmdLineImgs != 1) {
00107 std::cerr << "No project file given" << std::endl;
00108 usage(argv[0]);
00109 return 1;
00110 }
00111
00112 const char * ptoFile = argv[optind];
00113 Panorama pano;
00114 ifstream prjfile(ptoFile);
00115 if (prjfile.bad()) {
00116 cerr << "could not open script : " << ptoFile << std::endl;
00117 exit(1);
00118 }
00119 pano.setFilePrefix(hugin_utils::getPathPrefix(ptoFile));
00120 AppBase::DocumentData::ReadWriteError err = pano.readData(prjfile);
00121 if (err != AppBase::DocumentData::SUCCESSFUL) {
00122 cerr << "error while parsing panos tool script: " << ptoFile << std::endl;
00123 exit(1);
00124 }
00125
00126
00127 HuginBase::PanoramaMakefilelibExport::PTPrograms progs;
00128
00129 progs.exiftool_opts = HUGIN_EXIFTOOL_COPY_ARGS;
00130
00131 UIntSet activeImgs = pano.getActiveImages();
00132
00133 PanoramaOptions opts = pano.getOptions();
00134
00135 std::ofstream makeFileStream(mkfile.c_str());
00136 if (!makeFileStream.good()) {
00137 std::cerr << "Could not open output makefile" << std::endl;
00138 return 1;
00139 }
00140
00141 std::vector<std::string> outputFiles;
00142 HuginBase::PanoramaMakefilelibExport::createMakefile(pano,
00143 activeImgs,
00144 ptoFile,
00145 prefix,
00146 progs,
00147 "",
00148 outputFiles,
00149 makeFileStream,
00150 "",
00151 true,
00152 0);
00153
00154 return 0;
00155 }