seqan::ArgumentParser buildParser(void) { seqan::ArgumentParser parser; setCategory(parser, "5-prime end counter"); setShortDescription(parser, "Preprocessing Pipeline for Chip-Nexus and Chip-Exo data"); addUsageLine(parser, " \\fI<READ_FILE1> \\fP \\fI[OPTIONS]\\fP"); addDescription(parser, ""); addDescription(parser, ""); seqan::setVersion(parser, SEQAN_APP_VERSION " [" SEQAN_REVISION "]"); setDate(parser, SEQAN_DATE); seqan::ArgParseArgument fileArg(seqan::ArgParseArgument::INPUT_FILE, "positions in bed-format", true); setValidValues(fileArg, ".bed"); addArgument(parser, fileArg); setHelpText(parser, 0, "bed file"); seqan::ArgParseOption readsOpt = seqan::ArgParseOption( "i", "input", "Name of the reads file.", seqan::ArgParseOption::INPUT_FILE, "INPUT"); setValidValues(readsOpt, seqan::BamFileIn::getFileExtensions()); addOption(parser, readsOpt); seqan::ArgParseOption outputOpt = seqan::ArgParseOption( "o", "output", "Name of output file.", seqan::ArgParseOption::INPUT_FILE, "INPUT"); addOption(parser, outputOpt); seqan::ArgParseOption radiusOpt = seqan::ArgParseOption( "r", "radius", "radius around peaks to scan ", seqan::ArgParseOption::INTEGER, "VALUE"); setDefaultValue(radiusOpt, 1000); setMinValue(radiusOpt, "1"); addOption(parser, radiusOpt); seqan::ArgParseOption filterChromosomesOpt = seqan::ArgParseOption( "fc", "filterChromosomes", "Regular expression to remove chromosomes", seqan::ArgParseOption::STRING, "REGEX"); addOption(parser, filterChromosomesOpt); return parser; }
int main( int argc, const char** argv ) { std::string filename; std::string configFile = ""; bool outputJson = false; int seektoms = 0; bool detectRegion = false; std::string templateRegion; std::string country; int topn; TCLAP::CmdLine cmd("OpenAlpr Command Line Utility", ' ', Alpr::getVersion()); TCLAP::UnlabeledValueArg<std::string> fileArg( "image_file", "Image containing license plates", false, "", "image_file_path" ); TCLAP::ValueArg<std::string> countryCodeArg("c","country","Country code to identify (either us for USA or eu for Europe). Default=us",false, "us" ,"country_code"); TCLAP::ValueArg<int> seekToMsArg("","seek","Seek to the specied millisecond in a video file. Default=0",false, 0 ,"integer_ms"); TCLAP::ValueArg<std::string> configFileArg("","config","Path to the openalpr.conf file",false, "" ,"config_file"); TCLAP::ValueArg<std::string> templateRegionArg("t","template_region","Attempt to match the plate number against a region template (e.g., md for Maryland, ca for California)",false, "" ,"region code"); TCLAP::ValueArg<int> topNArg("n","topn","Max number of possible plate numbers to return. Default=10",false, 10 ,"topN"); TCLAP::SwitchArg jsonSwitch("j","json","Output recognition results in JSON format. Default=off", cmd, false); TCLAP::SwitchArg detectRegionSwitch("d","detect_region","Attempt to detect the region of the plate image. Default=off", cmd, false); TCLAP::SwitchArg clockSwitch("","clock","Measure/print the total time to process image and all plates. Default=off", cmd, false); try { cmd.add( templateRegionArg ); cmd.add( seekToMsArg ); cmd.add( topNArg ); cmd.add( configFileArg ); cmd.add( fileArg ); cmd.add( countryCodeArg ); if (cmd.parse( argc, argv ) == false) { // Error occured while parsing. Exit now. return 1; } filename = fileArg.getValue(); country = countryCodeArg.getValue(); seektoms = seekToMsArg.getValue(); outputJson = jsonSwitch.getValue(); configFile = configFileArg.getValue(); detectRegion = detectRegionSwitch.getValue(); templateRegion = templateRegionArg.getValue(); topn = topNArg.getValue(); measureProcessingTime = clockSwitch.getValue(); } catch (TCLAP::ArgException &e) // catch any exceptions { std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl; return 1; } cv::Mat frame; Alpr alpr(country, configFile); alpr.setTopN(topn); if (detectRegion) alpr.setDetectRegion(detectRegion); if (templateRegion.empty() == false) alpr.setDefaultRegion(templateRegion); if (alpr.isLoaded() == false) { std::cerr << "Error loading OpenALPR" << std::endl; return 1; } if (filename.empty()) { std::string filename; while (std::getline(std::cin, filename)) { if (fileExists(filename.c_str())) { frame = cv::imread( filename ); detectandshow( &alpr, frame, "", outputJson); } else { std::cerr << "Image file not found: " << filename << std::endl; } } } else if (filename == "webcam") { int framenum = 0; cv::VideoCapture cap(0); if (!cap.isOpened()) { std::cout << "Error opening webcam" << std::endl; return 1; } while (cap.read(frame)) { detectandshow(&alpr, frame, "", outputJson); usleep(1000); framenum++; } } else if (startsWith(filename, "http://") || startsWith(filename, "https://")) { int framenum = 0; VideoBuffer videoBuffer; videoBuffer.connect(filename, 5); cv::Mat latestFrame; while (program_active) { int response = videoBuffer.getLatestFrame(&latestFrame); if (response != -1) { detectandshow( &alpr, latestFrame, "", outputJson); } // Sleep 10ms usleep(10000); } videoBuffer.disconnect(); std::cout << "Video processing ended" << std::endl; } else if (hasEndingInsensitive(filename, ".avi") || hasEndingInsensitive(filename, ".mp4") || hasEndingInsensitive(filename, ".webm") || hasEndingInsensitive(filename, ".flv") || hasEndingInsensitive(filename, ".mjpg") || hasEndingInsensitive(filename, ".mjpeg")) { if (fileExists(filename.c_str())) { int framenum = 0; cv::VideoCapture cap=cv::VideoCapture(); cap.open(filename); cap.set(CV_CAP_PROP_POS_MSEC, seektoms); while (cap.read(frame)) { if (SAVE_LAST_VIDEO_STILL) { cv::imwrite(LAST_VIDEO_STILL_LOCATION, frame); } std::cout << "Frame: " << framenum << std::endl; detectandshow( &alpr, frame, "", outputJson); //create a 1ms delay usleep(1000); framenum++; } } else { std::cerr << "Video file not found: " << filename << std::endl; } } else if (hasEndingInsensitive(filename, ".png") || hasEndingInsensitive(filename, ".jpg") || hasEndingInsensitive(filename, ".jpeg") || hasEndingInsensitive(filename, ".gif")) { if (fileExists(filename.c_str())) { frame = cv::imread( filename ); detectandshow( &alpr, frame, "", outputJson); } else { std::cerr << "Image file not found: " << filename << std::endl; } } else if (DirectoryExists(filename.c_str())) { std::vector<std::string> files = getFilesInDir(filename.c_str()); std::sort( files.begin(), files.end(), stringCompare ); for (int i = 0; i< files.size(); i++) { if (hasEndingInsensitive(files[i], ".jpg") || hasEndingInsensitive(files[i], ".png")) { std::string fullpath = filename + "/" + files[i]; std::cout << fullpath << std::endl; frame = cv::imread( fullpath.c_str() ); if (detectandshow( &alpr, frame, "", outputJson)) { //while ((char) cv::waitKey(50) != 'c') { } } else { //cv::waitKey(50); } } } } else { std::cerr << "Unknown file type" << std::endl; return 1; } return 0; }
int main(int argc, char *argv[]) { // set up MPI //MPI_Init(&argc, &argv); //int rank, p; //MPI_Comm_rank(MPI_COMM_WORLD, &rank); //MPI_Comm_size(MPI_COMM_WORLD, &p); mxx::env e(argc, argv); mxx::env::set_exception_on_error(); mxx::comm comm = mxx::comm(); try { // define commandline usage TCLAP::CmdLine cmd("Parallel distirbuted suffix array and LCP construction."); TCLAP::ValueArg<std::string> fileArg("f", "file", "Input filename.", true, "", "filename"); TCLAP::ValueArg<std::size_t> randArg("r", "random", "Random input size", true, 0, "size"); cmd.xorAdd(fileArg, randArg); TCLAP::ValueArg<int> seedArg("s", "seed", "Sets the seed for the ranom input generation", false, 0, "int"); cmd.add(seedArg); TCLAP::SwitchArg lcpArg("l", "lcp", "Construct the LCP alongside the SA.", false); cmd.add(lcpArg); TCLAP::SwitchArg checkArg("c", "check", "Check correctness of SA (and LCP).", false); cmd.add(checkArg); cmd.parse(argc, argv); // read input file or generate input on master processor // block decompose input file std::string local_str; if (fileArg.getValue() != "") { local_str = mxx::file_block_decompose(fileArg.getValue().c_str(), MPI_COMM_WORLD); } else { // TODO proper distributed random! local_str = rand_dna(randArg.getValue()/comm.size(), seedArg.getValue() * comm.rank()); } // TODO differentiate between index types // run our distributed suffix array construction mxx::timer t; double start = t.elapsed(); if (lcpArg.getValue()) { // construct with LCP suffix_array<std::string::iterator, index_t, true> sa(local_str.begin(), local_str.end(), MPI_COMM_WORLD); // TODO choose construction method sa.construct(true); double end = t.elapsed() - start; if (comm.rank() == 0) std::cerr << "PSAC time: " << end << " ms" << std::endl; if (checkArg.getValue()) { gl_check_correct(sa, local_str.begin(), local_str.end(), MPI_COMM_WORLD); } } else { // construct without LCP suffix_array<std::string::iterator, index_t, false> sa(local_str.begin(), local_str.end(), MPI_COMM_WORLD); // TODO choose construction method sa.construct_arr<2>(true); double end = t.elapsed() - start; if (comm.rank() == 0) std::cerr << "PSAC time: " << end << " ms" << std::endl; if (checkArg.getValue()) { gl_check_correct(sa, local_str.begin(), local_str.end(), MPI_COMM_WORLD); } } // catch any TCLAP exception } catch (TCLAP::ArgException& e) { std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl; exit(EXIT_FAILURE); } // finalize MPI //MPI_Finalize(); return 0; }
int main(int argc, char *argv[]) { // set up MPI MPI_Init(&argc, &argv); int rank; MPI_Comm_rank(MPI_COMM_WORLD, &rank); try { // define commandline usage TCLAP::CmdLine cmd("Compare our parallel implementation with divsufsort."); TCLAP::ValueArg<std::string> fileArg("f", "file", "Input filename.", true, "", "filename"); TCLAP::ValueArg<std::size_t> randArg("r", "random", "Random input size", true, 0, "size"); TCLAP::ValueArg<int> seedArg("s", "seed", "Sets the seed for the ranom input generation", false, 0, "int"); cmd.add(seedArg); cmd.xorAdd(fileArg, randArg); TCLAP::SwitchArg checkArg("c", "check", "Check correctness of SA for PSAC using divsufsort `sufcheck()`.", false); cmd.add(checkArg); cmd.parse(argc, argv); // read input file or generate input on master processor std::string input_str; if (rank == 0) { if (fileArg.getValue() != "") { std::ifstream t(fileArg.getValue().c_str()); std::stringstream buffer; buffer << t.rdbuf(); input_str = buffer.str(); } else { input_str = rand_dna(randArg.getValue(), seedArg.getValue()); } } // TODO differentiate between index types // run our distributed suffix array construction std::string local_str = mxx::stable_distribute(input_str, MPI_COMM_WORLD); mxx::timer t; double start = t.elapsed(); suffix_array<std::string::iterator, index_t, false> sa(local_str.begin(), local_str.end(), MPI_COMM_WORLD); // TODO: choose construction method! sa.construct_arr<2>(true); //sa.construct_arr<2>(); double end = t.elapsed() - start; if (rank == 0) std::cerr << "PSAC time: " << end << " ms" << std::endl; std::vector<index_t> glSA = mxx::gatherv(sa.local_SA, 0); // run construction with divsufsort locally on rank 0 if (rank == 0) { mxx::timer t; std::vector<index_t> SA; double start = t.elapsed(); dss::construct(input_str.begin(), input_str.end(), SA); double end = t.elapsed() - start; std::cerr << "divsufsort time: " << end << " ms" << std::endl; // check correctness if we should do so! if (checkArg.getValue()) { std::cerr << "Checking for correctness..." << std::endl; if(!dss::check(input_str.begin(), input_str.end(), glSA)) { std::cerr << "ERROR: wrong suffix array from PSAC" << std::endl; return false; } if(!dss::check(input_str.begin(), input_str.end(), SA)) { std::cerr << "ERROR: wrong suffix array from divsufsort" << std::endl; } } } // catch any TCLAP exception } catch (TCLAP::ArgException& e) { std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl; exit(EXIT_FAILURE); } // finalize MPI MPI_Finalize(); return 0; }
//------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------- int main(int argc, char *argv[]) { QApplication a(argc, argv); QDir::setCurrent(a.applicationDirPath()); // See if we are loading something from the commandline. QString fileArg(""); QString suffix(""); QString argument = a.arguments().last(); QFileInfo info(a.arguments().last()); if(info.exists() && info.isFile()) { if(info.suffix() == "ogscene") { // Yes we've got an ogscene file to load. fileArg = info.absoluteFilePath(); suffix = info.suffix(); } else if(info.baseName() != "qtOgitor" && info.baseName() != "qtOgitor_d" ) { // We are trying to load something we can't load // Exit the application. QMessageBox msg(QMessageBox::Critical, "Ogitor Error", "We can only load Ogitor Scenes.\nExiting.."); msg.exec(); return 0; } } a.setOrganizationName("Ogitor"); a.setApplicationName("qtOgitor"); #if(OGRE_PLATFORM == OGRE_PLATFORM_APPLE) QFile file(":/stylesheets/osx.qss"); #else QFile file(":/stylesheets/obsidian.qss"); #endif file.open(QFile::ReadOnly); QString styleSheet = QLatin1String(file.readAll()); a.setStyleSheet(styleSheet); QSettings settings; QString languageFile = settings.value("preferences/customLanguage").toString(); QTranslator qtTranslator; QTranslator ogitorTranslator; if(languageFile != "ogitor_en.qm") { QString lang = "../languages/qt_" + languageFile; lang.remove("ogitor_"); QString lang2 = "../languages/" + languageFile; if(QFile::exists(lang) && QFile::exists(lang2)) { if(qtTranslator.load(lang)) a.installTranslator(&qtTranslator); if(ogitorTranslator.load(lang2)) a.installTranslator(&ogitorTranslator); } else { // If the system-wide Qt translation file is present, load it. if(qtTranslator.load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath))) { a.installTranslator(&qtTranslator); } // Otherwise: load our own Qt translation file. else if(qtTranslator.load("../languages/qt_" + QLocale::system().name())) { a.installTranslator(&qtTranslator); } // Install qtOgitor translator if(ogitorTranslator.load("../languages/ogitor_" + QLocale::system().name())) { a.installTranslator(&ogitorTranslator); } } } bool skipSplash = settings.value("preferences/skipSplash", false).toBool(); QSplashScreen *splash; if(!skipSplash) { QPixmap pixmap(":/images/OgitorLogo.png"); splash = new QSplashScreen(pixmap); splash->show(); } #ifdef _DEBUG setupOgre(resourcePath() + Ogre::String("plugins_debug.cfg"), Ogre::String("ogre.cfg"), Ogre::String("ogitor.log")); #else setupOgre(resourcePath() + Ogre::String("plugins.cfg"), Ogre::String("ogre.cfg"), Ogre::String("ogitor.log")); #endif readRecentFiles(settings); mOgitorMainWindow = new MainWindow(); mOgitorMainWindow->show(); mOgitorMainWindow->setApplicationObject(&a); QString sceneToLoad = ""; QString lastLoadedScene = settings.value("preferences/lastLoadedScene", "").toString(); if((settings.value("preferences/loadLastLoadedScene", false).toBool()) && (fileArg.isEmpty())) { if(!lastLoadedScene.isEmpty()) { sceneToLoad = lastLoadedScene; } } else if(!fileArg.isEmpty()) { sceneToLoad = fileArg; } if(!sceneToLoad.isEmpty()) { if(suffix == "material") { } else { Ogitors::OgitorsRoot::getSingletonPtr()->LoadScene(sceneToLoad.toStdString()); } } mOgitorMainWindow->repaint(); if(!skipSplash) { splash->finish(mOgitorMainWindow); delete splash; } int retval = a.exec(); writeRecentFiles(); delete mOgitorMainWindow; delete shortCuts; OGRE_DELETE mOgitorsRoot; OGRE_DELETE mSystem; OGRE_DELETE mOgreRoot; return retval; }