Exemple #1
0
void c_the_program::startup_data_dir() {
	bool found=false;
	try
	{
		namespace b_fs = boost::filesystem;
		// find path to my main data dir (to my data "in share").
		// e.g. /home/rafalcode/work/galaxy42/    - because it contains:
		//      /home/rafalcode/work/galaxy42/share/locale/en/LC_MESSAGES/galaxy42_main.mo

		// we could normalize the path... but this could trigger more problems maybe with encoding of string.
		auto dir_normalize = [](std::string path) -> std::string {
			return path; // nothing for now. TODO (would be nicer to not display "//home/.." in this tests below
		};

		b_fs::path cwd_full_boost( b_fs::current_path() );
		string cwd_full = dir_normalize( b_fs::absolute( cwd_full_boost ) .string() );
		// string cwd_full = b_fs::lexically_norma( b_fs::absolute( cwd_full_boost ) ).string();

		b_fs::path selfpath = "";
		// += cwd_full_boost;
		// selfpath += "/";
		selfpath += argt_exec; // hmm, what? --rafal
		b_fs::path selfdir_boost = selfpath.remove_filename();
		string selfdir = dir_normalize( b_fs::absolute( selfdir_boost ) .string() );

//		cerr << "Start... [" << cwd_full << "] (cwd) " << endl;
//		cerr << "Start... [" << selfdir << "] (exec) " << endl;

		vector<string> data_dir_possible;
		data_dir_possible.push_back(cwd_full);
		data_dir_possible.push_back(selfdir);

		#if defined(__MACH__)
			// TODO when macosx .dmg fully works (when Gitian on macosx works)
		#elif defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER)
			// data files should be next to .exe
		#else
			data_dir_possible.push_back("/usr");
			data_dir_possible.push_back("/usr/local");
			data_dir_possible.push_back("/usr/opt");
		#endif

		for (auto && dir : data_dir_possible) {
			string testname = dir;
			testname += "/share/locale/en/LC_MESSAGES/galaxy42_main.mo";
			_fact( "Test: [" << testname << "]... " << std::flush );
			ifstream filetest( testname.c_str() );
			if (filetest.good()) {
				m_install_dir_base = dir;
				found=true;
				_fact(" OK! " );
				break;
			} else _fact( "" );
		}
	} catch(std::exception & ex) {
			_erro( "Error while looking for data directory ("<<ex.what()<<")" << std::endl );
	}

	if (!found) _fact( "Can not find language data files." );

	_fact( "Data: [" << m_install_dir_base << "]" );
	m_install_dir_share_locale = m_install_dir_base + "/share/locale";
	_fact( "Lang: [" << m_install_dir_share_locale << "]" );
}
Exemple #2
0
int main() {
  struct timeval start, stop;
  double total;

  gettimeofday(&start, 0);
  filetest();
  gettimeofday(&stop, 0);

  total = stop.tv_sec - start.tv_sec;
  if (stop.tv_usec - start.tv_usec < 0) total++;
  total *= 1000*1000;
  total += stop.tv_usec - start.tv_usec;
  total /= (NUM_ITER);
  printf("access, open, creat, close, close %10f ms\n", total);

  gettimeofday(&start, 0);
  filetest2();
  gettimeofday(&stop, 0);

  total = stop.tv_sec - start.tv_sec;
  if (stop.tv_usec - start.tv_usec < 0) total++;
  total *= 1000*1000;
  total += stop.tv_usec - start.tv_usec;
  total /= (NUM_ITER);
  printf("access %10f ms\n", total);

  gettimeofday(&start, 0);
  filetest3();
  gettimeofday(&stop, 0);

  total = stop.tv_sec - start.tv_sec;
  if (stop.tv_usec - start.tv_usec < 0) total++;
  total *= 1000*1000;
  total += stop.tv_usec - start.tv_usec;
  total /= (NUM_ITER);
  printf("open, close %10f ms\n", total);

  gettimeofday(&start, 0);
  filetest();
  gettimeofday(&stop, 0);
  total = stop.tv_sec - start.tv_sec;
  if (stop.tv_usec - start.tv_usec < 0) total++;
  total *= 1000*1000;
  total += stop.tv_usec - start.tv_usec;
  total /= (NUM_ITER);
  printf("access, open, creat, close, close %10f ms\n", total);

  gettimeofday(&start, 0);
  filetest2();
  gettimeofday(&stop, 0);
  total = stop.tv_sec - start.tv_sec;
  if (stop.tv_usec - start.tv_usec < 0) total++;
  total *= 1000*1000;
  total += stop.tv_usec - start.tv_usec;
  total /= (NUM_ITER);
  printf("access %10f ms\n", total);

  gettimeofday(&start, 0);
  filetest3();
  gettimeofday(&stop, 0);
  total = stop.tv_sec - start.tv_sec;
  if (stop.tv_usec - start.tv_usec < 0) total++;
  total *= 1000*1000;
  total += stop.tv_usec - start.tv_usec;
  total /= (NUM_ITER);
  printf("open, close %10f ms\n", total);
return 0;
}
RenderTask_sV* RenderingDialog::buildTask()
{
    if (!slotValidate()) {
        return NULL;
    }
    slotSaveSettings();

    ProjectPreferences_sV *prefs = m_project->preferences();

    const QString imagesOutputDir = ui->imagesOutputDir->text();
    const QString imagesFilenamePattern = ui->imagesFilenamePattern->text();

    RenderTask_sV *task = new RenderTask_sV(m_project);
    task->renderPreferences().setFps(prefs->renderFPS());
    task->renderPreferences().size = prefs->renderFrameSize();
    task->renderPreferences().interpolation = prefs->renderInterpolationType();
    task->renderPreferences().motionblur = prefs->renderMotionblurType();


    if (ui->radioImages->isChecked()) {
        ImagesRenderTarget_sV *renderTarget = new ImagesRenderTarget_sV(task);
        renderTarget->setFilenamePattern(imagesFilenamePattern);
        renderTarget->setTargetDir(imagesOutputDir);
        task->setRenderTarget(renderTarget);
    } else if (ui->radioVideo->isChecked()) {
#ifdef USE_FFMPEG
#if 0
        newVideoRenderTarget *renderTarget = new newVideoRenderTarget(task);
#else
        exportVideoRenderTarget *renderTarget = new exportVideoRenderTarget(task);
#endif
        const bool use_qt = ui->use_qt->isChecked();
        if (!use_qt) {
            qDebug() << "using classical FFMPEG";
            renderTarget->setQT(0);
        }
#else
#warning "should not use this"
        VideoRenderTarget_sV *renderTarget = new VideoRenderTarget_sV(task);
#endif
        // check if file exist
        QFile filetest(ui->videoOutputFile->text());
        if (filetest.exists()) {
            int r = QMessageBox::warning(this, tr("slowmoUI"),
                tr("The file already exist.\n"
                "Do you want to overwrite it ?"),
                QMessageBox::Yes | QMessageBox::No);
            if (r == QMessageBox::Yes) {
            filetest.remove();
            } else {
            //TODO:  maybe should delete task ?
            return 0;
            }
        }
        renderTarget->setTargetFile(ui->videoOutputFile->text());
        renderTarget->setVcodec(ui->vcodec->text());
        task->setRenderTarget(renderTarget);
    } else {
        qDebug() << "Render target is neither images nor video. Not implemented?";
        Q_ASSERT(false);
    }

    if (ui->radioTagSection->isChecked()) {
        bool b;
        qreal start = ui->cbStartTag->itemData(ui->cbStartTag->currentIndex()).toFloat(&b);
        Q_ASSERT(b);
        qreal end = ui->cbEndTag->itemData(ui->cbEndTag->currentIndex()).toFloat(&b);
        Q_ASSERT(b);
        qDebug() << QString("Rendering tag section from %1 (%2) to %3 (%4)")
                    .arg(ui->cbStartTag->currentText())
                    .arg(start).arg(ui->cbEndTag->currentText()).arg(end);
        Q_ASSERT(start <= end);
        task->setTimeRange(start, end);
    } else if (ui->radioSection->isChecked()) {
        qDebug() << QString("Rendering time section from %1 to %3")
                    .arg(ui->cbStartTag->currentText())
                    .arg(ui->cbEndTag->currentText());
        task->setTimeRange(ui->timeStart->text(), ui->timeEnd->text());
    }

    QString mode;
    if (ui->radioFullProject->isChecked()) {
        mode = "full";
    } else if (ui->radioSection->isChecked()) {
        mode = "time";
        m_project->preferences()->renderStartTime() = ui->timeStart->text();
        m_project->preferences()->renderEndTime() = ui->timeEnd->text();
    } else if (ui->radioTagSection->isChecked()) {
        mode = "tags";
        m_project->preferences()->renderStartTag() = ui->cbStartTag->currentText();
        m_project->preferences()->renderEndTag() = ui->cbEndTag->currentText();
    } else {
        qDebug() << "No section mode selected?";
        Q_ASSERT(false);
    }

    // set optical flow parameters
    QSettings settings;
    QString flow_method = settings.value("preferences/flowMethod", "OpenCV-CPU").toString();
    if (flow_method == "V3D") {
        AbstractFlowSource_sV *flow_algo = m_project->flowSource();
        flow_algo->setLambda(prefs->flowV3DLambda());
    }
    else if (flow_method == "OpenCV-CPU" || flow_method == "OpenCV-OCL") {
        int algo_index = ui->opticalFlowAlgo->currentIndex();
        qDebug() << "algo index is " << algo_index;
        FlowSourceOpenCV_sV *flow_algo = (FlowSourceOpenCV_sV *)m_project->flowSource();

        switch (algo_index) {
            case 0:
                flow_algo->setupOpticalFlow(
                    ui->FarnLevels->value(),
                    ui->FarnWin->value(),
                    ui->FarnPoly->value(),
                    ui->FarnPyr->value(),
                    ui->FarnPolyN->value()
                );
                break;

            case 1:
                flow_algo->setupTVL1(
                    ui->TVLtau->value(),
                    ui->TVLlambda->value(),
                    ui->TVLnscales->value(),
                    ui->TVLwarps->value(),
                    ui->TVLiterations->value(),
                    ui->TVLepsilon->value()
                );
                break;

            default:
                qDebug() << "no algo defined";
        }
    }
    else {
        throw Error_sV("Unsupported Flow method");
    }
    return task;
}