Ejemplo n.º 1
0
    foreach (const QString &dir, dirs) {
        if ((dir.at(0) == QChar('.'))
                || (dir.right(5) == "build")
                || (dir.right(flags->outputDirectory().length()) == flags->outputDirectory())) {
            // Don't touch hidden directiories
            // Don't touch build directory
            // Don't touch output directory
            continue;
        }

        QString outputPath = tempOutput.path() + "/" + dir;
        QDir outputDir(outputPath);
        QDir inputDir(tempInput.path() + "/" + dir);
        convertDirectory(inputDir, outputDir);
    }
Ejemplo n.º 2
0
int main(int argc, char *argv[])
{
	if (argc!=5)
	{
		qWarning(QString("Usage: %1 <input_path> <output_path> <output_extent> <output format>").arg(argv[0]).toLocal8Bit().data());
		return -1;
	}

	int extent = QString(argv[3]).toInt();
	if (extent<=0)
	{
		qWarning(QString("Extent should be more than zero!").toLocal8Bit().data());
		return -2;
	}


	QDir inputDir(argv[1]);
	QDir outputDir(argv[2]);

	QStringList files = inputDir.entryList(QStringList("*.svg"), QDir::Files);
	for (QStringList::ConstIterator it=files.constBegin(); it!=files.constEnd(); ++it)
	{
		QFile input(inputDir.absoluteFilePath(*it));
		if (input.open(QIODevice::ReadOnly))
		{
			QImageReader reader(&input);
			reader.setScaledSize(QSize(extent, extent));
			QImage image = reader.read();
			input.close();

			QString fileName = QFileInfo(input).fileName();
			fileName.chop(fileName.length()-fileName.lastIndexOf('.')-1);
			fileName.append(argv[4]);
			QFile output(outputDir.absoluteFilePath(fileName));
			if (output.open(QIODevice::WriteOnly))
			{
				QImageWriter writer(&output, argv[4]);
				writer.write(image);
				output.close();
			}
		}
	}
}
Ejemplo n.º 3
0
void EditorBodyControl::PackLightmaps()
{
	SceneData *sceneData = SceneDataManager::Instance()->SceneGetActive();

	FilePath inputDir(EditorSettings::Instance()->GetProjectPath()+"DataSource/lightmaps_temp/");

 	FilePath outputDir = FilePath::CreateWithNewExtension(sceneData->GetScenePathname(),  + ".sc2_lightmaps/");

	FileSystem::Instance()->MoveFile(inputDir+"landscape.png", "test_landscape.png", true);

	LightmapsPacker packer;
	packer.SetInputDir(inputDir);

	packer.SetOutputDir(outputDir);
	packer.PackLightmaps(EditorSettings::Instance()->GetTextureViewGPU());
	packer.CreateDescriptors();
	packer.ParseSpriteDescriptors();

	BeastProxy::Instance()->UpdateAtlas(beastManager, packer.GetAtlasingData());

	FileSystem::Instance()->MoveFile("test_landscape.png", outputDir+"landscape.png", true);
}
Ejemplo n.º 4
0
/*!
  Main conversion routine.
  */
