#include <IPSDKCore/Config/LibraryInitializer.h>
#include <IPSDKBaseProcessing/Logger/IPSDKBaseProcessingException.h>
#include <IPSDKImageFile/Logger/IPSDKImageFileException.h>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/convenience.hpp>
#include <boost/program_options/cmdline.hpp>
#include <boost/program_options/options_description.hpp>
#include <boost/program_options/parsers.hpp>
#include <boost/program_options/variables_map.hpp>
#include <log4cplus/consoleappender.h>
#include <iostream>
bool
boost::filesystem::path& inImgFilePath,
boost::filesystem::path& outImgFilePath);
int
main(
int argc,
char* argv[])
{
log4cplus::SharedAppenderPtr pConsole(new log4cplus::ConsoleAppender);
log4cplus::Logger::getRoot().addAppender(pConsole);
log4cplus::Logger::getRoot().setLogLevel(log4cplus::INFO_LOG_LEVEL);
case ipsdk::core::eLibInitStatus::eLIS_Warn:
break;
case ipsdk::core::eLibInitStatus::eLIS_Failed:
return -1;
break;
default:
break;
}
boost::filesystem::path inImgFilePath, outImgFilePath;
return -1;
% inImgFilePath.string());
try {
% inImgFilePath.string() % e.
getMsg());
return -1;
}
try {
return -1;
}
% outImgFilePath.string());
try {
% outImgFilePath % e.
getMsg());
return -1;
}
return 0;
}
bool
boost::filesystem::path& inImgFilePath,
boost::filesystem::path& outImgFilePath)
{
boost::program_options::options_description desc("Allowed options");
desc.add_options()
("help", "produce help message")
("inputImgFilePath", value<path>(),
"input image file path (optional; only TIFF format is accepted)")
("outputImgFilePath", value<path>(),
"output image file path (optional; only TIFF format is accepted)")
;
boost::program_options::variables_map vm;
try {
boost::program_options::store(parse_command_line(argc, argv, desc), vm);
} catch(const std::exception& e) {
% e.what());
return false;
}
boost::program_options::notify(vm);
if (vm.count("help")) {
std::cout << desc << "\n";
return false;
}
inImgFilePath =
getIPSDKDirectory(eInternalDirectory::eID_Images) /
"Lena_510x509_UInt8.tif";
if(vm.count("inputImgFilePath"))
inImgFilePath = vm["inputImgFilePath"].as<path>();
if(vm.count("outputImgFilePath"))
outImgFilePath = vm["outputImgFilePath"].as<path>();
else {
const path outputDir =
"Sample";
if(!boost::filesystem::exists(outputDir)) {
try {
boost::filesystem::create_directories(outputDir);
} catch(const std::exception& e) {
% outputDir % e.what());
}
}
outImgFilePath = outputDir / "otsu.tif";
}
if(!boost::filesystem::exists(inImgFilePath)) {
% inImgFilePath);
return false;
}
return true;
}