Пример #1
0
void outputPath(int **kay, int i, int j)
{// Actual code to output i to j path.
   if (i == j) return;
   if (kay[i][j] == 0) cout << j << ' ';
   else {outputPath(kay, i, kay[i][j]);
         outputPath(kay, kay[i][j], j);}
}
Пример #2
0
//--------------------------------------------------------------------------------------------------
// MAIN
int main(int argc, char* argv[])
{
    // Validate arguments
    if (argc != 2)
    {
        std::cout << "Usage: " << argv[0] << " OutputDirectory" << std::endl;
        return -1;
    }

    std::string outputPath(argv[1]);


    // Init simulator
    std::cout << "Initializing simulator..." << std::endl;
    const Vec3d volumeMin(-3,   0, -1);
    const Vec3d volumeMax( 3,   3,  1);
    const double mass = 1.0;
    const double restDensity = 998.23;
    const double h = 0.2;
    const double k = 100.0;
    const double dt = 0.001;
    BasicSPH sph(volumeMin, volumeMax, mass, restDensity, h, k, dt);
    sph.enableAdaptiveTimeStep();

    // Init particles
    std::cout << "Initializing particles" << std::endl;
    Vec3d boxMin(-3, 0, -1);
    Vec3d boxMax(-1, 2,  1);
    initParticlesBox(boxMin, boxMax, 0.1, sph.particles());

    // Output first frame (initial frames)
    const std::string filePrefix("particles_");
    SPHParticleHoudiniIO::outputParticles(sph.particles(), outputPath, filePrefix, 1);

    // Run simulation and output a frame every 1/24 second
    std::cout << "Running simulation!" << std::endl;
    const double frameTime = 1.0/24.0;
    const double totalSimulationTime = 10.0;
    double time = 0.0;
    int currentFrame = 2;
    while (time < totalSimulationTime)
    {
        std::cout << "Simulating frame " << currentFrame << " (" << (frameTime+time) << "s)";
        std::cout << std::endl;

        // Run simulation
        sph.run(frameTime);

        // Output particles
        SPHParticleHoudiniIO::outputParticles(sph.particles(), outputPath, filePrefix, currentFrame);

        // Update simulation time
        time += frameTime;
        ++currentFrame;
    }

    std::cout << "Done!" << std::endl;

    return 0;
}
Пример #3
0
int main(int argc, char *argv[])
{	
	std::string filenameImage("small.png");
	double errorThreshold = 10.;
	int channel = 0;
	double gamma = 1.0;

	std::string histogramsTraining("training/training.dat");
	std::string outputPath("");


	// initialize LPIP detector
	LPIPDetector detector(filenameImage, channel, errorThreshold, 3, gamma);
	std::cout << "Detecting LISOs in the image..." << std::endl;
	detector.detect(outputPath);
	std::vector<LISO> lisoSet = detector.getLisoSet();
		
	// save LISO map 
	cv::Mat1f lisoMap = detector.getLisoMap();
	std::stringstream path1;
	path1 << outputPath << "liso_map.png";
	std::cout << "Save LISO map to " << path1.str() << std::endl;
	imwrite(path1.str(), lisoMap*255);

	// compute features and save histograms as images
	Trainer trainer;
	trainer.computeFeatures(lisoSet, lisoMap);
	std::cout << "Computing RQ Histogram..." << std::endl;
	Classifier classifier(histogramsTraining);
	classifier.createHistRQ(100, 50, lisoSet, false, "RQ_histogram");
	classifier.createHistRQ(100, 50, lisoSet, true, "RQ_histogram_weighted");

	
	return 0;
}
Пример #4
0
/*!
  Can be used to set the format for the destination directory, along with the path.

  Example format: ../myPhotos/<yyyy>/<MM>/<yyyy-MM-dd>*

  A star is being read as "anything goes" and can be used to import into some
  preexisting, named folders like "2014-01-27 Pics from today" with the following
  format "<yyyy-MM-dd>*".

  Accepted date formatting strings are the same as for QDateTime class and have
  to be put between "<" and ">" (otherwise they will be treated as part of the
  path). Spdr understands tags for date as well as for time.
 */
