33#include <vigra/impex.hxx>
35#include <vigra/functorexpression.hxx>
42#include <pano13/filter.h>
45static void usage(
const char* name)
47 std::cout << name <<
": find vertical lines in images" << std::endl
50 <<
"Usage: " << name <<
" [options] input.pto" << std::endl
52 <<
" Options:" << std::endl
53 <<
" -o, --output=file.pto Output Hugin PTO file. Default: <filename>_lines.pto" << std::endl
54 <<
" -i, --image=IMGNR Work only on given image numbers" << std::endl
55 <<
" -l, --lines=COUNT Save maximal COUNT lines (default: 5)" << std::endl
56 <<
" -h, --help Shows this help" << std::endl
77template <
class SrcIMG>
83 if (origType ==
"FLOAT" || origType ==
"DOUBLE" || origType ==
"UINT32" || origType ==
"INT32")
88 vigra::FindAverageAndVariance<float>
mean;
89 vigra::inspectImage(srcImageRange(
src, vigra::RGBToGrayAccessor<typename SrcIMG::PixelType>()),
mean);
96 vigra::transformImage(srcImageRange(
src), destImage(
dest),
101template <
class SrcIMG>
107 if (origType ==
"FLOAT" || origType ==
"DOUBLE" || origType ==
"UINT32" || origType ==
"INT32")
112 vigra::FindAverageAndVariance<float>
mean;
113 vigra::inspectImage(srcImageRange(
src),
mean);
120 vigra::transformImage(srcImageRange(
src), destImage(
dest),
125template <
class SrcIMG>
130 if(info.numExtraBands()==1)
132 mask.resize(info.width(), info.height());
144template <
class SrcIMG>
147 vigra::UInt8RGBImage image;
149 if(info.numExtraBands()==1)
151 mask.resize(info.width(), info.height());
169 std::string
pixelType=info.getPixelType();
172 image.resize(info.width(),info.height());
173 if(info.numExtraBands()==1)
175 mask.resize(info.width(), info.height());
203 std::cerr <<
"Unsupported pixel type" << std::endl;
208 if(image.width()>0 && image.height()>0)
218 vigra::UInt8RGBImage image;
221 std::string
pixelType=info.getPixelType();
224 image.resize(info.width(),info.height());
225 if(info.numExtraBands()==1)
227 mask.resize(info.width(), info.height());
255 std::cerr <<
"Unsupported pixel type" << std::endl;
260 if(image.width()>0 && image.height()>0)
413 if (std::abs(
optPano.getImage(img).getPitch()) < 50)
434 std::cerr <<
"No image to process found" << std::endl <<
"Stopping processing" << std::endl;
443 std::string
s=vigra::impexListExtensions();
447#pragma omp parallel for schedule(dynamic)
451 std::ostringstream
buf;
452 buf <<
"Working on image " << pano.
getImage(imgNr).getFilename() << std::endl;
453 std::cout <<
buf.str();
455 vigra::ImageImportInfo info(pano.
getImage(imgNr).getFilename().c_str());
457 if(info.isGrayscale())
470 std::cerr <<
"Image " << pano.
getImage(imgNr).getFilename().c_str() <<
" has "
471 << info.numBands() <<
" channels." << std::endl
472 <<
"Linefind works only with grayscale or color images." << std::endl
473 <<
"Skipping image." << std::endl;
485 std::cout << std::endl <<
"Found " << pano.
getNrOfCtrlPoints() -
nrCPS <<
" vertical lines" << std::endl << std::endl;
492 std::cout << std::endl <<
"Written output to " <<
output << std::endl;
declaration of functions for finding lines
!! from PTOptimise.h 1951
Somewhere to specify what variables belong to what.
Make an ImageVariableGroup for lenses and other common concepts.
virtual void run()
runs the algorithm.
const SrcPanoImage & getImage(std::size_t nr) const
get a panorama image, counting starts with 0
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...
unsigned int addCtrlPoint(const ControlPoint &point)
add a new control point.
std::size_t getNrOfCtrlPoints() const
number of control points
VariableMapVector getVariables() const
get variables of this panorama
Panorama duplicate() const
duplicate the panorama
bool WritePTOFile(const std::string &filename, const std::string &prefix="")
write data to given pto file
std::size_t getNrOfImages() const
number of images.
class AlphaIterator class AlphaAccessor inline void importImageAlpha(const ImageImportInfo &import_info, ImageIterator image_iterator, ImageAccessor image_accessor, AlphaIterator alpha_iterator, AlphaAccessor alpha_accessor)
static int ptProgress(int command, char *argument)
int main(int argc, char *argv[])
void convertToUInt8(SrcIMG &src, const std::string &origType, vigra::UInt8RGBImage &dest)
converts the given image to UInt8RGBImage only this image is correctly processed by linefind
static int ptinfoDlg(int command, char *argument)
HuginBase::CPVector LoadGrayImageAndFindLines(vigra::ImageImportInfo info, HuginBase::Panorama &pano, size_t imgNr, int nrLines)
vigra::UInt8RGBImage LoadImageAndConvert(vigra::ImageImportInfo &info, vigra::BImage &mask)
void convertGrayToUInt8(SrcIMG &src, const std::string &origType, vigra::BImage &dest)
vigra::BImage LoadGrayImageAndConvert(vigra::ImageImportInfo &info, vigra::BImage &mask)
static hugin_omp::Lock lock
HuginBase::CPVector LoadImageAndFindLines(vigra::ImageImportInfo info, HuginBase::Panorama &pano, size_t imgNr, int nrLines)
std::vector< unsigned int > UIntVector
std::vector< VariableMap > VariableMapVector
std::vector< ControlPoint > CPVector
std::vector< UIntSet > UIntSetVector
std::set< unsigned int > UIntSet
HuginBase::CPVector GetVerticalLines(const HuginBase::Panorama &pano, const unsigned int imgNr, vigra::UInt8RGBImage &image, vigra::BImage &mask, const unsigned int nrLines)
searches for vertical control points in given image
std::string GetHuginVersion()
return a string with version numbers
std::string GetOutputFilename(const std::string &out, const std::string &in, const std::string &suffix)
construct output filename, if ouput is known return this value otherwise use the input filename and a...
std::string stripPath(const std::string &filename)
remove the path of a filename (mainly useful for gui display of filenames)
std::string getPathPrefix(const std::string &filename)
Get the path to a filename.
double getMaxValForPixelType(const std::string &v)
void applyMapping(vigra::triple< SrcIterator, SrcIterator, SrcAccessor > img, vigra::pair< DestIterator, DestAccessor > dest, T min, T max, int mapping)
Map::mapped_type & map_get(Map &m, const typename Map::key_type &key)
get a map element.
const HuginBase::Panorama & m_pano
SortVectorByExposure(const HuginBase::Panorama &pano)
bool operator()(const size_t &img1, const size_t &img2)
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.
functions to manage ROI's