27 #include "hugin_config.h"
58 long style,
const wxString& name)
61 if (! wxPanel::Create(parent,
id, pos, size, style, name))
66 wxXmlResource::Get()->LoadPanel(
this, wxT(
"optimize_photo_panel"));
67 wxPanel * panel = XRCCTRL(*
this,
"optimize_photo_panel", wxPanel);
69 wxBoxSizer *topsizer =
new wxBoxSizer( wxVERTICAL );
70 topsizer->Add(panel, 1, wxEXPAND, 0);
82 XRCCTRL(*
this,
"optimize_photo_panel_splitter", wxSplitterWindow)->SetSashGravity(0.66);
137 wxWindowDisabler winDisable;
147 wxMessageBox(_(
"The project does not contain any active images.\nPlease activate at least 2 images in the (fast) preview window.\nOptimization canceled."),
153 wxICON_ERROR | wxOK);
173 XRCCTRL(*
this,
"optimize_photo_panel_optimize", wxButton)->Enable(pano.
getNrOfImages()>1);
174 XRCCTRL(*
this,
"optimize_photo_panel_reset", wxButton)->Enable(pano.
getNrOfImages()>0);
185 HuginBase::ImageVariableGroup::IVE_EMoRParams,
186 HuginBase::ImageVariableGroup::IVE_ResponseType,
187 HuginBase::ImageVariableGroup::IVE_VigCorrMode,
188 HuginBase::ImageVariableGroup::IVE_RadialVigCorrCoeff,
189 HuginBase::ImageVariableGroup::IVE_RadialVigCorrCenterShift
192 std::vector<PanoCommand::PanoCommand *> commands;
197 std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> links_needed;
198 links_needed.clear();
199 for (
int v = 0; v < 5; v++)
203 links_needed.insert(vars[v]);
206 if (!links_needed.empty())
212 if (!commands.empty()) {
213 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);
223 for (std::vector<PanoCommand::PanoCommand *>::iterator it = commands.begin(); it != commands.end(); ++it)
238 for(
unsigned int i=0;i<optvars.size() && !valid;i++)
248 wxMessageBox(_(
"You selected no parameters to optimize.\nTherefore optimization will be canceled."), _(
"Exposure optimization"), wxOK | wxICON_INFORMATION);
255 std::vector<vigra_ext::PointPairRGB> points;
264 std::vector<vigra::FRGBImage *> srcImgs;
266 float imageStepSize = 1 / 255.0f;
269 ImageCache::EntryPtr e = ImageCache::getInstance().getSmallImage(optPano.
getImage(i).getFilename());
272 wxMessageBox(_(
"Error: could not load all images"), _(
"Error"));
276 vigra::FRGBImage * img =
new vigra::FRGBImage;
277 if (e->imageFloat && e->imageFloat->size().area() > 0)
279 if (e->mask->size().area() > 0)
281 vigra::BImage maskSmall;
285 imageStepSize =
std::min(imageStepSize, (minmax.
max - minmax.
min) / 16384.0f);
292 imageStepSize =
std::min(imageStepSize, (minmax.
max - minmax.
min) / 16384.0f);
298 if (e->image16 && e->image16->size().area() > 0)
302 vigra::functor::Arg1() / vigra::functor::Param(65535.0));
304 imageStepSize =
std::min(imageStepSize, 1 / 65536.0f);
310 vigra::functor::Arg1() / vigra::functor::Param(255.0));
312 imageStepSize =
std::min(imageStepSize, 1 / 255.0f);
315 srcImgs.push_back(img);
316 limits.push_back(limit);
317 if (!progress.updateDisplayValue())
325 if (!progress.updateDisplayValue())
331 wxMessageBox(_(
"Error: no overlapping points found, Photometric optimization aborted"), _(
"Error"));
335 progress.setMaximum(0);
336 progress.updateDisplay(_(
"Optimize..."));
375 if (progress.wasCancelled())
380 catch (std::exception & error)
382 wxMessageBox(_(
"Internal error during photometric optimization:\n") + wxString(error.what(), wxConvLocal), _(
"Internal error"));
389 int ret = wxMessageBox(wxString::Format(_(
"Photometric optimization results:\nAverage difference (RMSE) between overlapping pixels: %.2f gray values (0..255)\n\nApply results?"), error*255),
390 _(
"Photometric optimization finished"), wxYES_NO | wxICON_INFORMATION,
this);
397 std::vector<PanoCommand::PanoCommand*> optCommands;
437 : wxXmlResourceHandler()
446 cp->Create(m_parentAsWindow,
448 GetPosition(), GetSize(),
449 GetStyle(wxT(
"style")),
459 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.
OptimizePhotometricPanel()
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