27 #include "hugin_config.h"
65 long style,
const wxString& name)
68 if (! wxPanel::Create(parent,
id, pos, size, style, name))
73 wxXmlResource::Get()->LoadPanel(
this, wxT(
"optimize_photo_panel"));
74 wxPanel * panel = XRCCTRL(*
this,
"optimize_photo_panel", wxPanel);
76 wxBoxSizer *topsizer =
new wxBoxSizer( wxVERTICAL );
77 topsizer->Add(panel, 1, wxEXPAND, 0);
88 XRCCTRL(*
this,
"optimize_photo_panel_splitter", wxSplitterWindow)->SetSashGravity(0.66);
139 wxWindowDisabler winDisable;
149 wxMessageBox(_(
"The project does not contain any active images.\nPlease activate at least 2 images in the (fast) preview window.\nOptimization canceled."),
155 wxICON_ERROR | wxOK);
175 XRCCTRL(*
this,
"optimize_photo_panel_optimize", wxButton)->Enable(pano.
getNrOfImages()>1);
176 XRCCTRL(*
this,
"optimize_photo_panel_reset", wxButton)->Enable(pano.
getNrOfImages()>0);
187 HuginBase::ImageVariableGroup::IVE_EMoRParams,
188 HuginBase::ImageVariableGroup::IVE_ResponseType,
189 HuginBase::ImageVariableGroup::IVE_VigCorrMode,
190 HuginBase::ImageVariableGroup::IVE_RadialVigCorrCoeff,
191 HuginBase::ImageVariableGroup::IVE_RadialVigCorrCenterShift
194 std::vector<PanoCommand::PanoCommand *> commands;
199 std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> links_needed;
200 links_needed.clear();
201 for (
int v = 0; v < 5; v++)
205 links_needed.insert(vars[v]);
208 if (!links_needed.empty())
214 if (!commands.empty()) {
215 int ok = wxMessageBox(_(
"The same vignetting and response parameters should\nbe applied for all images of a lens.\nCurrently each image can have different parameters.\nLink parameters?"), _(
"Link parameters"), wxYES_NO | wxICON_INFORMATION);
225 for (std::vector<PanoCommand::PanoCommand *>::iterator it = commands.begin(); it != commands.end(); ++it)
240 for(
unsigned int i=0;i<optvars.size() && !valid;i++)
250 wxMessageBox(_(
"You selected no parameters to optimize.\nTherefore optimization will be canceled."), _(
"Exposure optimization"), wxOK | wxICON_INFORMATION);
257 std::vector<vigra_ext::PointPairRGB> points;
266 std::vector<vigra::FRGBImage *> srcImgs;
268 float imageStepSize = 1 / 255.0f;
271 ImageCache::EntryPtr e = ImageCache::getInstance().getSmallImage(optPano.
getImage(i).getFilename());
274 wxMessageBox(_(
"Error: could not load all images"), _(
"Error"));
278 vigra::FRGBImage * img =
new vigra::FRGBImage;
279 if (e->imageFloat && e->imageFloat->size().area() > 0)
281 if (e->mask->size().area() > 0)
283 vigra::BImage maskSmall;
287 imageStepSize =
std::min(imageStepSize, (minmax.
max - minmax.
min) / 16384.0f);
294 imageStepSize =
std::min(imageStepSize, (minmax.
max - minmax.
min) / 16384.0f);
300 if (e->image16 && e->image16->size().area() > 0)
304 vigra::functor::Arg1() / vigra::functor::Param(65535.0));
306 imageStepSize =
std::min(imageStepSize, 1 / 65536.0f);
312 vigra::functor::Arg1() / vigra::functor::Param(255.0));
314 imageStepSize =
std::min(imageStepSize, 1 / 255.0f);
317 srcImgs.push_back(img);
318 limits.push_back(limit);
319 if (!progress.updateDisplayValue())
327 if (!progress.updateDisplayValue())
333 wxMessageBox(_(
"Error: no overlapping points found, Photometric optimization aborted"), _(
"Error"));
337 progress.setMaximum(0);
338 progress.updateDisplay(_(
"Optimize..."));
377 if (progress.wasCancelled())
382 catch (std::exception & error)
384 wxMessageBox(_(
"Internal error during photometric optimization:\n") + wxString(error.what(), wxConvLocal), _(
"Internal error"));
391 int ret = wxMessageBox(wxString::Format(_(
"Photometric optimization results:\nAverage difference (RMSE) between overlapping pixels: %.2f gray values (0..255)\n\nApply results?"), error*255),
392 _(
"Photometric optimization finished"), wxYES_NO | wxICON_INFORMATION,
this);
399 std::vector<PanoCommand::PanoCommand*> optCommands;
439 : wxXmlResourceHandler()
448 cp->Create(m_parentAsWindow,
450 GetPosition(), GetSize(),
451 GetStyle(wxT(
"style")),
461 return IsOfClass(node, wxT(
"OptimizePhotometricPanel"));
Base class for all panorama commands.
void reduceToNextLevel(ImageIn &in, ImageOut &out)
bool getVarLinkedInPart(ImageVariableEnum variable, std::size_t part) const
Get the linked status of a particular variable for a given part number.
An ImageVariableGroup is a collection of image variables that can have some shared variable values...
void OnCheckOnlyActiveImages(wxCommandEvent &e)
handle "only active images" checkbox
update variables of a group of images
void SetGroupMode(GroupMode newMode)
sets the group mode to given mode
class for storing the limits of an image used by the sampler to exclude too dark or too bright pixel ...
virtual PanoCommand::PanoCommand * GetCommand(wxWindow *parent, HuginBase::Panorama &pano, HuginBase::UIntSet images, GuiLevel guiLevel)
returns the appropriate PanoCommand::PanoCommand to be inserted into GlobalCmdHistory, checks if operation is enabled
void SetGuiLevel(GuiLevel newGuiLevel)
static double calcMeanExposure(const PanoramaData &pano)
declaration of main image tree control
bool removeObserver(PanoramaObserver *observer)
remove a panorama observer.
bool set_contains(const _Container &c, const typename _Container::key_type &key)
void SetOptimizeOnlyActiveImages(const bool onlyActive)
sets the status of the "optimize only active images" menu item
#define DEBUG_ASSERT(cond)
include file for the hugin project
PhotometricOptimizeMode
local optimize definition.
Panorama getSubset(const UIntSet &imgs) const
get a subset of the panorama
vigra::pair< typename ROIImage< Image, Mask >::image_const_traverser, typename ROIImage< Image, Mask >::ImageConstAccessor > srcImage(const ROIImage< Image, Mask > &img)
virtual wxObject * DoCreateResource()
Definition of PanoOperation class.
unsigned int colorReferenceImage
void Init(HuginBase::Panorama *pano)
initialization, connects all control with Panorama, register observer
PanoCommand to combine other PanoCommands.
wxCheckBox * m_only_active_images_cb
std::set< unsigned int > UIntSet
std::vector< VariableMap > VariableMapVector
PointPairs getResultPoints()
void MarkActiveImages(const bool markActive)
sets the flag, if active/disabled image should be marked with different colour
HuginBase::Panorama * m_pano
ConstImageVariableGroup & getLenses()
Get the ImageVariableGroup representing the group of lens variables.
const OptimizeVector & getOptimizeVector() const
return the optimize settings stored inside panorama
some definitions to work with optimizer master switches
void SetDisplayMode(DisplayMode newMode)
sets the display mode to given mode
VariableMapVector getVariables() const
get variables of this panorama
std::size_t getNrOfImages() const
number of images.
static MainFrame * Get()
hack.. kind of a pseudo singleton...
Link a set of lens variables for some lens.
void SetOnlyActiveImages(const bool onlyActive)
for external setting of "only active image" checkbox
static void smartOptimizePhotometric(PanoramaData &pano, PhotometricOptimizeMode mode, const std::vector< vigra_ext::PointPairRGB > &correspondences, const float imageStepSize, AppBase::ProgressDisplay *progress, double &error)
use various heuristics to decide what to optimize.
IMPLEMENT_DYNAMIC_CLASS(wxTreeListHeaderWindow, wxWindow)
virtual void panoramaImagesChanged(HuginBase::Panorama &pano, const HuginBase::UIntSet &imgNr)
receives notification about panorama changes
Make an ImageVariableGroup for lenses and other common concepts.
virtual ~OptimizePhotometricPanel()
static GlobalCmdHist & getInstance()
virtual void panoramaChanged(HuginBase::Panorama &pano)
receives notification about panorama changes
void runOptimizer(const HuginBase::UIntSet &img)
void OnOptimizeButton(wxCommandEvent &e)
run the optimizer
static void optimizePhotometric(PanoramaData &pano, const OptimizeVector &vars, const PointPairs &correspondences, const float imageStepSize, AppBase::ProgressDisplay *progress, double &error)
void addCommand(PanoCommand *command, bool execute=true)
Adds a command to the history.
vigra::pair< typename ROIImage< Image, Alpha >::image_traverser, typename ROIImage< Image, Alpha >::ImageAccessor > destImage(ROIImage< Image, Alpha > &img)
void SetGuiLevel(GuiLevel newSetting)
sets the GuiLevel of the control
vigra::triple< typename ROIImage< Image, Mask >::image_const_traverser, typename ROIImage< Image, Mask >::image_const_traverser, typename ROIImage< Image, Mask >::ImageConstAccessor > srcImageRange(const ROIImage< Image, Mask > &img)
helper function for ROIImages
UIntSet getActiveImages() const
get active images
VALUETYPE min
the current min
HuginBase::UIntSet GetSelectedImages()
returns the selected images
void addObserver(PanoramaObserver *o)
add a panorama observer.
include file for the hugin project
const GuiLevel GetGuiLevel() const
const PanoramaOptions & getOptions() const
returns the options for this panorama
the main images tree control, used on images and optimizer tabs
const int getPhotometricOptimizerSwitch() const
return the photometric optimizer master switch
PanoOperation to reset image variables.
void Init(HuginBase::Panorama *pano)
VALUETYPE max
the current max
std::vector< LimitIntensity > LimitIntensityVector
virtual bool CanHandle(wxXmlNode *node)
void transformImage(SrcImageIterator src_upperleft, SrcImageIterator src_lowerright, SrcAccessor src_acc, DestImageIterator dest_upperleft, DestAccessor dest_acc, const Functor &func)
std::vector< std::set< std::string > > OptimizeVector
const SrcPanoImage & getImage(std::size_t nr) const
get a panorama image, counting starts with 0
ImagesTreeCtrl * m_lens_tree
void fill_set(_Container &c, typename _Container::key_type begin, typename _Container::key_type end)
void setOptions(const PanoramaOptions &opt)
set new output settings This is not used directly for optimizing/stiching, but it can be feed into ru...
void OnReset(wxCommandEvent &e)
void OnClose(wxCloseEvent &e)
std::size_t getNumberOfParts() const
get the number of parts.
#define HUGIN_PHOTOMETRIC_OPTIMIZER_NRPOINTS
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL, const wxString &name=wxT("panel"))
void SetOptimizerMode()
sets to control into optimizer mode
double outputExposureValue
ImagesTreeCtrl * m_images_tree