#include <IPSDKCore/Config/LibraryInitializer.h>
#include <IPSDKIPL/IPSDKIPLShapeAnalysis/Measure/Geometry/Basic/HolesBasicPolicyMsrParams.h>
#include <IPSDKIPL/IPSDKIPLShapeAnalysis/Measure/Geometry/FormFactor/MaxFeretDiameter/MaxFeretDiameterMsrParams.h>
#include <IPSDKIPL/IPSDKIPLShapeAnalysis/Measure/Geometry/FormFactor/MinFeretDiameter/MinFeretDiameterMsrParams.h>
#include <IPSDKBaseShapeAnalysis/Measure/BaseMeasure.h>
#include <IPSDKBaseShapeAnalysis/Measure/Result/ValueMeasureResult.h>
#include <IPSDKBaseShapeAnalysis/Measure/Info/MeasureInfoSet.h>
#include <IPSDKBaseShapeAnalysis/Measure/MeasureSet.h>
#include <IPSDKBaseShapeSegmentation/Entity/3d/Shape3dColl.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& inputGreyImgPath,
boost::filesystem::path& inputBinImgPath,
boost::filesystem::path& outputCsvResultPath);
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 inputGreyImgPath, inputBinImgPath, outputCsvResultPath;
if(!
readCmdArguments(argc, argv, inputGreyImgPath, inputBinImgPath, outputCsvResultPath))
return -1;
% inputGreyImgPath.string());
% inputBinImgPath.string());
const MeasureConstPtr& pAreaMinusHolesOutMsr = pOutMeasureSet->getMeasure(
"AreaMinusHoles");
const std::vector<ipReal64>& pAreaMinusHolesRes = extractValueResults<ipReal64>(pAreaMinusHolesOutMsr);
% outputCsvResultPath.string());
if (bWritten == false) {
% outputCsvResultPath.string() % bWritten.getMsg());
return -1;
}
return 0;
}
bool
boost::filesystem::path& inputGreyImgPath,
boost::filesystem::path& inputBinImgPath,
boost::filesystem::path& outputCsvResultPath)
{
boost::program_options::options_description desc("Allowed options");
desc.add_options()
("help", "produce help message")
("inputGreyImgPath", value<path>(),
"input grey image file path (optional; only TIFF format is accepted)")
("inputBinImgPath", value<path>(),
"input binary image file path (optional; only TIFF format is accepted)")
("outputCsvResultPath", value<path>(),
"output csv result file path (optional)")
;
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;
}
inputGreyImgPath =
getIPSDKDirectory(eInternalDirectory::eID_Images) /
"blobs3d_483x348x31_UInt8.tif";
if(vm.count("inputGreyImgPath"))
inputGreyImgPath = vm["inputGreyImgPath"].as<path>();
const boost::filesystem::path binRelToRootDir =
path("data") / "Sample" / "images" / "blobs3d_483x348x31_Binary.tif";
if(!boost::filesystem::exists(inputBinImgPath))
if(vm.count("inputBinImgPath"))
inputBinImgPath = vm["inputBinImgPath"].as<path>();
if(vm.count("outputCsvResultPath"))
outputCsvResultPath = vm["outputCsvResultPath"].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());
}
}
outputCsvResultPath = outputDir / "shapeAnalysis3d.csv";
}
return true;
}