bool SpdrImport::setOutputPath(const QString &newOutputPath, bool checkIfExists)
{
    Q_UNUSED(checkIfExists);
    Q_D(SpdrImport);

    if (newOutputPath != outputPath()) {
        if (d->checkFormat(newOutputPath)) {
            SpdrBase::setOutputPath(newOutputPath, false);
            return true;
        } else if (!outputPath().isEmpty()) {
            SpdrBase::setOutputPath(QString::null);
            return false;
        }
    }

    return false;
}
Пример #5
0
int main(int argc, char * argv[])
{
    QApplication app(argc, argv);

    QCommandLineParser commandLineParser;
    commandLineParser.addPositionalArgument(QStringLiteral("url"),
        QStringLiteral("The url to be loaded in the browser window."));
    commandLineParser.process(app);
    QStringList positionalArguments = commandLineParser.positionalArguments();

    QUrl url;
    QString year("2010"),month("3"),outputPath("/home/dyz/MLProjData");
    int day=22;
    if (positionalArguments.size() > 5) {
        showHelp(commandLineParser, QStringLiteral("Too many arguments."));
        return -1;
    } else if (positionalArguments.size() == 5) {
        url = QUrl::fromUserInput(positionalArguments.at(0));
        year = positionalArguments.at(1);
        month = positionalArguments.at(2);
        day = positionalArguments.at(3).toInt();
        outputPath = positionalArguments.at(4);
    }
    else
        url = QUrl("http://query.nytimes.com/search/sitesearch/#/crude+oil/from20100502to20100602/allresults/1/allauthors/relevance/business");

    if (!url.isValid()) {
        showHelp(commandLineParser, QString("%1 is not a valid url.").arg(positionalArguments.at(0)));
        return -1;
    }
    MainWindowCreator *pMainWindowCreator = new MainWindowCreator();
//    qDebug() << "helllo";
//    do {
//    MainWindow *mainWin = pMainWindowCreator->create(url,year,month,day,outputPath);
//    mainWin->show();
//    app.exec();
//    pMainWindowCreator->destroy();
//    qDebug() << year;
//    } while (1);

    QList<QString> monthhrefs, dayhrefs;
    QString currentURL;
    int urlLevel = 0;
    do {
        MainWindow *mainWin = pMainWindowCreator->create(url,year,month,day,outputPath,monthhrefs,dayhrefs,currentURL,urlLevel);
        mainWin->show();
        app.exec();
        pMainWindowCreator->destroy();
        qDebug() << "reloading";
        QEventLoop loop;
        QTimer::singleShot(1000, &loop, SLOT(quit()));
        loop.exec();
        qDebug() << monthhrefs.count() << dayhrefs.count();
        } while (0);
    return 0;
}
Пример #6
0
bool GFXD3D9Shader::_loadCompiledOutput( const Torque::Path &filePath, 
                                         const String &target, 
                                         GenericConstBufferLayout *bufferLayoutF, 
                                         GenericConstBufferLayout *bufferLayoutI,
                                         Vector<GFXShaderConstDesc> &samplerDescriptions )
{
   Torque::Path outputPath(filePath);
   outputPath.setExtension("csf");     // "C"ompiled "S"hader "F"ile (fancy!)

   FileStream f;
   if (!f.open(outputPath, Torque::FS::File::Read))
      return false;
   U32 fileTag;
   if (!f.read(&fileTag))
      return false;
   if (fileTag != smCompiledShaderTag)
      return false;
   if (!bufferLayoutF->read(&f))
      return false;
   if (!bufferLayoutI->read(&f))
      return false;
   U32 bufferSize;
   if (!f.read(&bufferSize))
      return false;
   U32 waterMark = FrameAllocator::getWaterMark();
   DWORD* buffer = static_cast<DWORD*>(FrameAllocator::alloc(bufferSize));
   if (!f.read(bufferSize, buffer))
      return false;

   // Read sampler descriptions.

   U32 samplerCount;
   f.read( &samplerCount );   

   for ( U32 i = 0; i < samplerCount; i++ )
   {
      GFXShaderConstDesc samplerDesc;
      f.read( &(samplerDesc.name) );
      f.read( (U32*)&(samplerDesc.constType) );
      f.read( &(samplerDesc.arraySize) );

      samplerDescriptions.push_back( samplerDesc );
   }

   f.close();

   HRESULT res;
   if (target.compare("ps_", 3) == 0)      
      res = mD3D9Device->CreatePixelShader(buffer, &mPixShader );
   else
      res = mD3D9Device->CreateVertexShader(buffer, &mVertShader );
   AssertFatal(SUCCEEDED(res), "Unable to load shader!");

   FrameAllocator::setWaterMark(waterMark);
   return SUCCEEDED(res);
}
Пример #7
0
void OutputPath(T **c, int **kay, T NoEdge,
                         int i, int j)
{// Output shortest path from i to j.
   if (c[i][j] == NoEdge) {
      cout << "There is no path from " << i << " to "
           << j << endl;
      return;}
   cout << "The path is" << endl;
   cout << i << ' ';
   outputPath(kay,i,j);
   cout << endl;
}
Пример #8
0
/*!
  */
