24#include "wx/msw/wrapwin.h"
29#include "hugin_config.h"
41#include "vigra/stdimage.hxx"
42#include "vigra/resizeimage.hxx"
51#if defined HAVE_EPOXY && HAVE_EPOXY
57#include <wx/display.h>
61#include <OpenGL/glu.h>
68#include "wx/mstream.h"
73#include <exiv2/exiv2.hpp>
92 TexturesMap::iterator
it;
99 if (
it->second->GetUseAlpha() ||
it->second->GetHasActiveMasks())
112 float scale[4] = {
static_cast<float>(
es / img->getWhiteBalanceRed()),
114 static_cast<float>(
es /img->getWhiteBalanceBlue()),
125 if (scale[0] > 1.0 || scale[1] > 1.0 || scale[2] > 1.0)
133 bool r = (scale[0] > 2.0);
134 bool g = (scale[1] > 2.0);
135 bool b = (scale[2] > 2.0);
136 unsigned short int count = 0;
137 while ((r ||
g || b) && count < 9)
139 glColor4f(r ? 1.0 : 0.0,
g ? 1.0 : 0.0, b ? 1.0 : 0.0, 1.0);
141 if (r) scale[0] /= 2.0;
142 if (
g) scale[1] /= 2.0;
143 if (b) scale[2] /= 2.0;
144 r = (scale[0] > 2.0);
145 g = (scale[1] > 2.0);
146 b = (scale[2] > 2.0);
150 if (scale[0] > 1.0 || scale[1] > 1.0 || scale[2] > 1.0)
153 scale[0] -= 1.0; scale[1] -= 1.0; scale[2] -= 1.0;
164 if (
it->second->GetUseAlpha() ||
it->second->GetHasActiveMasks())
174 TexturesMap::iterator
it;
179 return it->second->GetNumber();
185 TexturesMap::iterator
it;
269 TexturesMap::iterator
it;
292 std::cout <<
"Texture size for image " <<
image_index <<
" is "
296 std::cout <<
"About to create new TextureInfo for "
297 <<
img_p->getFilename()
299 std::pair<std::map<TextureKey, TextureInfo>::iterator,
bool>
ins;
300 ins =
textures.insert(std::pair<TextureKey, TextureInfo>
314 double hfov =
img_p->getHFOV(),
352 std::cout <<
"biggest mipmap of image " <<
image_index <<
" is "
377 double hfov =
img_p->getHFOV(),
430 std::pair<TexturesMap::iterator, bool>
ins;
490 for (
size_t i = 0;
i < wxDisplay::GetCount(); ++
i)
524 DEBUG_INFO(
"Max texture size supported is " << max_size <<
535 TexturesMap::iterator
tex;
544 for (
unsigned int img = 0; img <
num_images; img++)
547 if (
ik ==
tex->first)
556 DEBUG_INFO(
"Removing old texture for " <<
tex->first.filename <<
".");
578 std::shared_ptr<TextureInfo>
tex(
it->second);
597 has_active_masks=
false;
601 width = 1 << width_p;
602 height = 1 << height_p;
635#if defined HAVE_EPOXY && HAVE_EPOXY
643 DEBUG_INFO(
"Using anisotropic filtering at maximum value "
647 DEBUG_INFO(
"Anisotropic filtering is not available.");
656 if(m_viewState->GetSupportMultiTexture())
670 DEBUG_ERROR(
"GL Error when setting texture parameters: "
687 if(m_viewState->GetSupportMultiTexture())
699 if(m_viewState->GetSupportMultiTexture())
709 if(m_viewState->GetSupportMultiTexture())
731 int max_mip_level = (width_p > height_p) ? width_p : height_p;
742 ImageCache::getInstance().softFlush();
745 ImageCache::EntryPtr entry = ImageCache::getInstance().getImageIfAvailable(
img_name);
749 m_imageRequest = ImageCache::getInstance().requestAsyncImage(
img_name);
755 m_imageRequest->ready.push_back(
760 m_imageRequest->ready.push_back(
769#if defined EXIV2_VERSION && EXIV2_TEST_VERSION(0,27,99)
770 Exiv2::Image::UniquePtr image;
772 Exiv2::Image::AutoPtr image;
777 image = Exiv2::ImageFactory::open(
img_name.c_str());
782 std::cerr <<
__FILE__ <<
" " <<
__LINE__ <<
" Error opening file" << std::endl;
786 std::shared_ptr<Exiv2::PreviewManager>
previews;
787 Exiv2::PreviewPropertiesList
lists;
791 image->readMetadata();
792 previews = std::make_shared<Exiv2::PreviewManager>(*image);
795 catch (
const Exiv2::Error&)
817 wxLog::EnableLogging(
false);
840 wxLog::EnableLogging(
true);
853 GLubyte c = ((
i / 8 +
j / 8) % 2) ? 63 : 191;
870 m_imageRequest = ImageCache::RequestPtr();
872 std::shared_ptr<vigra::BRGBImage> img = entry->get8BitImage(wxConfigBase::Get()->Read(
"/ImageCache/Mapping",
HUGIN_IMGCACHE_MAPPING_FLOAT));
873 std::shared_ptr<vigra::BImage> mask = entry->mask;
875 int wo = 1 << (width_p - min),
ho = 1 << (height_p - min);
876 if (
wo < 1)
wo = 1;
if (
ho < 1)
ho = 1;
882 has_mask = mask->width() && mask->height();
885 if (
wo < 2 ||
ho < 2)
889 for (
int h = 0; h <
ho; h++)
891 for (
int w = 0;
w <
wo;
w++)
894 if (has_mask) (*out_alpha)[h][
w] = (*mask)[0][0];
908 vigra::resizeImageNoInterpolation(srcImageRange(*img),
912 vigra::resizeImageNoInterpolation(srcImageRange(*(mask)),
917 if (!entry->iccProfile->empty())
947 DEBUG_INFO(
"Performing photometric correction");
959 HuginBase::Photometric::InvResponseTransform < unsigned char, double >
964 std::vector<double>
outLut;
985#pragma omp parallel for
986 for (
int y = 0; y <
ho; y++)
988 for (
int x = 0; x <
wo; x++)
996 if (transform !=
NULL)
1005 if (transform !=
NULL)
1007#pragma omp parallel for
1008 for (
int y = 0; y <
ho; y++)
1014 if (transform !=
NULL)
1028 DEBUG_INFO(
"Defining mipmap levels " << min <<
" to " << max
1029 <<
" of texture " << num <<
", starting with a size of "
1030 <<
wo <<
" by " <<
ho <<
".");
1037 for (
int h = 0; h <
ho; h++)
1039 for (
int w = 0;
w <
wo;
w++)
1060 (
unsigned char *)
out_img.data());
1064 DEBUG_ERROR(
"GLU Error when building mipmap levels: "
1070 DEBUG_ERROR(
"GL Error when building mipmap levels: "
1081 has_active_masks=
srcImg.hasActiveMasks();
1083 if(has_active_masks)
1085 unsigned int maskSize=(width>height) ? width : height;
1089 for(
unsigned int i=0;
i<masks.size();
i++)
1120 if(m_viewState->GetSupportMultiTexture())
1127 DefineMaskTexture(
srcImg);
1139 if(m_viewState->GetSupportMultiTexture())
1149 DEBUG_ERROR(
"Error when setting the base mipmap level: "
1164 return !(*
this <
comp ||
comp < *
this);
1171 if (filename <
comp.filename)
return true;
1172 if (filename >
comp.filename)
return false;
1174 if (masks <
comp.masks)
return true;
1175 if (masks >
comp.masks)
return false;
1179 if (exposure <
comp.exposure)
return true;
1180 if (exposure >
comp.exposure)
return false;
1181 if (white_balance_red <
comp.white_balance_red)
return true;
1182 if (white_balance_red >
comp.white_balance_red)
return false;
1183 if (white_balance_blue <
comp.white_balance_blue)
return true;
1184 if (white_balance_blue >
comp.white_balance_blue)
return false;
1185 if (EMoR_params <
comp.EMoR_params)
return true;
1186 if (EMoR_params >
comp.EMoR_params)
return false;
1187 if (radial_vig_corr_coeff <
comp.radial_vig_corr_coeff)
return true;
1188 if (radial_vig_corr_coeff >
comp.radial_vig_corr_coeff)
return false;
1189 if (vig_corr_mode <
comp.vig_corr_mode)
return true;
1190 if (vig_corr_mode >
comp.vig_corr_mode)
return false;
1191 if (response_type <
comp.response_type)
return true;
1192 if (response_type >
comp.response_type)
return false;
1193 if (gamma <
comp.gamma)
return true;
1194 if (gamma >
comp.gamma)
return false;
1195 if (radial_distortion_red <
comp.radial_distortion_red)
return true;
1196 if (radial_distortion_red >
comp.radial_distortion_red)
return false;
1197 if (radial_distortion_blue <
comp.radial_distortion_blue)
return true;
1198 if (radial_distortion_blue >
comp.radial_distortion_blue)
return false;
1205 filename =
source->getFilename();
1212 exposure =
source->getExposure();
1213 white_balance_red =
source->getWhiteBalanceRed();
1214 white_balance_blue =
source->getWhiteBalanceBlue();
1215 EMoR_params =
source->getEMoRParams();
1216 radial_vig_corr_coeff =
source->getRadialVigCorrCoeff();
1217 vig_corr_mode =
source->getVigCorrMode();
1218 response_type =
source->getResponseType();
1219 gamma =
source->getGamma();
1220 radial_distortion_red =
source->getRadialDistortionRed();
1221 radial_distortion_blue =
source->getRadialDistortionBlue();
declaration of classes to work with mask
void redrawPreview()
Display an updated version of the preview images.
@ RESPONSE_LINEAR
linear response
@ RESPONSE_EMOR
empirical model of response
double outputExposureValue
const PanoramaOptions & getOptions() const
returns the options for this panorama
std::size_t getNrOfImages() const
number of images.
All variables of a source image.
double getExposure() const
TextureInfo(ViewState *new_view_state)
void DefineMaskTexture(const HuginBase::SrcPanoImage &srcImg)
void UpdateMask(const HuginBase::SrcPanoImage &srcImg)
void SetMaxLevel(int level)
void DefineLevels(int min, int max, bool photometric_correct, const HuginBase::PanoramaOptions &dest_img, const HuginBase::SrcPanoImage &state)
const bool operator==(const TextureKey &comp) const
void SetOptions(const HuginBase::SrcPanoImage *source)
const bool operator<(const TextureKey &comp) const
virtual ~TextureManager()
void BindTexture(unsigned int image_number)
HuginBase::Panorama * m_pano
void DrawImage(unsigned int image_number, unsigned int display_list)
void LoadingImageFinished(int min, int max, bool texture_photometric_correct, const HuginBase::PanoramaOptions &dest_img, const HuginBase::SrcPanoImage &state)
void SetPhotometricCorrect(bool state)
unsigned int GetTextureName(unsigned int image_number)
unsigned int GetMaxTotalTexels()
void DisableTexture(bool maskOnly=false)
TextureManager(HuginBase::Panorama *pano, ViewState *view)
unsigned int GetMaxTextureSizePower()
bool RequireRecalculateMasks(unsigned int image_nr)
bool GetSupportMultiTexture() const
HuginBase::PanoramaOptions * GetOptions()
HuginBase::SrcPanoImage * GetSrcImage(unsigned int image_nr)
TextureManager * GetTextureManager()
bool RequireRecalculatePhotometric()
static MainFrame * getMainFrame()
static huginApp * Get()
hack.. kind of a pseudo singleton...
#define HUGIN_IMGCACHE_MAPPING_FLOAT
#define DEBUG_ASSERT(cond)
std::vector< MaskPolygon > MaskPolygonVector
void createEMoRLUT(const std::vector< float > ¶ms, VECTOR &lut)
void applyMask(vigra::triple< SrcImageIterator, SrcImageIterator, SrcAccessor > img, HuginBase::MaskPolygonVector masks)
void enforceMonotonicity(LUT &lut)
enforce monotonicity of an array (mostly used for lookup tables)
include file for the hugin project
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.