Hugin trunk 0.1
Loading...
Searching...
No Matches
icpfind.cpp
Go to the documentation of this file.
1// -*- c-basic-offset: 4 -*-
2
11/* This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
15 *
16 * This software is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public
22 * License along with this software. If not, see
23 * <http://www.gnu.org/licenses/>.
24 *
25 */
26
27#include "icpfind.h"
28
29#include <fstream>
30#include <sstream>
31
33#include <panodata/Panorama.h>
34#include <base_wx/platform.h>
36#if defined __WXGTK__
37#include "base_wx/wxPlatform.h"
38#endif
39
40extern "C"
41{
42 #include <pano13/filter.h> // for PT_setProgressFcn, PT_setInfoDlgFcn
43}
44
46{
47#if defined __WXGTK__
49#endif
50 wxConfig config("hugin");
51 //read cp detectors settings
52 CPDetectorConfig cpdetector_config;
53 cpdetector_config.Read(&config);
54 //write current cp detectors settings
55 cpdetector_config.Write(&config);
56 config.Flush();
57
58 if(m_setting<0 || m_setting>=cpdetector_config.settings.size())
59 {
60 m_cpsetting=cpdetector_config.settings[cpdetector_config.GetDefaultGenerator()];
61 }
62 else
63 {
64 m_cpsetting=cpdetector_config.settings[m_setting];
65 };
66
67 if(m_matches==-1)
68 {
69 m_matches=config.Read("/Assistant/nControlPoints", HUGIN_ASS_NCONTROLPOINTS);
70 };
71};
72
74{
75 parser.AddSwitch("h","help","shows this help message");
76 parser.AddOption("s","setting","used setting",wxCMD_LINE_VAL_NUMBER);
77 parser.AddOption("m","matches","number of matches",wxCMD_LINE_VAL_NUMBER);
78 parser.AddOption("o","output","output project",wxCMD_LINE_VAL_STRING,wxCMD_LINE_OPTION_MANDATORY);
80};
81
83{
84 // we don't call the parents method of OnCmdLineParse, this will pull in other options we don't want
85 if(!parser.Found("s",&m_setting))
86 {
87 m_setting=-1;
88 };
89 if(!parser.Found("m",&m_matches))
90 {
91 m_matches=-1;
92 };
93 parser.Found("o",&m_output);
94 m_input=parser.GetParam();
95 return true;
96};
97
98// dummy panotools progress functions
99static int ptProgress( int command, char* argument )
100{
101 return 1;
102}
103static int ptinfoDlg( int command, char* argument )
104{
105 return 1;
106}
107
109{
111 //read input project
113 int ptoVersion = 0;
114 wxFileName file(m_input);
115 file.MakeAbsolute();
116 std::ifstream in((const char *)file.GetFullPath().mb_str(HUGIN_CONV_FILENAME));
117 if(!in.good())
118 {
119 std::cerr << "could not open script : " << file.GetFullPath().char_str() << std::endl;
120 return 1;
121 }
122 if(!newPano.loadPTScript(in, ptoVersion,(std::string)file.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR).mb_str(HUGIN_CONV_FILENAME)))
123 {
124 std::cerr << "could not parse script: " << file.GetFullPath().char_str() << std::endl;
125 return 1;
126 };
127 pano.setMemento(newPano);
128
129 //match images
132 fill_set(imgs,0, pano.getNrOfImages()-1);
133 //deactivate libpano messages
139 if(cps.empty())
140 {
141 return 1;
142 };
143 for(unsigned i=0;i<cps.size();i++)
144 {
145 pano.addCtrlPoint(cps[i]);
146 };
147
148 //write output
150 outputFile.MakeAbsolute();
151 const std::string output(outputFile.GetFullPath().mb_str(HUGIN_CONV_FILENAME));
153 {
154 std::cout << std::endl << "Written output to " << output << std::endl;
155 };
156
157 return 0;
158};
159
Base class for control point creators.
class for storing settings of different control point generators
unsigned int GetDefaultGenerator()
return index of default generator (this one is used for assistent)
void Read(wxConfigBase *config=wxConfigBase::Get(), wxString loadFromFile=wxEmptyString)
read the settings of different cp generators from config
void Write(wxConfigBase *config=wxConfigBase::Get())
writes the settings of different cp generators to config
ArraySettings settings
array which stores the different autopano settings
Memento class for a Panorama object.
Definition Panorama.h:50
bool loadPTScript(std::istream &i, int &ptoVersion, const std::string &prefix="")
load a Hugin file
void setMemento(const PanoramaMemento &memento)
set the internal state
unsigned int addCtrlPoint(const ControlPoint &point)
add a new control point.
Definition Panorama.cpp:381
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
wxString m_output
Definition icpfind.h:35
HuginBase::Panorama pano
Definition icpfind.h:37
virtual bool OnCmdLineParsed(wxCmdLineParser &parser)
processes the command line parameters
Definition icpfind.cpp:82
virtual void OnInitCmdLine(wxCmdLineParser &parser)
set the parameters for the command line parser
Definition icpfind.cpp:73
virtual int OnRun()
the main procedure of iCPApp
Definition icpfind.cpp:108
long m_setting
Definition icpfind.h:32
long m_matches
Definition icpfind.h:33
CPDetectorSetting m_cpsetting
Definition icpfind.h:36
wxString m_input
Definition icpfind.h:34
void ReadDetectorConfig()
read the CPDetectorConfig from file/registry
Definition icpfind.cpp:45
#define HUGIN_ASS_NCONTROLPOINTS
implementation of huginApp Class
#define HUGIN_CONV_FILENAME
Definition platform.h:40
static int ptProgress(int command, char *argument)
Definition icpfind.cpp:99
static int ptinfoDlg(int command, char *argument)
Definition icpfind.cpp:103
std::vector< ControlPoint > CPVector
std::set< unsigned int > UIntSet
std::string getPathPrefix(const std::string &filename)
Get the path to a filename.
Definition utils.cpp:184
void fill_set(_Container &c, typename _Container::key_type begin, typename _Container::key_type end)
Definition stl_utils.h:81
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
platform/compiler specific stuff.