QString CuiRendererManager::makeOutputDir(const SettingNodeBase& scene_settings)
    const noexcept
{
  const auto settings = castNode<SceneSettingNode>(&scene_settings);
  const auto scene_name = QString{settings->sceneName().data()};

  QString dir_name = outputPath() + "/" + scene_name + "_" + getCurrentTime();
  const bool result = QDir::current().mkpath(dir_name);
  if (!result)
    dir_name.clear();
  return dir_name;
}
Пример #9
0
int resynthesize(Options& opts) {
  readCoefOptions(opts);

  auto index = util::parse<unsigned>(opts.input);
  auto corpus = get_corpus(opts);
  assert(index < corpus.size());
  std::vector<PhonemeInstance> input = corpus.input(index);

  INFO("Input file: " << alphabet_test.file_data_of(input[0]).file);
  INFO("Total duration: " << get_total_duration(input));
  INFO("Original cost: " << concat_cost(input, crf, crf.lambda, input));

  std::vector<int> path;
  traverse_automaton<MinPathFindFunctions, CRF, 1>(input, crf, crf.lambda, &path);

  std::vector<PhonemeInstance> output = crf.alphabet().to_phonemes(path);

  SynthPrinter sp(crf.alphabet(), labels_all);
  if(opts.has_opt("verbose"))
    sp.print_synth(path, input);
  sp.print_textgrid(path, input, labels_synth, opts.text_grid);

  CRF::Stats stats;
  INFO("Resynth. cost: " << concat_cost(output, crf, crf.lambda, input, &stats));
  //INFO("Second best cost: " << costs[1]);
  auto baselineCost = concat_cost(output, baseline_crf, baseline_crf.lambda, input);
  INFO("Baseline cost: " << baselineCost);

  outputStats(crf.lambda, stats, opts);
  outputPath(opts, output, input);

  auto sws = SpeechWaveSynthesis(output, input, crf.alphabet());
  Wave outputSignal = sws.get_resynthesis(opts);

  outputSignal.write(opts.get_opt<std::string>("output", "resynth.wav"));

  auto sws2 = SpeechWaveSynthesis(input, input, alphabet_test);
  auto concatenation = sws2.get_concatenation();
  concatenation.write(opts.get_opt<std::string>("original", "original.wav"));

  if(opts.has_opt("verbose")) {
    Comparisons cmp;
    cmp.fill(concatenation, outputSignal);
    INFO("LogSpectrum = " << cmp.LogSpectrum);
    INFO("LogSpectrumCritical = " << cmp.LogSpectrumCritical);
    INFO("SegSNR = " << cmp.SegSNR);
    INFO("MFCC = " << cmp.MFCC);
    INFO("WSS = " << cmp.WSS);
    outputComparisons(opts, cmp, baselineCost);
  }
  return 0;
}
Пример #10
0
bool MachOLinkingContext::validateImpl(raw_ostream &diagnostics) {
    // TODO: if -arch not specified, look at arch of first .o file.

    if (_currentVersion && _outputMachOType != MH_DYLIB) {
        diagnostics << "error: -current_version can only be used with dylibs\n";
        return false;
    }

    if (_compatibilityVersion && _outputMachOType != MH_DYLIB) {
        diagnostics
                << "error: -compatibility_version can only be used with dylibs\n";
        return false;
    }

    if (_deadStrippableDylib && _outputMachOType != MH_DYLIB) {
        diagnostics
                << "error: -mark_dead_strippable_dylib can only be used with dylibs.\n";
        return false;
    }

    if (!_bundleLoader.empty() && outputMachOType() != MH_BUNDLE) {
        diagnostics
                << "error: -bundle_loader can only be used with Mach-O bundles\n";
        return false;
    }

    // If -exported_symbols_list used, all exported symbols must be defined.
    if (_exportMode == ExportMode::whiteList) {
        for (const auto &symbol : _exportedSymbols)
            addInitialUndefinedSymbol(symbol.getKey());
    }

    // If -dead_strip, set up initial live symbols.
    if (deadStrip()) {
        // Entry point is live.
        if (outputTypeHasEntry())
            addDeadStripRoot(entrySymbolName());
        // Lazy binding helper is live.
        if (needsStubsPass())
            addDeadStripRoot(binderSymbolName());
        // If using -exported_symbols_list, make all exported symbols live.
        if (_exportMode == ExportMode::whiteList) {
            setGlobalsAreDeadStripRoots(false);
            for (const auto &symbol : _exportedSymbols)
                addDeadStripRoot(symbol.getKey());
        }
    }

    addOutputFileDependency(outputPath());

    return true;
}
Пример #11
0
TestResult::EOutcome MailExchangeRecordWriteBinaryTest1(FileComparisonTest& test)
{
    boost::filesystem::path outputPath(test.environment().getTestOutputDirectory() / "MailExchangeRecordWriteBinaryTest1.bin");
    std::ofstream stream(outputPath.c_str(), std::ios::binary);

    Ishiko::DNS::MailExchangeRecord mailExchangeRecord("example.org.", 86400, 20, "mx.example.org");
    mailExchangeRecord.writeBinary(stream);

    test.setOutputFilePath(outputPath);
    test.setReferenceFilePath(test.environment().getReferenceDataDirectory() / "MailExchangeRecordWriteBinaryTest1.bin");

    return TestResult::ePassed;
}
Пример #12
0
TestResult::EOutcome TTLWriteBinaryTest1(FileComparisonTest& test)
{
    boost::filesystem::path outputPath(test.environment().getTestOutputDirectory() / "TTLWriteBinaryTest1.bin");
    std::ofstream stream(outputPath.c_str(), std::ios::binary);

    Ishiko::DNS::TTL ttl(5);
    ttl.writeBinary(stream);

    test.setOutputFilePath(outputPath);
    test.setReferenceFilePath(test.environment().getReferenceDataDirectory() / "TTLWriteBinaryTest1.bin");

    return TestResult::ePassed;
}
Пример #13
0
bool EnsureFileDirectoryExists( wxFileName*     aTargetFullFileName,
                                const wxString& aBaseFilename,
                                REPORTER*       aReporter )
{
    wxString msg;
    wxString baseFilePath = wxFileName( aBaseFilename ).GetPath();

    // make aTargetFullFileName path, which is relative to aBaseFilename path (if it is not
    // already an absolute path) absolute:
    if( !aTargetFullFileName->MakeAbsolute( baseFilePath ) )
    {
        if( aReporter )
        {
            msg.Printf( _( "Cannot make path '%s' absolute with respect to '%s'." ),
                        GetChars( aTargetFullFileName->GetPath() ),
                        GetChars( baseFilePath ) );
            aReporter->Report( msg, REPORTER::RPT_ERROR );
        }

        return false;
    }

    // Ensure the path of aTargetFullFileName exists, and create it if needed:
    wxString outputPath( aTargetFullFileName->GetPath() );

    if( !wxFileName::DirExists( outputPath ) )
    {
        if( wxMkdir( outputPath ) )
        {
            if( aReporter )
            {
                msg.Printf( _( "Output directory '%s' created.\n" ), GetChars( outputPath ) );
                aReporter->Report( msg, REPORTER::RPT_INFO );
                return true;
            }
        }
        else
        {
            if( aReporter )
            {
                msg.Printf( _( "Cannot create output directory '%s'.\n" ),
                            GetChars( outputPath ) );
                aReporter->Report( msg, REPORTER::RPT_ERROR );
            }

            return false;
        }
    }

    return true;
}
Пример #14
0
bool EnsureOutputDirectory( wxFileName*     aOutputDir,
                            const wxString& aBoardFilename,
                            REPORTER*       aReporter )
{
    wxString msg;
    wxString boardFilePath = wxFileName( aBoardFilename ).GetPath();

    if( !aOutputDir->MakeAbsolute( boardFilePath ) )
    {
        if( aReporter )
        {
            msg.Printf( _( "*** Error: cannot make path <%s> absolute with respect to <%s>! ***" ),
                        GetChars( aOutputDir->GetPath() ),
                        GetChars( boardFilePath ) );
            aReporter->Report( msg );
        }

        return false;
    }

    wxString outputPath( aOutputDir->GetPath() );

    if( !wxFileName::DirExists( outputPath ) )
    {
        if( wxMkdir( outputPath ) )
        {
            if( aReporter )
            {
                msg.Printf( _( "Output directory <%s> created.\n" ), GetChars( outputPath ) );
                aReporter->Report( msg );
                return true;
            }
        }
        else
        {
            if( aReporter )
            {
                msg.Printf( _( "*** Error: cannot create output directory <%s>! ***\n" ),
                            GetChars( outputPath ) );
                aReporter->Report( msg );
            }

            return false;
        }
    }

    return true;
}
Пример #15
0
int baseline(const Options& opts) {
  readCoefOptions(opts);

  auto index = opts.get_opt<unsigned>("input", 0);
  auto corpus = get_corpus(opts);
  std::vector<PhonemeInstance> input = corpus.input(index);

  INFO("Input file: " << alphabet_test.file_data_of(input[0]).file);
  INFO("Total duration: " << get_total_duration(input));

  std::vector<int> path;
  traverse_automaton<MinPathFindFunctions>(input, baseline_crf,
                                           baseline_crf.lambda, &path);

  std::vector<PhonemeInstance> output = baseline_crf.alphabet().to_phonemes(path);

  Wave outputSignal = SpeechWaveSynthesis(output, input, baseline_crf.alphabet())
    .get_resynthesis_td();
  outputSignal.write(opts.get_opt<std::string>("output", "baseline.wav"));

  auto sws2 = SpeechWaveSynthesis(input, input, alphabet_test);
  auto concatenation = sws2.get_concatenation();
  concatenation.write(opts.get_opt<std::string>("original", "original.wav"));

  CRF::Stats stats;
  INFO("Baseline cost in original: " << concat_cost(output, crf, crf.lambda, input, &stats));
  auto baselineCost = concat_cost(output, baseline_crf, baseline_crf.lambda, input);
  INFO("Baseline cost:" << baselineCost);

  outputStats(crf.lambda, stats, opts);
  outputPath(opts, output, input);

  if(opts.has_opt("verbose")) {
    auto sws = SpeechWaveSynthesis(input, input, alphabet_test);
    auto concatenation = sws.get_concatenation();
    Comparisons cmp;
    cmp.fill(concatenation, outputSignal);
    INFO("LogSpectrum = " << cmp.LogSpectrum);
    INFO("LogSpectrumCritical = " << cmp.LogSpectrumCritical);
    INFO("SegSNR = " << cmp.SegSNR);
    INFO("MFCC = " << cmp.MFCC);
    INFO("WSS = " << cmp.WSS);
    outputComparisons(opts, cmp, baselineCost);
  }

  return 0;
}
Пример #16
0
Engine::Engine(QObject *parent)
    :   QObject(parent)
    ,   m_mode(QAudio::AudioInput)
    ,   m_state(QAudio::StoppedState)
    ,   m_generateTone(false)
    ,   m_file(0)
    ,   m_analysisFile(0)
    ,   m_availableAudioInputDevices
            (QAudioDeviceInfo::availableDevices(QAudio::AudioInput))
    ,   m_audioInputDevice(QAudioDeviceInfo::defaultInputDevice())
    ,   m_audioInput(0)
    ,   m_audioInputIODevice(0)
    ,   m_recordPosition(0)
    ,   m_availableAudioOutputDevices
            (QAudioDeviceInfo::availableDevices(QAudio::AudioOutput))
    ,   m_audioOutputDevice(QAudioDeviceInfo::defaultOutputDevice())
    ,   m_audioOutput(0)
    ,   m_playPosition(0)
    ,   m_bufferPosition(0)
    ,   m_bufferLength(0)
    ,   m_dataLength(0)
    ,   m_levelBufferLength(0)
    ,   m_rmsLevel(0.0)
    ,   m_peakLevel(0.0)
    ,   m_spectrumBufferLength(0)
    ,   m_spectrumAnalyser()
    ,   m_spectrumPosition(0)
    ,   m_count(0)
{
    qRegisterMetaType<FrequencySpectrum>("FrequencySpectrum");
    qRegisterMetaType<WindowFunction>("WindowFunction");
    CHECKED_CONNECT(&m_spectrumAnalyser,
                    SIGNAL(spectrumChanged(FrequencySpectrum)),
                    this,
                    SLOT(spectrumChanged(FrequencySpectrum)));

    initialize();

#ifdef DUMP_DATA
    createOutputDir();
#endif

#ifdef DUMP_SPECTRUM
    m_spectrumAnalyser.setOutputPath(outputPath());
#endif
}
Пример #17
0
void CameraTab::updateImageInfo()
{
	CleanupSettingsModel *model = CleanupSettingsModel::instance();
	CleanupParameters *params = model->getCurrentParameters();

	TDimension outRes(0, 0);
	TPointD outDpi;

	params->getOutputImageInfo(outRes, outDpi.x, outDpi.y);
	setImageInfo(outRes.lx, outRes.ly, outDpi.x, outDpi.y);

	TXshSimpleLevel *sl;
	TFrameId fid;
	model->getCleanupFrame(sl, fid);

	ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
	TFilePath outputPath(sl ? scene->decodeFilePath(model->getOutputPath(sl, params)) : TFilePath());

	setImageInfo(outputPath);
}
Пример #18
0
/*!
  Performs the import operation. That is to say, it takes all files from input
  path and puts them into output path according to formatting tags that have
  been used.

  For example, if you want to copy your newly taken photographs onto your local
  foto archive/ gallery, you can use this output path:

  /some/path/<yyyy>/<MM>/<yyyy-MM-dd>*

  This will copy the files into a well-organized folder structure. Later, when
  you take more pictures, you can run import() again, and the archive will be
  updated.

  \sa setOutputPath
 */
