27#include "hugin_config.h"
42#include <vigra/cornerdetection.hxx>
43#include <vigra/localminmax.hxx>
62 ImageCache::EntryPtr
eptr = ImageCache::getInstance().getSmallImage(i1.getFilename());
64 vigra::BImage
leftImg(
eptr->get8BitImage()->size());
66 vigra::GreenAccessor<vigra::RGBValue<vigra::UInt8> >
ga;
67 vigra::copyImage(srcImageRange(*(
eptr->get8BitImage()),
ga ),
84 vigra::cornerResponseFunction(srcImageRange(
leftImg),
98 vigra::Threshold<double, double>(
125 for (
unsigned int x=0; x < (
unsigned int)
leftImg.width(); x++ ) {
126 for (
unsigned int y=0; y < (
unsigned int)
leftImg.height(); y++) {
186 dlg.CenterOnParent();
187 int ret =
dlg.ShowModal();
192 if (
dlg.GetCropFactor() <= 0)
213 if (
iccName.compare(0, 4,
"sRGB") == 0)
244 for (
const auto& filename:
files)
250 srcImg.setFilename(filename);
253 vigra::ImageImportInfo info(filename.c_str());
254 if(info.width()==0 || info.height()==0)
259 srcImg.setSize(info.size());
260 const std::string
pixelType=info.getPixelType();
264 hugin_utils::HuginMessageBox(wxString::Format(
_(
"File \"%s\" is a black/white image.\nHugin does not support this image type. Skipping this image.\nConvert image to grayscale image and try loading again."),
fname.c_str()),
270 const int bands = info.numBands();
272 if (bands != 1 && bands != 3 && !(bands == 2 &&
extraBands == 1) && !(bands == 4 &&
extraBands == 1))
274 hugin_utils::HuginMessageBox(wxString::Format(
_(
"Hugin supports only grayscale and RGB images (without and with alpha channel).\nBut file \"%s\" has %d channels and %d extra channels (probably alpha channels).\nHugin does not support this image type. Skipping this image.\nConvert this image to grayscale or RGB image and try loading again."),
fname.c_str(), bands,
extraBands),
284 wxString s(
_(
"Hugin supports only grayscale or RGB images (without and with alpha channel)."));
288 s.Append(wxString::Format(
_(
"File \"%s\" is a grayscale image, but other images in project are color images."),
fname.c_str()));
292 s.Append(wxString::Format(
_(
"File \"%s\" is a color image, but other images in project are grayscale images."),
fname.c_str()));
295 s.Append(
_(
"Hugin does not support this mixing. Skipping this image.\nConvert this image to grayscale or RGB image respectively and try loading again."));
335 warning.Append(
_(
"Hugin expects all images in the same color profile.\nPlease convert all images to same color profile and try again."));
343 if (!info.getICCProfile().empty())
353 catch(std::exception & e)
355 std::cerr <<
"ERROR: caught exception: " << e.what() << std::endl;
356 std::cerr <<
"Could not get pixel type for file " << filename << std::endl;
365 if (
srcImg.getCropFactor()<0.1)
367 srcImg.readCropfactorFromDB();
374 const bool ignoreFovRectilinear = wxConfigBase::Get()->Read(
"/General/IgnoreFovRectilinearOnAdd", 1l) == 1l;
394 other.getExifFocalLength() ==
srcImg.getExifFocalLength()
398 if (
srcImg.getCropFactor() <= 0.1)
425 if (!wxFileName::FileExists(
fn)) {
426 DEBUG_INFO(
"Image: " <<
fn.mb_str() <<
" has disappeared, skipping...");
437 if (
other.getExifFocalLength()>0) {
441 &&
other.getExifFocalLength() ==
srcImg.getExifFocalLength()
483 message =
_(
"Hugin has image stacks detected in the added images and will assign corresponding stack numbers to the images.");
487 message =
_(
"Hugin has image stacks detected in the whole project. Stack numbers will be re-assigned on base of this detection. Existing stack assignments will be overwritten.");
490 message.append(
_(
"Should the position of images in each stack be linked?"));
492 dialog->SetExtendedMessage(
_(
"When shooting bracketed image stacks from a sturdy tripod the position of the images in each stack can be linked to help Hugin to process the panorama. But if the images in each stack require a fine tune of the position (e. g. when shooting hand held), then don't link the position."));
495 dialog->SetYesNoCancelLabels(
_(
"Link position"),
_(
"Don't link position"),
_(
"Don't assign stacks"));
499 dialog->SetYesNoCancelLabels(
_(
"Link position"),
_(
"Don't link position"),
_(
"Keep existing stacks"));
501 switch (
dialog->ShowModal())
528 wxXmlResource::Get()->LoadDialog(&
dlg,
NULL,
"warning_exposure_dlg");
533 config->Write(
"/ShowExposureWarning", 0l);
537 config->Write(
"/ShowExposureWarning", 1l);
578 for (
unsigned int i = 0;
i <
nImg;
i++) {
580 while (!
fname.FileExists()){
592 if (
fname.FileExists()) {
627 vigra::ImageImportInfo
imginfo(
srcImg.getFilename().c_str());
633 double hfov = pano.
getImage(
i).getHFOV();
668 for (
unsigned i = 0;
i <
nImg; ++
i)
682 HuginBase::UIntSet::const_iterator
it =
imgLens.begin();
683 const size_t img1 = *
it;
687 pano.linkImageVariableProjection(img1, *
it);
705 for (HuginBase::CPVector::const_iterator
it =
oldCPs.begin();
711 if (0 > point.
x1 || point.
x1 > img1.getSize().x ||
712 0 > point.
y1 || point.
y1 > img1.getSize().y ||
713 0 > point.
x2 || point.
x2 > img2.getSize().x ||
714 0 > point.
y2 || point.
y2 > img2.getSize().y)
814 dlg.SetDirectory(path);
818 if (
config->HasEntry(
"lastImageType")){
822 dlg.SetFilterIndex(0);
824 dlg.SetFilterIndex(1);
826 dlg.SetFilterIndex(2);
828 dlg.SetFilterIndex(3);
830 dlg.SetFilterIndex(4);
832 dlg.SetFilterIndex(5);
833 else if (
img_ext ==
"all files")
834 dlg.SetFilterIndex(6);
848 config->Write(
"/actualPath",
dlg.GetDirectory());
852 switch (
dlg.GetFilterIndex() ) {
853 case 0:
config->Write(
"lastImageType",
"all images");
break;
854 case 1:
config->Write(
"lastImageType",
"jpg");
break;
855 case 2:
config->Write(
"lastImageType",
"tiff");
break;
856 case 3:
config->Write(
"lastImageType",
"png");
break;
857 case 4:
config->Write(
"lastImageType",
"hdr");
break;
858 case 5:
config->Write(
"lastImageType",
"exr");
break;
859 case 6:
config->Write(
"lastImageType",
"all files");
break;
867 vigra::ImageImportInfo
inf(filename.c_str());
869 img.setFilename(filename);
874 lenses.updatePartNumbers();
875 if (
i > 0)
lenses.switchParts(imgNr, 0);
942 std::cout <<
"run python script: " << m_scriptFile.c_str() << std::endl;
945 "HuginBase::Panorama*" , &pano ) ;
949 std::cout <<
"Python interface returned " <<
success << endl ;
some definitions to work with optimizer master switches
Somewhere to specify what variables belong to what.
@ RESPONSE_LINEAR
linear response
@ RESPONSE_EMOR
empirical model of response
represents a control point
Same as above, but use a non const panorama.
Memento class for a Panorama object.
bool loadPTScript(std::istream &i, int &ptoVersion, const std::string &prefix="")
load a Hugin file
void setHFOV(double h, bool keepView=true)
set the horizontal field of view.
void setProjection(ProjectionFormat f)
set the Projection format and adjust the hfov/vfov if nessecary
BlendingMechanism blendMode
vigra_ext::Interpolator interpolator
std::string hdrmergeOptions
std::string verdandiOptions
void setWidth(unsigned int w, bool keepView=true)
set panorama width keep the HFOV, if keepView=true
double outputExposureValue
std::string enblendOptions
BlendingMechanism
blenders
std::string tiffCompression
std::string outputImageType
HDRMergeType hdrMergeMode
std::string enfuseOptions
std::string outputImageTypeCompression
unsigned int colorReferenceImage
const SrcPanoImage & getImage(std::size_t nr) const
get a panorama image, counting starts with 0
void imageChanged(unsigned int imgNr)
mark image for change notification.
const PanoramaOptions & getOptions() const
returns the options for this panorama
void setMemento(const PanoramaMemento &memento)
set the internal state
const int getNrOfBands() const
return number of bands of first image (without alpha channel) so it can be 1 for grayscale or 3 for r...
void setCtrlPoints(const CPVector &points)
set all control points (Ippei: Is this supposed to be 'add' method?)
const double getMaxExposureDifference() const
returns the maximum exposure value difference of all images in the project
SrcPanoImage getSrcImage(unsigned imgNr) const
get a description of a source image
const bool hasPossibleStacks() const
return true, if the metadata indicates that the projects is a bracketet project
unsigned int addCtrlPoint(const ControlPoint &point)
add a new control point.
unsigned int addImage(const SrcPanoImage &img)
the the number for a specific image
void setImageFilename(unsigned int img, const std::string &fname)
set a new image filename
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 markAsOptimized(bool optimized=true)
const std::string getICCProfileDesc() const
return description of icc profile used for pano
void setSrcImage(unsigned int nr, const SrcPanoImage &img)
set input image parameters
const CPVector & getCtrlPoints() const
get all control point of this Panorama
virtual void updateVariables(const VariableMapVector &vars)
Set the variables.
PanoramaMemento getMemento() const
get the internal state
void setNrOfBands(const int nrBands)
sets the number of bands
void setICCProfileDesc(const std::string &newDesc)
sets the icc profile description for check of same profile
void setPhotometricOptimizerSwitch(const int newSwitch)
sets the photometric optimizer master switch
void linkPossibleStacks(bool linkPosition)
create automatically stacks as indicated by metadata
void reset()
clear the internal state.
void setOptimizerSwitch(const int newSwitch)
set optimizer master switch
std::size_t getNrOfImages() const
number of images.
All variables of a source image.
bool applyEXIFValues(bool applyEVValue=true)
apply values found in EXIF data to SrcPanoImage class, call readEXIF() before to initialize some valu...
int getWidth() const
Get the width of the image in pixels.
void setSize(vigra::Size2D val)
Set the image size in pixels.
int getHeight() const
Get the height of the image in pixels.
bool readEXIF()
try to fill out information about the image, by examining the exif data
virtual bool processPanorama(HuginBase::Panorama &pano)
Called by execute().
virtual bool processPanorama(HuginBase::Panorama &pano)
Called by execute().
std::vector< std::string > files
virtual bool processPanorama(HuginBase::Panorama &pano)
Called by execute().
virtual bool processPanorama(HuginBase::Panorama &pano)
Called by execute().
const std::string filename
const bool markAsOptimized
virtual bool processPanorama(HuginBase::Panorama &pano)
Called by execute().
#define HUGIN_JPEG_QUALITY
#define HUGIN_ENBLEND_ARGS
#define HUGIN_NONA_USEGPU
#define HUGIN_GUI_SORT_NEW_IMG_ON_ADD
#define HUGIN_NONA_CROPPEDIMAGES
#define HUGIN_TIFF_COMPRESSION
#define HUGIN_ENFUSE_ARGS
#define HUGIN_DEFAULT_BLENDER
#define HUGIN_NONA_INTERPOLATOR
#define HUGIN_HDRMERGE_ARGS
#define HUGIN_LDR_OUTPUT_FORMAT
C++ call interface to hpi.
std::vector< VariableMap > VariableMapVector
std::vector< ControlPoint > CPVector
std::vector< UIntSet > UIntSetVector
std::set< unsigned int > UIntSet
bool getLensDataFromUser(wxWindow *parent, HuginBase::SrcPanoImage &srcImg)
std::string GetICCProfileNameChecked(const std::string &iccName)
return name of icc profile with same checks for comparision
void applyColorBalanceValue(HuginBase::SrcPanoImage &srcImg, HuginBase::Panorama &pano)
int callhpi(const char *plugin_name, int argc,...)
simplified call interface to the Python Plugin facility.
int HuginMessageBox(const wxString &message, const wxString &caption, int style, wxWindow *parent)
std::unique_ptr< wxMessageDialogBase > MessageDialog
bool IsLinearICCProfile(const vigra::ImageImportInfo::ICCProfile &iccProfile)
return true if icc profile is linear one, otherwise return false
std::string GetICCDesc(const vigra::ImageImportInfo::ICCProfile &iccProfile)
returns description of given icc profile
std::string stripPath(const std::string &filename)
remove the path of a filename (mainly useful for gui display of filenames)
MessageDialog GetMessageDialog(const wxString &message, const wxString &caption, int style, wxWindow *parent)
Interpolator
enum with all interpolation methods
include file for the hugin project
include file for the hugin project
Functor class to compare two objects with the "Alphanum Algorithm".
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.
wxwindows specific panorama commands