#include #include #include #include #include #include #include #include class Config { public: std::vector inputImages; std::string maskFileName = ""; std::string outputFileName = "out.xyz"; float scaleX = 0.01; float scaleY = 0.01; float scaleZ = 0.3; }; void cd_to_exe_dir( char *argv[] ) { std::string path = argv[0]; int ii = path.length(); while ( !( path[ii] == '/' || path[ii] == '\\' ) && ii > 0 ) { ii--; } path.erase( ii, 100 ); chdir( path.c_str() ); } static void printUsage() { std::cout<<"scannassembler --output outImage inImage\n"; } static int parseCmdArgs(int argc, char** argv, Config *config) { if (argc == 1) { printUsage(); return -1; } for (int i = 1; i < argc; i++) { if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { printUsage(); return -1; } else if (std::string(argv[i]) == "--output" || std::string(argv[i]) == "-o") { i++; if(argc > i) config->outputFileName = argv[i]; else return -1; } else if (std::string(argv[i]) == "--mask" || std::string(argv[i]) == "-m") { i++; if(argc > i) config->maskFileName = argv[i]; else return -1; } else if (std::string(argv[i]) == "--scale" || std::string(argv[i]) == "-s") { if(argc > i+3) { config->scaleX = atof(argv[i+1]); config->scaleY = atof(argv[i+2]); config->scaleZ = atof(argv[i+3]); i+=3; } else return -1; } else if (std::string(argv[i]) == "--mask" || std::string(argv[i]) == "-m") { i++; if(argc > i) config->maskFileName = argv[i]; else return -1; } else config->inputImages.push_back(argv[i]); } return 0; } void showImages(std::vector images) { cv::namedWindow( "Viewer", cv::WINDOW_AUTOSIZE ); for(uint i = 0; i< images.size(); i++) { cv::imshow( "Viewer", images[i] ); cv::waitKey(0); } cv::destroyWindow("Viewer"); } void showImages(std::vector images) { cv::namedWindow( "Viewer", cv::WINDOW_AUTOSIZE ); for(uint i = 0; i< images.size(); i++) { cv::imshow( "Viewer", images[i] ); cv::waitKey(0); } cv::destroyWindow("Viewer"); } void showImages(cv::Mat image) { cv::namedWindow( "Viewer", cv::WINDOW_AUTOSIZE ); cv::imshow( "Viewer", image ); cv::waitKey(0); cv::destroyWindow("Viewer"); } std::vector loadImages(std::vector fileNames) { std::vector images; for(uint i = 0; i < fileNames.size(); i++) { cv::Mat tmpImage = cv::imread(fileNames[i]); if(tmpImage.data)images.push_back(tmpImage); else { std::cout<<"can not read image "<(x,y)) outputFile<