24#ifndef _HUGIN_UTILS_UTILS_H
25#define _HUGIN_UTILS_UTILS_H
35#include <vigra/imageinfo.hxx>
49 #define DEBUG_HEADER hugin_utils::GetCurrentTimeString() <<" (" << __FILE__ << ":" << __LINE__ << ") " << __func__ << "(): "
51 #define DEBUG_HEADER hugin_utils::GetCurrentTimeString() <<" (" << __FILE__ << ":" << __LINE__ << ") " << __FUNCTION__ << "(): "
53 #define DEBUG_HEADER hugin_utils::GetCurrentTimeString() <<" (" << __FILE__ << ":" << __LINE__ << ") " << __func__ << "(): "
59 #define DEBUG_TRACE(msg) { std::cerr << "TRACE " << DEBUG_HEADER << msg << std::endl; }
61 #define DEBUG_DEBUG(msg) { std::cerr << "DEBUG " << DEBUG_HEADER << msg << std::endl; }
63 #define DEBUG_INFO(msg) { std::cerr << "INFO " << DEBUG_HEADER << msg << std::endl; }
65 #define DEBUG_NOTICE(msg) { std::cerr << "NOTICE " << DEBUG_HEADER << msg << std::endl; }
67 #define DEBUG_TRACE(msg)
68 #define DEBUG_DEBUG(msg)
69 #define DEBUG_INFO(msg)
70 #define DEBUG_NOTICE(msg)
74#define DEBUG_WARN(msg) { std::cerr << "WARN: " << DEBUG_HEADER << msg << std::endl; }
76#define DEBUG_ERROR(msg) { std::cerr << "ERROR: " << DEBUG_HEADER << msg << std::endl; }
78#define DEBUG_FATAL(msg) { std::cerr << "FATAL: " << DEBUG_HEADER << "(): " << msg << std::endl; }
80#define DEBUG_ASSERT(cond) assert(cond)
83#define UTILS_THROW(class, msg) { std::stringstream o; o << msg; throw(class(o.str().c_str())); };
113 template <
typename STR>
124 for (
typename STR::iterator
it =
str.begin();
it !=
str.end(); ++
it) {
130 const char * p =
str.c_str();
189 for (
size_t i = 0;
i < len;
i++) {
195 if (
idx != str::npos) {
200 }
while (
idx != str::npos);
206 double &r,
double &
g,
double &b);
242 IMPEX std::string
GetICCDesc(
const vigra::ImageImportInfo::ICCProfile& iccProfile);
namespace for various utils
bool StringContainsCaseInsensitive(const std::string &s1, const std::string &s2)
check if s1 contains s2 using case insensitive comparison
void ControlPointErrorColour(const double cperr, double &r, double &g, double &b)
bool stringToUInt(const std::string &s, unsigned int &val)
convert string to unsigned integer value, returns true, if sucessful
std::vector< std::string > SplitString(const std::string &s, const std::string &sep)
split string s at given sep, returns vector of strings
std::string GetAbsoluteFilename(const std::string &filename)
returns the full absolute filename
std::string StrTrim(const std::string &str)
remove trailing and leading white spaces and tabs
std::string GetCurrentTimeString()
current time as a string
std::string stripExtension(const std::string &basename2)
remove extension of a filename
bool initGPU(int *argcp, char **argv)
Try to initalise GLUT and GLEW, and create an OpenGL context for GPU stitching.
std::string doubleToString(double d, int digits)
convert a double to a string, suitable for display within a GUI.
bool IsLinearICCProfile(const vigra::ImageImportInfo::ICCProfile &iccProfile)
return true if icc profile is linear one, otherwise return false
void ReplaceAll(std::string &s, const std::string &oldChar, char newChar)
replace all characters oldChar in s with newChar
std::string getExtension(const std::string &basename2)
Get extension of a filename.
std::string GetDataDir()
returns the full path to the data directory
std::string GetUserAppDataDir()
returns the directory for user specific Hugin settings, e.g.
bool wrapupGPU()
cleanup GPU settings
void EnforceExtension(std::string &filename, const std::string &defaultExtension)
check if filename contains extension, if not add default extension
str QuoteStringInternal(const str &arg, const str "echar, const str &replacements)
bool IsRawExtension(const std::string testExt)
return true if extension belongs to a raw file
std::string GetICCDesc(const vigra::ImageImportInfo::ICCProfile &iccProfile)
returns description of given icc profile
bool IsFileTypeSupported(const std::string &filename)
return true, if file type by extension is supported by vigra
std::string GetHuginVersion()
return a string with version numbers
bool FileExists(const std::string &filename)
checks if file exists
bool stringToDouble(const STR &str_, double &dest)
convert a string to a double, ignore localisation.
std::vector< std::string > GetRawExtensions()
return vector of known extensions of raw files, all lower case
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.
bool stringToInt(const std::string &s, int &val)
convert string to integer value, returns true, if sucessful
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.