bool SpdrImport::import() const
{
    Q_D(const SpdrImport);

    bool result = true;

    if (inputPath().isEmpty() || outputPath().isEmpty()) {
        emit finished(false);
        return false;
    }

    result = d->importDirectory(inputPath());

    if (result) {
        log(tr("DONE: Directory import successful"), Spdr::MildLogging);
    }

    emit finished(result);
    return result;
}
Пример #19
0
bool GFXD3D9Shader::_saveCompiledOutput( const Torque::Path &filePath, 
                                         LPD3DXBUFFER buffer, 
                                         GenericConstBufferLayout *bufferLayoutF, 
                                         GenericConstBufferLayout *bufferLayoutI,
                                         Vector<GFXShaderConstDesc> &samplerDescriptions )
{
   Torque::Path outputPath(filePath);
   outputPath.setExtension("csf");     // "C"ompiled "S"hader "F"ile (fancy!)

   FileStream f;
   if (!f.open(outputPath, Torque::FS::File::Write))
      return false;
   if (!f.write(smCompiledShaderTag))
      return false;
   // We could reverse engineer the structure in the compiled output, but this
   // is a bit easier because we can just read it into the struct that we want.
   if (!bufferLayoutF->write(&f))
      return false;
   if (!bufferLayoutI->write(&f))
      return false;
   U32 bufferSize = buffer->GetBufferSize();
   if (!f.write(bufferSize))
      return false;
   if (!f.write(bufferSize, buffer->GetBufferPointer()))
      return false;

   // Write out sampler descriptions.

   f.write( samplerDescriptions.size() );   

   for ( U32 i = 0; i < samplerDescriptions.size(); i++ )
   {
      f.write( samplerDescriptions[i].name );
      f.write( (U32)(samplerDescriptions[i].constType) );
      f.write( samplerDescriptions[i].arraySize );
   }

   f.close();

   return true;
}
Пример #20
0
void MainWindow::on_openFileButton_clicked() {
    QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), QString(),
            tr("Media Files (*.avi *.mp4 *.mp3 *.divx *.mov *.flac *.wmv *.ogg *.mkv)"));

    if (!fileName.isEmpty()) {

        QFile file(fileName);

        if (file.exists()) {

            ui->filePath->setText(fileName);

            QFileInfo finfo(fileName);
            QDir dir = finfo.absoluteDir();

            // If output field is empty, with replace the name of the video with "out"
            QString outputPath(dir.absolutePath().append("/").append(finfo.baseName()).append(".out.").append(finfo.suffix()));
            ui->filePathOut->setText(outputPath);
        }
    }
}
QString JobFusionVideoMaker::format()
{
	return formatFromExtension( QFileInfo( outputPath() ).suffix() );
}
Пример #22
0
std::string PECOFFLinkingContext::getOutputImportLibraryPath() const {
  if (!_implib.empty())
    return _implib;
  return replaceExtension(outputPath(), ".lib");
}
Пример #23
0
bool ReflectionParser::ProcessFile(std::string const & fileName, bool InProcessModule)
{
  if (!InProcessModule && !m_sourceCache->RequestGenerate(fileName))
    return true;

  Clear();

  m_currentFile = fileName;
  m_index = clang_createIndex(true, false);

  std::vector<const char *> arguments;

  for (auto &argument : m_options.arguments)
  {
    // unescape flags
    boost::algorithm::replace_all(argument, "\\-", "-");

    arguments.emplace_back(argument.c_str());
  }

  m_translationUnit = clang_createTranslationUnitFromSourceFile(
        m_index,
        fileName.c_str(),
        static_cast<int>(arguments.size()),
        arguments.data(),
        0,
        nullptr
        );

  auto cursor = clang_getTranslationUnitCursor(m_translationUnit);

  try
  {
    Namespace tempNamespace;
    buildClasses(cursor, tempNamespace);
    tempNamespace.clear();

    if (ContainsModule() && !InProcessModule)
    {
      if (m_classes.size() > 1)
      {
        EMIT_ERROR("You can't implement any other classes in one file with module class");
      }
      return false;
    }

    if (RequestGenerate())
    {
      std::string fileId = GetFileID(fileName);
      std::stringstream outCode;

      // includes
      outCode << "#include <memory>\n\n";
      outCode << "#include \"sc-memory/cpp/sc_memory.hpp\"\n\n\n";
      outCode << "#include \"sc-memory/cpp/sc_event.hpp\"\n\n\n";

      for (auto it = m_classes.begin(); it != m_classes.end(); ++it)
      {
        Class const * klass = *it;
        if (klass->ShouldGenerate())
        {
          klass->GenerateCode(fileId, outCode, this);
        }
      }

      /// write ScFileID definition
      outCode << "\n\n#undef ScFileID\n";
      outCode << "#define ScFileID " << fileId;

      // generate output file
      boost::filesystem::path outputPath(m_options.outputPath);
      outputPath /= boost::filesystem::path(GetOutputFileName(fileName));
      std::ofstream outputFile(outputPath.string());
      outputFile << outCode.str();
      outputFile << std::endl << std::endl;
      outputFile.close();
    }

    clang_disposeIndex(m_index);
    clang_disposeTranslationUnit(m_translationUnit);

  } catch (Exception e)
  {
    clang_disposeIndex(m_index);
    clang_disposeTranslationUnit(m_translationUnit);

    EMIT_ERROR(e.GetDescription());
  }


  return true;
}
Пример #24
0
std::string PECOFFLinkingContext::getPDBFilePath() const {
  assert(_debug);
  if (!_pdbFilePath.empty())
    return _pdbFilePath;
  return replaceExtension(outputPath(), ".pdb");
}
Пример #25
0
void MainWindow::startPatching()
{
    Q_D(MainWindow);

    d->bytes = 0;
    d->maxBytes = 0;
    d->files = 0;
    d->maxFiles = 0;

    d->progressBar->setMaximum(0);
    d->progressBar->setValue(0);
    d->detailsLbl->clear();

    d->state = MainWindowPrivate::Patching;
    updateWidgetsVisibility();

    QString romId;
    if (d->instLocSel->currentIndex() == d->instLocs.size()) {
        romId = QStringLiteral("data-slot-%1").arg(d->instLocLe->text());
    } else if (d->instLocSel->currentIndex() == d->instLocs.size() + 1) {
        romId = QStringLiteral("extsd-slot-%1").arg(d->instLocLe->text());
    } else {
        romId = d->instLocs[d->instLocSel->currentIndex()].id;
    }


    QStringList suffixes;
    suffixes << QStringLiteral(".tar.md5");
    suffixes << QStringLiteral(".tar.md5.gz");
    suffixes << QStringLiteral(".tar.md5.xz");
    suffixes << QStringLiteral(".zip");

    QFileInfo qFileInfo(d->fileName);
    QString suffix;
    QString outputName;
    bool isOdin = false;

    for (const QString &suffix : suffixes) {
        if (d->fileName.endsWith(suffix)) {
            // Input name: <parent path>/<base name>.<suffix>
            // Output name: <parent path>/<base name>_<rom id>.zip
            outputName = d->fileName.left(d->fileName.size() - suffix.size())
                    % QStringLiteral("_")
                    % romId
                    % QStringLiteral(".zip");
            isOdin = suffix.contains(QStringLiteral(".tar.md5"));
            break;
        }
    }
    if (outputName.isEmpty()) {
        outputName = qFileInfo.completeBaseName()
                % QStringLiteral("_")
                % romId
                % QStringLiteral(".")
                % qFileInfo.suffix();
    }

    QString inputPath(QDir::toNativeSeparators(qFileInfo.filePath()));
    QString outputPath(QDir::toNativeSeparators(
            qFileInfo.dir().filePath(outputName)));

    FileInfoPtr fileInfo = new mbp::FileInfo();
    fileInfo->setInputPath(inputPath.toUtf8().constData());
    fileInfo->setOutputPath(outputPath.toUtf8().constData());
    fileInfo->setDevice(d->device);
    fileInfo->setRomId(romId.toUtf8().constData());

    if (isOdin) {
        d->patcher = d->pc->createPatcher("OdinPatcher");
    } else {
        d->patcher = d->pc->createPatcher("MultiBootPatcher");
    }

    emit runThread(d->patcher, fileInfo);
}
Пример #26
0
int main ( int argc, char *argv[] )
{
	std::vector<std::string> args (argv, argv + argc);
	if ( args.size() == 1 )
	{
		PrintUsage (args[0]);
		return EXIT_FAILURE;
	}

	std::string animationFile;
	std::string outputPath ("model.glm");
	unsigned i;
	for ( i = 1; i < args.size(); i++ )
	{
		if ( args[i].compare ("-o") == 0 )
		{
			i++;
			if ( args.size() > i )
			{
				outputPath = args[i];

				continue;
			}
			else
			{
				PrintUsage (args[0]);

				return EXIT_FAILURE;
			}
		}
		else if ( args[i].compare ("-anim") == 0 )
		{
			i++;
			if ( args.size() > i )
			{
				animationFile = args[i];

				continue;
			}
			else
			{
				PrintUsage (args[0]);

				return EXIT_FAILURE;
			}
		}
	}

	std::unique_ptr<Skeleton> skeleton;
	std::string modelPath (args.back());

	std::cout << "Converting " << modelPath << " to GLM.\n";

	if ( !animationFile.empty() )
	{
		skeleton = LoadGLA (animationFile);
		if ( !skeleton )
		{
			return EXIT_FAILURE;
		}

		std::cout << "Using " << animationFile << " for skeleton.\n";
	}

	FbxManager *fbxManager = FbxManager::Create();
	FbxIOSettings *ios = FbxIOSettings::Create (fbxManager, IOSROOT);
	fbxManager->SetIOSettings (ios);

	FbxImporter *importer = FbxImporter::Create (fbxManager, "");

	if ( !importer->Initialize (modelPath.c_str(), -1, fbxManager->GetIOSettings()) )
	{
		std::cerr << "ERROR: Failed to import '" << modelPath << "': " << importer->GetStatus().GetErrorString() << ".\n";

		importer->Destroy();
		fbxManager->Destroy();

		return EXIT_FAILURE;
	}

	FbxScene *scene = FbxScene::Create (fbxManager, "model");
	importer->Import (scene);
	importer->Destroy();

	FbxNode *root = scene->GetRootNode();
	if ( root == nullptr )
	{
		std::cerr << "ERROR: The scene's root node could not be found.\n";

		fbxManager->Destroy();

		return EXIT_FAILURE;
	}

	std::vector<FbxNode *> modelRoots (GetLodRootModels (*root));

	if ( modelRoots.empty() )
	{
		std::cerr << "ERROR: No model LODs found.\n";

		fbxManager->Destroy();

		return EXIT_FAILURE;
	}

	std::sort (modelRoots.begin(), modelRoots.end(),
		[]( const FbxNode *a, const FbxNode *b ) { return std::strcmp (a->GetName(), b->GetName()) < 0; });

	if ( !MakeGLMFile (*scene, modelRoots, skeleton.get(), outputPath) )
	{
		std::cerr << "ERROR: Failed to create GLM file " << outputPath << ".\n";

		fbxManager->Destroy();

		return EXIT_FAILURE;
	}

	std::cout << "GLM file has been written to '" << outputPath << "'.\n";

	fbxManager->Destroy();

	return 0;
}
Пример #27
0
int main(int argc, const char * argv[])
{
    Timer timer;
    timer.start();

    FileSequenceImageGenerator generator(argv[2], "", "png", 90, 6550);

    //VideoFileImageGenerator generator(argv[2]);

    cv::Mat image;

    generator.init();

    // path al archivo de configuracion, path de salida
    std::string outputPath("");
    if (argc > 3)
    {
        outputPath = argv[3];
    }
    else
    {
        outputPath = "";
    }

    EKF extendedKalmanFilter(argv[1], outputPath.c_str());

    // para la primer imagen, se inicializa Kalman Filter
    // Se hace un sensado y se agregan todos los features que se detectan en la imagen.
    image = generator.getNextImage();

#ifdef DEBUG
    int stepCount = 0;
    std::cout << "~~~~~~~~~~~~ STEP 0 ~~~~~~~~~~~~" << std::endl;
#endif

    if (!image.empty())
    {
        extendedKalmanFilter.init(image);
    }
    else
    {
        std::cout << "No se puede iniciar Kalman Filter dado que no hay imagenes disponibles." << std::endl;
        return 0;
    }

#ifdef DEBUG
    std::cout << extendedKalmanFilter.state << std::endl;
#endif

#ifdef DEBUG_SHOW_3D_MAP
    boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer = create3DMapVisualizer(extendedKalmanFilter.state);
#endif

#ifdef DEBUG_SHOW_PLANAR_INFO
    double cameraPreviousPosition[3];

    cameraPreviousPosition[0] = state.position[0];
    cameraPreviousPosition[1] = state.position[1];
    cameraPreviousPosition[2] = state.position[2];
    // Se crean las ventanas y se muestran las posciones
    std::string windowName = "Informacion planar";
    cv::Size size(PLANAR_WINDOW_SIZE_X, PLANAR_WINDOW_SIZE_Y);

    cv::Mat cameraPositionImage(cv::Mat::zeros(size, CV_8UC3));
    cv::Mat cameraPositionEllipse(cv::Mat::zeros(size, CV_8UC3));
    cv::Mat featuresPositionImage(cv::Mat::zeros(size, CV_8UC3));
    cv::namedWindow(windowName);

    std::string windowNameActualImage = "Imagen actual";
    //cv::namedWindow(windowNameActualImage);

    drawPlanarInformation(state, covariance, cameraPreviousPosition, PLANAR_INFORMATION_XY, cameraPositionImage, featuresPositionImage, cameraPositionEllipse);

    cv::imshow(windowName, cv::Mat(cameraPositionImage + featuresPositionImage));
//    cv::imshow(windowNameActualImage, image);
    cv::waitKey(0);
#endif

    image = generator.getNextImage();

    while(!image.empty())
    {
#ifdef DEBUG
        std::cout << std::endl << std::endl;
        std::cout << "~~~~~~~~~~~~ STEP " << stepCount++ << " ~~~~~~~~~~~~" << std::endl;
#endif

        // para cada imagen recibida se hace un paso del EKF
        extendedKalmanFilter.step(image);

#ifdef DEBUG
        // mostramos el estado
        std::cout << extendedKalmanFilter.state << std::endl;
#endif

#ifdef DEBUG_SHOW_3D_MAP
        draw3DMap(extendedKalmanFilter.state, viewer);
        viewer->spinOnce(100);
#endif
#ifdef DEBUG_SHOW_PLANAR_INFO
        cv::Mat(cv::Mat::zeros(size, CV_8UC3)).copyTo(featuresPositionImage);
        cv::Mat(cv::Mat::zeros(size, CV_8UC3)).copyTo(cameraPositionEllipse);

        // Se muestra la posicion en 2 dimensiones.
        drawPlanarInformation(state, covariance, cameraPreviousPosition, PLANAR_INFORMATION_XY, cameraPositionImage, featuresPositionImage, cameraPositionEllipse);

        cv::imshow(windowName, cv::Mat(cameraPositionImage + featuresPositionImage + cameraPositionEllipse));
        cv::waitKey(1);
//        cv::imshow(windowNameActualImage, image);

        // Se actualiza la posicion anterior de la camara
        cameraPreviousPosition[0] = state.position[0];
        cameraPreviousPosition[1] = state.position[1];
        cameraPreviousPosition[2] = state.position[2];
#endif

#if defined(DEBUG_SHOW_IMAGES)
        // waitKey global para ir paso a paso o hacer todo de corrido
        cv::waitKey(1);
#endif

        image = generator.getNextImage();
    }

    std::cout << "Tiempo de ejecución total: "<< timer.getElapsedTimeInMilliSec() << " ms" << std::endl;
    timer.stop();

#if defined(DEBUG_SHOW_IMAGES)
    cv::destroyAllWindows();
#endif

    return 0;
}
Пример #28
0
/*!
  \internal

  Imports the file specified by \a filePath. File destination is acquired
  automatically based on output path.
  */
bool SpdrImportPrivate::importFile(const QString &filePath) const
{
    QString outputPath(getOutputFilePath(filePath));
    outputPath = substituteStarsInPath(outputPath);
    return performFileOperation(filePath, outputPath);
}