Hugin trunk 0.1
Loading...
Searching...
No Matches
GenerateThumbnail.cpp
Go to the documentation of this file.
1// -*- c-basic-offset: 4 -*-
2
12 /* This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public
14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version.
16 *
17 * This software is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public
23 * License along with this software. If not, see
24 * <http://www.gnu.org/licenses/>.
25 *
26 */
27
28#include "GenerateThumbnail.h"
32
33bool GenerateThumbnail(const std::string pto_filename, const wxSize size, vigra::BRGBImage& panoImage, vigra::BImage& panoMask, vigra::ImageImportInfo::ICCProfile& iccProfile)
34{
35 // read pto file
38 {
39 return false;
40 };
41 // check that all images are available
42 for (long i = 0; i < pano.getNrOfImages(); ++i)
43 {
44 if (!hugin_utils::FileExists(pano.getImage(i).getFilename()))
45 {
46 return false;
47 };
48 };
49 if (pano.getActiveImages().empty())
50 {
51 // no active images in pto file
52 return false;
53 }
54 // calculate scale factor
56 const vigra::Rect2D roi(opts.getROI());
57 const double scale = std::max(roi.width() * 1.0 / size.GetWidth(), roi.height() * 1.0 / size.GetHeight());
58 opts.setWidth(opts.getWidth() / scale);
59 // TO DO: check that images has enough pixel
60 vigra::Rect2D newROI(opts.getROI());
61 newROI.addSize(vigra::Size2D(std::min(size.GetWidth() - newROI.width(), 0), std::min(size.GetHeight() - newROI.height(), 0)));
62 opts.setROI(newROI);
63 // now remapped and stitch images
65 //prepare some settings
66 opts.tiff_saveROI = false;
68 opts.outputImageType = "png";
70 opts.remapUsingGPU = false;
71 if (pano.getImage(0).getResponseType() == HuginBase::BaseSrcPanoImage::RESPONSE_EMOR)
72 {
73 // get the emor parameters.
74 opts.outputEMoRParams = pano.getSrcImage(0).getEMoRParams();
75 }
76 else
77 {
78 // clear the parameters to indicatate these should not be used
79 opts.outputEMoRParams.clear();
80 };
82 HuginBase::Nona::SetAdvancedOption(advOptions, "saveIntermediateImages", false);
87 // create panorama canvas
88 vigra::BRGBImage preview(opts.getWidth(), opts.getHeight());
89 vigra::BImage previewMask(opts.getWidth(), opts.getHeight());
90 // finally stitch and merge images
91 stitcher.init(opts, pano.getActiveImages());
92 stitcher.stitch(opts, pano.getActiveImages(), std::string(), preview, previewMask, remapper, advOptions);
93 // HuginBase::Nona::WeightedStitcher is using the full canvas size
94 // so we copy out only the crop portion into the final image data
95 panoImage.resize(stitcher.GetPanoROI().size());
96 panoMask.resize(panoImage.size());
97 vigra::copyImage(vigra::srcImageRange(preview, stitcher.GetPanoROI()), vigra::destImage(panoImage));
98 vigra::copyImage(vigra::srcImageRange(previewMask, stitcher.GetPanoROI()), vigra::destImage(panoMask));
99 iccProfile = stitcher.GetICCProfile();
100 delete pdisp;
101 return true;
102}
bool GenerateThumbnail(const std::string pto_filename, const wxSize size, vigra::BRGBImage &panoImage, vigra::BImage &panoMask, vigra::ImageImportInfo::ICCProfile &iccProfile)
generate thumbnail image for given pto_filename
generate thumbnail from given pto file
Contains various routines used for stitching panoramas.
Dummy progress display, without output.
@ RESPONSE_EMOR
empirical model of response
functor to create a remapped image, loads image from disk
void setAdvancedOptions(const HuginBase::Nona::AdvancedOptions advancedOptions)
Panorama image options.
const vigra::Rect2D & getROI() const
void setWidth(unsigned int w, bool keepView=true)
set panorama width keep the HFOV, if keepView=true
std::vector< float > outputEMoRParams
void setROI(const vigra::Rect2D &val)
unsigned int getWidth() const
unsigned int getHeight() const
get panorama height
Model for a panorama.
Definition Panorama.h:153
const SrcPanoImage & getImage(std::size_t nr) const
get a panorama image, counting starts with 0
Definition Panorama.h:211
const PanoramaOptions & getOptions() const
returns the options for this panorama
Definition Panorama.h:481
bool ReadPTOFile(const std::string &filename, const std::string &prefix="")
read pto file from the given filename into Panorama object it does some checks on the file and issues...
SrcPanoImage getSrcImage(unsigned imgNr) const
get a description of a source image
UIntSet getActiveImages() const
get active images
std::size_t getNrOfImages() const
number of images.
Definition Panorama.h:205
std::map< std::string, std::string > AdvancedOptions
void SetAdvancedOption(AdvancedOptions &opts, const std::string &name, const bool value)
store the option with name in AdvancedOptions
bool FileExists(const std::string &filename)
checks if file exists
Definition utils.cpp:362
std::string getPathPrefix(const std::string &filename)
Get the path to a filename.
Definition utils.cpp:184
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