27#include "hugin_version.h"
28#include "hugin_config.h"
32 #include <sys/utime.h>
38 #include <sys/types.h>
49#include <hugin_config.h>
56#include <mach-o/dyld.h>
61#if defined HAVE_EPOXY && HAVE_EPOXY
73 #include <GLUT/glut.h>
87 sprintf(tmp+8,
".%06ld", (
long)
tv.tv_usec);
104 if (
idx == std::string::npos) {
106 return std::string(
"");
115 return std::string(
"");
125 return std::string(
"");
135 if (
idx == std::string::npos) {
163 std::string::size_type
idx = filename.rfind(
'/');
165 std::string::size_type
idx1 = filename.rfind(
'\\');
166 std::string::size_type
idx2 = filename.rfind(
'/');
167 std::string::size_type
idx;
168 if (
idx1 == std::string::npos) {
170 }
else if (
idx2 == std::string::npos) {
176 if (
idx != std::string::npos) {
178 return filename.substr(
idx + 1);
187 std::string::size_type
idx = filename.rfind(
'/');
189 std::string::size_type
idx1 = filename.rfind(
'\\');
190 std::string::size_type
idx2 = filename.rfind(
'/');
191 std::string::size_type
idx;
192 if (
idx1 == std::string::npos) {
194 }
else if (
idx2 == std::string::npos) {
200 if (
idx != std::string::npos) {
202 return filename.substr(0,
idx+1);
211 std::string::size_type
pos =
s.find_last_not_of(
" \t");
212 if (
pos != std::string::npos)
215 pos =
s.find_first_not_of(
" \t");
216 if (
pos != std::string::npos)
223 s.erase(
s.begin(),
s.end());
235 std::sprintf(
fmt,
"%%.%df", std::min(
digits, 16));
249 while ( l != 0 &&
number[l] ==
'0' ) {
271 int x =
atoi(
s.c_str());
287 val =
static_cast<unsigned int>(x);
296 std::vector<std::string> result;
297 std::size_t
pos =
s.find_first_of(
sep, 0);
298 std::size_t
pos2 = 0;
299 while (
pos != std::string::npos)
313 if (
pos2 <
s.length())
315 std::string
t(
s.substr(
pos2));
328 while (
found != std::string::npos)
337 const auto it = std::search(
s1.begin(),
s1.end(),
s2.begin(),
s2.end(), [](
const char a,
const char b)->bool { return std::tolower(a) == std::tolower(b); });
338 return it !=
s1.end();
342 double &r,
double &
g,
double &b)
364 std::ifstream
ifile(filename.c_str());
365 return !
ifile.fail();
383 std::ofstream os(filename.c_str());
408 return (vigra::impexListExtensions().
find(
extension) != std::string::npos);
450 return std::filesystem::absolute(
data_path.parent_path() /
".." /
"share" /
"hugin" /
"data").string() +
"\\";
452 return std::string();
453#elif defined MAC_SELF_CONTAINED_BUNDLE
463#elif defined UNIX_SELF_CONTAINED_BUNDLE
464 std::filesystem::path
data_path = std::filesystem::read_symlink(
"/proc/self/exe");
468 return (
data_path.parent_path() /
"share/hugin/data").string() +
"/";
470 return std::string();
491 return std::string();
499 std::filesystem::path path;
504 return std::string();
506 path = std::filesystem::path(
fullpath);
517 return std::string();
519 path = std::filesystem::path(
homeDir);
520 path /=
".local/share/hugin";
529 if (!std::filesystem::exists(path))
531 if (!std::filesystem::create_directories(path))
533 std::cerr <<
"ERROR: Could not create destination directory: " << path.string() << std::endl
534 <<
"Maybe you have not sufficient rights to create this directory." << std::endl;
535 return std::string();
538 return path.string();
543struct ContextSettings
610#if defined HAVE_EPOXY && HAVE_EPOXY
621#if defined HAVE_EPOXY && HAVE_EPOXY
637#elif defined __APPLE__
659#if defined HAVE_EGL && HAVE_EGL
660#if defined HAVE_EPOXY && HAVE_EPOXY
661#include <epoxy/egl.h>
666struct ContextSettings
691 std::cerr <<
"Could not connect to EGL_DEFAULT_DISPLAY" << std::endl;
698 std::cerr <<
"Could not initialize EGL" << std::endl
699 <<
"Error: 0x" << std::hex <<
eglGetError() << std::endl;
702 std::cout <<
"Init OpenGL ES " <<
major <<
"." <<
minor << std::endl;
710 std::cerr <<
"Could not bind OpenGL API" << std::endl
711 <<
"Error: 0x" << std::hex <<
eglGetError() << std::endl;
719 std::cerr <<
"Cound not set egl config" << std::endl
720 <<
"Error: 0x" << std::hex <<
eglGetError() << std::endl;
728 std::cerr <<
"Cound not create context" << std::endl
729 <<
"Error: 0x" << std::hex <<
eglGetError() << std::endl;
734 std::cerr <<
"Could not make current context" << std::endl
735 <<
"Error: 0x" << std::hex <<
eglGetError() << std::endl;
749#include <X11/Xutil.h>
750#if defined HAVE_EPOXY && HAVE_EPOXY
751#include <epoxy/glx.h>
806 swa.border_pixel = 0;
852#if defined HAVE_EPOXY && HAVE_EPOXY
865 std::cerr <<
argv[0] <<
": an error occurred while setting up the GPU:" << std::endl;
867 std::cerr <<
argv[0] <<
": Switching to CPU calculation." << std::endl;
883 const char *
msg[] = {
"false",
"true"};
892 std::cerr <<
argv[0] <<
": This graphics system lacks the necessary extensions for -g." << std::endl;
893 std::cerr <<
argv[0] <<
": Switching to CPU calculation." << std::endl;
912std::string
GetICCDesc(
const vigra::ImageImportInfo::ICCProfile& iccProfile)
914 if (iccProfile.empty())
917 return std::string();
923 return std::string();
942#if LCMS_VERSION >= 2130
944 if (iccProfile.empty())
957 return gamma > 0.6 && gamma < 1.4;
966 std::vector<std::string>
rawExt{
"dng",
"crw",
"cr2",
"cr3",
"raw",
"erf",
"raf",
"mrw",
"nef",
"orf",
"rw2",
"pef",
"srw",
"arw" };
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 CreateContext(int *argcp, char **argv)
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
bool IsRawExtension(const std::string testExt)
return true if extension belongs to a raw file
std::string tolower(const std::string &s)
convert a string to lowercase
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
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.
static ContextSettings context
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.
functions to manage ROI's