コード例 #1
0
RenderTask_sV* RenderingDialog::buildTask()
{
    if (slotValidate()) {
        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()) {
            VideoRenderTarget_sV *renderTarget = new VideoRenderTarget_sV(task);
            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);
        }
        return task;
    } else {
        return NULL;
    }
}
コード例 #2
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;
}