Hugin trunk 0.1
Loading...
Searching...
No Matches
pto_merge.cpp
Go to the documentation of this file.
1// -*- c-basic-offset: 4 -*-
2
13/* This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public
15 * License as published by the Free Software Foundation; either
16 * version 2 of the License, or (at your option) any later version.
17 *
18 * This software is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public
24 * License along with this software. If not, see
25 * <http://www.gnu.org/licenses/>.
26 *
27 */
28
29#include <fstream>
30#include <sstream>
31#include <getopt.h>
32#include <panodata/Panorama.h>
33
34static void usage(const char* name)
35{
36 std::cout << name << ": merges several project files" << std::endl
37 << "pto_merge version " << hugin_utils::GetHuginVersion() << std::endl
38 << std::endl
39 << "Usage: " << name << " [options] input.pto input2.pto ..." << std::endl
40 << std::endl
41 << " Options:" << std::endl
42 << " -o, --output=file.pto Output Hugin PTO file." << std::endl
43 << " Default: <filename>_merge.pto" << std::endl
44 << " -h, --help Shows this help" << std::endl
45 << std::endl;
46}
47
48int main(int argc, char* argv[])
49{
50 // parse arguments
51 const char* optstring = "o:h";
52
53 static struct option longOptions[] =
54 {
55 {"output", required_argument, NULL, 'o' },
56 {"help", no_argument, NULL, 'h' },
57 0
58 };
59
60 int c;
61 std::string output;
62 while ((c = getopt_long (argc, argv, optstring, longOptions,nullptr)) != -1)
63 {
64 switch (c)
65 {
66 case 'o':
67 output = optarg;
68 break;
69 case 'h':
71 return 0;
72 case ':':
73 case '?':
74 // missing argument or invalid switch
75 return 1;
76 break;
77 default:
78 // this should not happen
79 abort();
80 }
81 }
82
83 if (argc - optind < 2)
84 {
85 std::cerr << hugin_utils::stripPath(argv[0]) << ": at least 2 project files needed" << std::endl << std::endl;
86 return 1;
87 };
88
89 std::string input=argv[optind];
90 // read panorama
93 {
94 return 1;
95 };
96
97 optind++;
98 while(optind<argc)
99 {
101 const std::string input2=argv[optind];
102 if (!pano2.ReadPTOFile(input2, hugin_utils::getPathPrefix(input2)))
103 {
104 return 1;
105 };
106 // read EXIF data, needed for lens detection in merged pano
107 for (size_t i = 0; i < pano.getNrOfImages(); ++i)
108 {
110 srcImg.readEXIF();
111 pano.setSrcImage(i, srcImg);
112 };
113 pano.mergePanorama(pano2);
114 optind++;
115 };
116
117 //write output
118 // Set output .pto filename if not given
121 {
122 std::cout << std::endl << "Written project file " << output << std::endl;
123 };
124
125 return 0;
126}
static void usage()
Definition Main.cpp:32
Model for a panorama.
Definition Panorama.h:153
const SrcPanoImage & getImage(std::size_t nr) const
get a panorama image, counting starts with 0
Definition Panorama.h:211
bool ReadPTOFile(const std::string &filename, const std::string &prefix="")
read pto file from the given filename into Panorama object it does some checks on the file and issues...
void mergePanorama(const Panorama &newPano)
merges the panorama with the given pano
void setSrcImage(unsigned int nr, const SrcPanoImage &img)
set input image parameters
bool WritePTOFile(const std::string &filename, const std::string &prefix="")
write data to given pto file
std::size_t getNrOfImages() const
number of images.
Definition Panorama.h:205
All variables of a source image.
std::string GetHuginVersion()
return a string with version numbers
Definition utils.cpp:907
std::string GetOutputFilename(const std::string &out, const std::string &in, const std::string &suffix)
construct output filename, if ouput is known return this value otherwise use the input filename and a...
Definition utils.cpp:420
std::string stripPath(const std::string &filename)
remove the path of a filename (mainly useful for gui display of filenames)
Definition utils.cpp:160
std::string getPathPrefix(const std::string &filename)
Get the path to a filename.
Definition utils.cpp:184
int main(int argc, char *argv[])
Definition pto_merge.cpp:48
std::vector< deghosting::BImagePtr > threshold(const std::vector< deghosting::FImagePtr > &inputImages, const double threshold, const uint16_t flags)
Threshold function used for creating alpha masks for images.
Definition threshold.h:41