void ConverterCore::convert()
{
    if (helpMode)
        return;

    if ((flags->inputDirectory() == flags->outputDirectory())
            && !(flags->flags() & ConverterFlags::Force)
            && !(flags->flags() & ConverterFlags::Suffix)) {
        enterErrorState("Will not overwrite without --force or a given --suffix.");
        return;
    }

    QString input;
    QString output;

    if (flags->inputDirectory() == "") {
        input = ".";
    } else {
        input = flags->inputDirectory();
    }

    if (flags->outputDirectory() == "") {
        output = ".";
    } else {
        output = flags->outputDirectory();
    }

    QDir inputDir(input);
    QDir outputDir(output);

    convertDirectory(inputDir, outputDir);

    ConverterQrcGenerator qrcGenerator(flags, this);
    qrcGenerator.createQrcFiles();
    if (qrcGenerator.isErrorState()) {
        enterErrorState(qrcGenerator.errorMessage());
    }
}
Ejemplo n.º 5
0
int main(int argc, const char** argv) {
    
    boost::program_options::options_description desc("Allowed options");
    desc.add_options()
        ("help", "produce help message")
        ("input", boost::program_options::value<std::string>(), "the folder to process")
        ("lambda", boost::program_options::value<double>()->default_value(0.5), "lambda")
        ("sigma", boost::program_options::value<double>()->default_value(5.0), "sigma")
        ("four-connected", "use 4-connected")
        ("superpixels", boost::program_options::value<int>()->default_value(400), "number of superpixels")
        ("time", boost::program_options::value<std::string>(), "time the algorithm and save results to the given directory")
        ("process", "show additional information while processing")
        ("csv", "save segmentation as CSV file")
        ("contour", "save contour image of segmentation")
        ("mean", "save mean colored image of segmentation")
        ("output", boost::program_options::value<std::string>()->default_value("output"), "specify the output directory (default is ./output)");

    boost::program_options::positional_options_description positionals;
    positionals.add("input", 1);
    
    boost::program_options::variables_map parameters;
    boost::program_options::store(boost::program_options::command_line_parser(argc, argv).options(desc).positional(positionals).run(), parameters);
    boost::program_options::notify(parameters);

    if (parameters.find("help") != parameters.end()) {
        std::cout << desc << std::endl;
        return 1;
    }
    
    boost::filesystem::path outputDir(parameters["output"].as<std::string>());
    if (!boost::filesystem::is_directory(outputDir)) {
        boost::filesystem::create_directory(outputDir);
    }
    
    boost::filesystem::path inputDir(parameters["input"].as<std::string>());
    if (!boost::filesystem::is_directory(inputDir)) {
        std::cout << "Image directory not found ..." << std::endl;
        return 1;
    }
    
    bool process = false;
    if (parameters.find("process") != parameters.end()) {
        process = true;
    }
    
    std::vector<boost::filesystem::path> pathVector;
    std::vector<boost::filesystem::path> images;
    
    std::copy(boost::filesystem::directory_iterator(inputDir), boost::filesystem::directory_iterator(), std::back_inserter(pathVector));

    std::sort(pathVector.begin(), pathVector.end());
    
    std::string extension;
    int count = 0;
    
    for (std::vector<boost::filesystem::path>::const_iterator iterator (pathVector.begin()); iterator != pathVector.end(); ++iterator) {
        if (boost::filesystem::is_regular_file(*iterator)) {
            
            // Check supported file extensions.
            extension = iterator->extension().string();
            std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
            
            if (extension == ".png" || extension == ".jpg" || extension == ".jpeg") {
                images.push_back(*iterator);
                
                if (process == true) {
                    std::cout << "Found " << iterator->string() << " ..." << std::endl;
                }
                
                ++count;
            }
        }
    }
    
    std::cout << count << " images total ..." << std::endl;
    
    boost::timer timer;
    double totalTime = 0;
    
    int eightConnected = 1;
    if (parameters.find("four-connected") != parameters.end()) {
        eightConnected = 0;
    }
    
    int superpixels = parameters["superpixels"].as<int>();
    int kernel = 0;
    double lambda = parameters["lambda"].as<double>();
    double sigma = parameters["sigma"].as<double>();
    MERCLazyGreedy merc;
    
    cv::Mat time(images.size(), 2, cv::DataType<double>::type);
    for(std::vector<boost::filesystem::path>::iterator iterator = images.begin(); iterator != images.end(); ++iterator) {
        cv::Mat mat = cv::imread(iterator->string());
        
        Image<RGBMap> inputImage;
        MERCInputImage<RGBMap> input;

        inputImage.Resize(mat.cols, mat.rows, false);

        for (int i = 0; i < mat.rows; ++i) {
            for (int j = 0; j < mat.cols; ++j) {
                RGBMap color((int) mat.at<cv::Vec3b>(i, j)[2], (int) mat.at<cv::Vec3b>(i, j)[1], (int) mat.at<cv::Vec3b>(i, j)[0]);
                inputImage.Access(j, i) = color;
            }
        }

        input.ReadImage(&inputImage, eightConnected);
		
        timer.restart();
        int index = std::distance(images.begin(), iterator);
        
        merc.ClusteringTreeIF(input.nNodes_, input, kernel, sigma*mat.channels(), lambda*1.0*superpixels, superpixels);
        
        time.at<double>(index, 1) = timer.elapsed();
        time.at<double>(index, 0) = index + 1;
        totalTime += time.at<double>(index, 1);
        
	vector<int> label = MERCOutputImage::DisjointSetToLabel(merc.disjointSet_);
        
        int** labels = new int*[mat.rows];
        for (int i = 0; i < mat.rows; ++i) {
            labels[i] = new int[mat.cols];
            
            for (int j = 0; j < mat.cols; ++j) {
                labels[i][j] = label[j + i*mat.cols];
            }
        }
        
        Integrity::relabel(labels, mat.rows, mat.cols);
        
        boost::filesystem::path extension = iterator->filename().extension();
        int position = iterator->filename().string().find(extension.string());
        
        if (parameters.find("contour") != parameters.end()) {
            
            std::string store = outputDir.string() + DIRECTORY_SEPARATOR + iterator->filename().string().substr(0, position) + "_contours.png";
            
            int bgr[] = {0, 0, 204};
            cv::Mat contourImage = Draw::contourImage(labels, mat, bgr);
            cv::imwrite(store, contourImage);
            
            if (process == true) {
                std::cout << "Image " << iterator->string() << " with contours saved to " << store << " ..." << std::endl;
            }
        }

        if (parameters.find("mean") != parameters.end()) {
            
            std::string store = outputDir.string() + DIRECTORY_SEPARATOR + iterator->filename().string().substr(0, position) + "_mean.png";

            cv::Mat meanImage = Draw::meanImage(labels, mat);
            cv::imwrite(store, meanImage);

            if (process == true) {
                std::cout << "Image " << iterator->string() << " with mean colors saved to " << store << " ..." << std::endl;
            }
        }

        if (parameters.find("csv") != parameters.end()) {
            
            boost::filesystem::path csvFile(outputDir.string() + DIRECTORY_SEPARATOR + iterator->filename().string().substr(0, position) + ".csv");
            Export::CSV(labels, mat.rows, mat.cols, csvFile);

            if (process == true) {
                std::cout << "Labels for image " << iterator->string() << " saved in " << csvFile.string() << " ..." << std::endl;
            }
        }
        
        for (int i = 0; i < mat.rows; ++i) {
            delete[] labels[i];
        }
        
        delete[] labels;
    }
    
    if (parameters.find("time") != parameters.end()) {
        
        boost::filesystem::path timeDir(parameters["time"].as<std::string>());
        if (!boost::filesystem::is_directory(timeDir)) {
            boost::filesystem::create_directories(timeDir);
        }
        
        boost::filesystem::path timeImgFile(timeDir.string() + DIRECTORY_SEPARATOR + "eval_time_img.txt");
        boost::filesystem::path timeFile(timeDir.string() + DIRECTORY_SEPARATOR + "eval_time.txt");
        
        Export::BSDEvaluationFile<double>(time, 4, timeImgFile);
        
        cv::Mat avgTime(1, 1, cv::DataType<double>::type);
        avgTime.at<double>(0, 0) = totalTime/((double) images.size());
        Export::BSDEvaluationFile<double>(avgTime, 6, timeFile);
    }
    
    std::cout << "On average, " << totalTime/images.size() << " seconds needed ..." << std::endl;
    
    return 0;
}
Ejemplo n.º 6
0
int main(int argc, char** argv)
{
  setTDRStyle();
    

  std::string inputDir("/gwteraz/users/deguio/PLOTS/NTUPLES_useFakeRate/");
  //std::string inputDir("/data2/deguio/Wprime/WprimeAnalysis/WprimeAnalysis/output/FAKERATE/useFakeRate/");
  //std::string outputDir("/gwteraz/users/deguio/PLOTS/FIGURES_numFakeRate/");
  std::string outputDir("/gwteraz/users/deguio/PLOTS/FIGURES_testFakeRate/");

  int step = 10;//numerator & useFakeRate & contamination(senza applicare FR)
  //int step = 8;//denominator
  //float lumi = 201.38; //May10
  float lumi = 1132; //05Jul
  

  std::string drawMode = "eventsScaled";
  //std::string drawMode = "sameAreaStack";
  
  
  // draw plots
  drawTStack_ntu* stack = new drawTStack_ntu(inputDir, "config/crossSections_wPrime_Summer11_ntu.txt", "ntu_WprimeTreeAnalysis", outputDir);
    
  //=============
  //==== Eff ====  
  //=============  
  stack -> DrawEvents("events", lumi, step, true);
  stack -> DrawEvents("eventsScaled", lumi, step, true);
  stack -> DrawEvents("eventsScaledStack", lumi, step, true);
  stack -> DrawEvents("efficiencies", lumi, step, true);
  stack -> DrawEvents("efficienciesRelative", lumi, step, true);

  std::vector<std::string> variableNames;
  variableNames.push_back("");
  std::vector<std::string> variableNames2;
  variableNames2.push_back("");
  variableNames2.push_back("");
  
  std::vector<std::string>* cuts = new std::vector<std::string>;
  cuts->push_back("");
  std::vector<std::string>* cuts2 = new std::vector<std::string>;
  cuts2->push_back("");  
  cuts2->push_back("");
  
  std::string histoName;

  //=============
  //==== MET ====  
  //=============  
  variableNames.at(0) = "met.Et()";
  histoName    = "met";
  cuts->at(0) = "hltPrescale";
  stack -> SetXaxisRange(0., 100.);
  stack -> SetXaxisTitle("PFMet (GeV)");
  stack -> Draw(variableNames, histoName, drawMode, lumi, step, 100, false, cuts);

  variableNames.at(0) = "met.px()";
  histoName    = "mex";
  cuts->at(0) = "hltPrescale";
  stack -> SetXaxisRange(-500., 500.);
  stack -> SetXaxisTitle("PFMex (GeV)");
  stack -> Draw(variableNames, histoName, drawMode, lumi, step, 100, false, cuts);

  variableNames.at(0) = "met.py()";
  histoName    = "mey";
  cuts->at(0) = "hltPrescale";
  stack -> SetXaxisRange(-500., 500.);
  stack -> SetXaxisTitle("PFMey (GeV)");
  stack -> Draw(variableNames, histoName, drawMode, lumi, step, 100, false, cuts);

  //================
  //==== Pho Et ====
  //================
  variableNames.at(0) = "pho.Et()";
  histoName    = "phoEt";
  cuts->at(0) = "hltPrescale";
  stack -> SetXaxisRange(0., 150.);
  stack -> SetXaxisTitle("pho Et (GeV)");
  stack -> Draw(variableNames, histoName, drawMode, lumi, step, 200, false, cuts, false);

  variableNames.at(0) = "pho.Et()";
  histoName    = "phoEt_cumulative";
  cuts->at(0) = "hltPrescale";
  stack -> SetXaxisRange(0., 150.);
  stack -> SetXaxisTitle("pho Et (GeV)");
  stack -> Draw(variableNames, histoName, drawMode, lumi, step, 200, false, cuts, true);

  //================
  //==== Ele Et ====  
  //================
  variableNames.at(0) = "ele.Et()";
  histoName    = "eleEt";
  cuts->at(0) = "hltPrescale";
  stack -> SetXaxisRange(0., 150.);
  stack -> SetXaxisTitle("ele Et (GeV)");
  stack -> Draw(variableNames, histoName, drawMode, lumi, step, 200, false, cuts, false);

  variableNames.at(0) = "ele.Et()";
  histoName    = "eleEt_cumulative";
  cuts->at(0) = "hltPrescale";
  stack -> SetXaxisRange(0., 150.);
  stack -> SetXaxisTitle("ele Et (GeV)");
  stack -> Draw(variableNames, histoName, drawMode, lumi, step, 200, false, cuts, true);

  //==============
  //==== hMt =====
  //==============
  variableNames.at(0) = "eleMet_mt";
  histoName    = "mT";
  cuts->at(0) = "hltPrescale";
  stack -> SetXaxisRange(0., 400.);
  stack -> SetXaxisTitle("M_{T} (GeV/c^{2})");
  stack -> Draw(variableNames, histoName, drawMode, lumi, step, 200, false, cuts, false);

  variableNames.at(0) = "eleMet_mt";
  histoName    = "mT_cumulative";
  cuts->at(0) = "hltPrescale";
  stack -> SetXaxisRange(0., 1500.);
  stack -> SetXaxisTitle("M_{T} (GeV/c^{2})");
  stack -> Draw(variableNames, histoName, drawMode, lumi, step, 200, false, cuts, true);

  variableNames.at(0) = "eleMet_mt";
  histoName    = "mT_cumulative_noReweight";
  cuts->at(0) = "";
  stack -> SetXaxisRange(0., 1500.);
  stack -> SetXaxisTitle("M_{T} (GeV/c^{2})");
  stack -> Draw(variableNames, histoName, drawMode, lumi, step, 200, false, cuts, true);
  
  // //========================
  // //==== hMt fake rate =====
  // //========================
  // variableNames.at(0) = "sqrt( 2. * pho.pt() * met.pt() * ( 1 - cos(eleMet_Dphi) ) )";
  // histoName    = "mT";
  // cuts->at(0) = "hltPrescale";
  // stack -> SetXaxisRange(0., 1500.);
  // stack -> SetXaxisTitle("M_{T} (GeV/c^{2})");
  // stack -> Draw(variableNames, histoName, drawMode, lumi, step, 200, true, cuts, false);

  // //==========================
  // //==== Ele Et fake rate ====  
  // //==========================
  // variableNames.at(0) = "ele.Et()";
  // histoName    = "eleEt";
  // cuts->at(0) = "hltPrescale";
  // stack -> SetXaxisRange(0., 150.);
  // stack -> SetXaxisTitle("ele Et (GeV)");
  // stack -> Draw(variableNames, histoName, drawMode, lumi, step, 200, false, cuts, false);

}
Ejemplo n.º 7
0
int main(int argc, char *argv[])
{
	QApplication a(argc, argv);

	// Open the log file and install our handler.
	QString logPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/Revive/";
	if (QDir().mkpath(logPath)) {
		g_LogFile = new QFile(logPath + "ReviveOverlay.txt");
		g_LogFile->open(QIODevice::WriteOnly | QIODevice::Truncate);
	}
	qInstallMessageHandler(myMessageOutput);

	// Handle command-line arguments
	if (a.arguments().contains("-manifest")) {
		// Only initialize the manifest
		vr::EVRInitError err = vr::VRInitError_None;
		vr::VR_Init( &err, vr::VRApplication_Utility );

		if ( err != vr::VRInitError_None )
			return -1;

		QString filePath = QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + "/app.vrmanifest");
		vr::VRApplications()->AddApplicationManifest(qPrintable(filePath));
		vr::VRApplications()->SetApplicationAutoLaunch(CReviveManifestController::AppKey, true);
		vr::VR_Shutdown();
		return 0;
	}

	// Check if we need to copy over input files
	QString inputPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/Revive/Input/";
	if (!QDir().exists(inputPath) && QDir().mkpath(inputPath))
	{
		QDir inputDir(QCoreApplication::applicationDirPath() + "/Input");
		if (inputDir.exists())
		{
			QStringList names = inputDir.entryList(QStringList("*.json"));
			QStringList files;
			for (QString file : names)
				files.append(inputDir.path() + "/" + file);
			WindowsServices::CopyFiles(files, inputPath, names);
		}
	}

	if (COpenVROverlayController::SharedInstance()->Init())
	{
		// If the dashboard was successfully created keep running in the background
		a.setQuitOnLastWindowClosed(false);
	}

	if (!CTrayIconController::SharedInstance()->Init())
		qDebug("Failed to initialize the tray icon");

	if (!CReviveManifestController::SharedInstance()->Init())
		qDebug("Failed to initialize the revive manifest");

	// Create a QML engine.
	QQmlEngine qmlEngine;
	qmlEngine.rootContext()->setContextProperty("Revive", CReviveManifestController::SharedInstance());
	qmlEngine.rootContext()->setContextProperty("OpenVR", COpenVROverlayController::SharedInstance());

	QQmlComponent qmlComponent( &qmlEngine, QUrl("qrc:/Overlay.qml"));
	if (qmlComponent.isError())
	{
		qDebug(qUtf8Printable(qmlComponent.errorString()));
		return -1;
	}

	QObject *rootObject = qmlComponent.create();
	QQuickItem *rootItem = qobject_cast<QQuickItem*>( rootObject );

	COpenVROverlayController::SharedInstance()->SetQuickItem( rootItem );

	win_sparkle_set_appcast_url("https://raw.githubusercontent.com/LibreVR/Revive/master/appcast.xml");
	win_sparkle_set_can_shutdown_callback([]() { return (BOOL)!QApplication::startingUp(); });
	win_sparkle_set_shutdown_request_callback([]() { CTrayIconController::SharedInstance()->quit(); });
	win_sparkle_init();
	QObject::connect(&a, &QApplication::aboutToQuit, win_sparkle_cleanup);
	return a.exec();
}