Exemplo n.º 1
0
void CreateFinalPtoTask::run()
{
    (*finalPtoUrl) = tmpDir;
    finalPtoUrl->setFileName(QString("final.pto"));

    QFile pto(finalPtoUrl->toLocalFile());

    if (pto.exists())
    {
        errString   = i18n("PTO file already created in the temporary directory.");
        successFlag = false;
        return;
    }

    if (!pto.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text))
    {
        errString   = i18n("PTO file cannot be created in the temporary directory.");
        successFlag = false;
        return;
    }

    ptoData.project.crop = crop;
    ptoData.createFile(finalPtoUrl->toLocalFile());

    successFlag = true;
    return;
}
Exemplo n.º 2
0
void Manager::resetPanoUrl()
{
    QFile pto(d->panoUrl.toLocalFile());

    if (pto.exists())
    {
        pto.remove();
    }

    d->panoUrl.clear();
}
Exemplo n.º 3
0
void Manager::resetPreviewPto()
{
    d->previewPtoData.clear();

    QFile pto(d->previewPtoUrl.toLocalFile());

    if (pto.exists())
    {
        pto.remove();
    }

    d->previewPtoUrl.clear();
}
Exemplo n.º 4
0
void Manager::resetViewAndCropOptimisePto()
{
    d->viewAndCropOptimisePtoData.clear();

    QFile pto(d->viewAndCropOptimisePtoUrl.toLocalFile());

    if (pto.exists())
    {
        pto.remove();
    }

    d->viewAndCropOptimisePtoUrl.clear();
}
Exemplo n.º 5
0
void Manager::resetAutoOptimisePto()
{
    d->autoOptimisePtoData.clear();

    QFile pto(d->autoOptimisePtoUrl.toLocalFile());

    if (pto.exists())
    {
        pto.remove();
    }

    d->autoOptimisePtoUrl.clear();
}
Exemplo n.º 6
0
void Manager::resetCpCleanPto()
{
    d->cpCleanPtoData.clear();

    QFile pto(d->cpCleanPtoUrl.toLocalFile());

    if (pto.exists())
    {
        pto.remove();
    }

    d->cpCleanPtoUrl.clear();
}
Exemplo n.º 7
0
 bool operator()(const pto&p1, const pto&p2) const{
 return cmp(pto(p1.x-r.x,p1.y-r.y),pto(p2.x-r.x,p2.y-r.y));
 }
Exemplo n.º 8
0
void CreatePtoTask::run(ThreadWeaver::JobPointer, ThreadWeaver::Thread*)
{
    ptoUrl = tmpDir.resolved(QUrl::fromLocalFile(QLatin1String("pano_base.pto")));

    QFile pto(ptoUrl.toLocalFile());

    if (pto.exists())
    {
        errString = i18n("PTO file already created in the temporary directory.");
        successFlag = false;
        return;
    }

    if (!pto.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text))
    {
        errString   = i18n("PTO file cannot be created in the temporary directory.");
        successFlag = false;
        return;
    }

    // 1. Project parameters
    PTOType panoBase(huginVersion);

    if (addGPlusMetadata)
    {
        panoBase.project.projection = PTOType::Project::EQUIRECTANGULAR;
    }
    else
    {
        panoBase.project.projection = PTOType::Project::CYLINDRICAL;
    }

    panoBase.project.fieldOfView = 0;
    panoBase.project.hdr         = false;

    switch (fileType)
    {
        case JPEG:
            panoBase.project.fileFormat.fileType = PTOType::Project::FileFormat::JPEG;
            panoBase.project.fileFormat.quality = 90;
            break;
        case TIFF:
            panoBase.project.fileFormat.fileType = PTOType::Project::FileFormat::TIFF_m;
            panoBase.project.fileFormat.compressionMethod = PTOType::Project::FileFormat::LZW;
            panoBase.project.fileFormat.savePositions = false;
            panoBase.project.fileFormat.cropped = false;
            break;
        case HDR:
            panoBase.project.hdr = true;
            // TODO HDR
            break;
    }

//  panoBase.project.bitDepth = PTOType::Project::FLOAT;
//  panoBase.project.crop.setLeft(X_left);
//  panoBase.project.crop.setRight(X_right);
//  panoBase.project.crop.setTop(X_top);
//  panoBase.project.crop.setBottom(X_bottom);
    panoBase.project.photometricReferenceId = 0;

    // 2. Images
    panoBase.images.reserve(inputFiles.size());
    panoBase.images.resize(inputFiles.size());
    int i = 0;

    for (i = 0; i < inputFiles.size(); ++i)
    {
        QUrl inputFile(inputFiles.at(i));
        QUrl preprocessedUrl(preProcessedMap->value(inputFile).preprocessedUrl);
        m_meta.load(preprocessedUrl.toLocalFile());
        QSize size = m_meta.getPixelSize();

        panoBase.images[i]                = PTOType::Image();
        panoBase.images[i].lensProjection = PTOType::Image::RECTILINEAR;
        panoBase.images[i].size           = size;

        if (i > 0)
        {
            // We suppose that the pictures are all taken with the same camera and lens
            panoBase.images[i].lensBarrelCoefficientA.referenceId = 0;
            panoBase.images[i].lensBarrelCoefficientB.referenceId = 0;
            panoBase.images[i].lensBarrelCoefficientC.referenceId = 0;
            panoBase.images[i].lensCenterOffsetX.referenceId = 0;
            panoBase.images[i].lensCenterOffsetY.referenceId = 0;
            panoBase.images[i].lensShearX.referenceId = 0;
            panoBase.images[i].lensShearY.referenceId = 0;
            panoBase.images[i].vignettingCorrectionI.referenceId = 0;
            panoBase.images[i].vignettingCorrectionJ.referenceId = 0;
            panoBase.images[i].vignettingCorrectionK.referenceId = 0;
            panoBase.images[i].vignettingCorrectionL.referenceId = 0;
            panoBase.images[i].vignettingOffsetX.referenceId = 0;
            panoBase.images[i].vignettingOffsetY.referenceId = 0;
        }
        else
        {
            panoBase.images[i].optimisationParameters.push_back(PTOType::Optimisation());
            panoBase.images[i].optimisationParameters.last().parameter = PTOType::Optimisation::LENSA;
            panoBase.images[i].optimisationParameters.push_back(PTOType::Optimisation());
            panoBase.images[i].optimisationParameters.last().parameter = PTOType::Optimisation::LENSB;
            panoBase.images[i].optimisationParameters.push_back(PTOType::Optimisation());
            panoBase.images[i].optimisationParameters.last().parameter = PTOType::Optimisation::LENSC;
            panoBase.images[i].optimisationParameters.push_back(PTOType::Optimisation());
            panoBase.images[i].optimisationParameters.last().parameter = PTOType::Optimisation::LENSD;
            panoBase.images[i].optimisationParameters.push_back(PTOType::Optimisation());
            panoBase.images[i].optimisationParameters.last().parameter = PTOType::Optimisation::LENSE;
            panoBase.images[i].optimisationParameters.push_back(PTOType::Optimisation());
            panoBase.images[i].optimisationParameters.last().parameter = PTOType::Optimisation::VA;
            panoBase.images[i].optimisationParameters.push_back(PTOType::Optimisation());
            panoBase.images[i].optimisationParameters.last().parameter = PTOType::Optimisation::VB;
            panoBase.images[i].optimisationParameters.push_back(PTOType::Optimisation());
            panoBase.images[i].optimisationParameters.last().parameter = PTOType::Optimisation::VC;
            panoBase.images[i].optimisationParameters.push_back(PTOType::Optimisation());
            panoBase.images[i].optimisationParameters.last().parameter = PTOType::Optimisation::VD;
            panoBase.images[i].optimisationParameters.push_back(PTOType::Optimisation());
            panoBase.images[i].optimisationParameters.last().parameter = PTOType::Optimisation::VX;
            panoBase.images[i].optimisationParameters.push_back(PTOType::Optimisation());
            panoBase.images[i].optimisationParameters.last().parameter = PTOType::Optimisation::VY;
        }

        panoBase.images[i].optimisationParameters.push_back(PTOType::Optimisation());
        panoBase.images[i].optimisationParameters.last().parameter =  PTOType::Optimisation::RA;
        panoBase.images[i].optimisationParameters.push_back(PTOType::Optimisation());
        panoBase.images[i].optimisationParameters.last().parameter =  PTOType::Optimisation::RB;
        panoBase.images[i].optimisationParameters.push_back(PTOType::Optimisation());
        panoBase.images[i].optimisationParameters.last().parameter =  PTOType::Optimisation::RC;
        panoBase.images[i].optimisationParameters.push_back(PTOType::Optimisation());
        panoBase.images[i].optimisationParameters.last().parameter =  PTOType::Optimisation::RD;
        panoBase.images[i].optimisationParameters.push_back(PTOType::Optimisation());
        panoBase.images[i].optimisationParameters.last().parameter =  PTOType::Optimisation::RE;
        panoBase.images[i].optimisationParameters.push_back(PTOType::Optimisation());
        panoBase.images[i].optimisationParameters.last().parameter =  PTOType::Optimisation::EXPOSURE;
        panoBase.images[i].optimisationParameters.push_back(PTOType::Optimisation());
        panoBase.images[i].optimisationParameters.last().parameter =  PTOType::Optimisation::WBR;
        panoBase.images[i].optimisationParameters.push_back(PTOType::Optimisation());
        panoBase.images[i].optimisationParameters.last().parameter =  PTOType::Optimisation::WBB;
        panoBase.images[i].optimisationParameters.push_back(PTOType::Optimisation());
        panoBase.images[i].optimisationParameters.last().parameter =  PTOType::Optimisation::LENSYAW;
        panoBase.images[i].optimisationParameters.push_back(PTOType::Optimisation());
        panoBase.images[i].optimisationParameters.last().parameter =  PTOType::Optimisation::LENSPITCH;
        panoBase.images[i].optimisationParameters.push_back(PTOType::Optimisation());
        panoBase.images[i].optimisationParameters.last().parameter =  PTOType::Optimisation::LENSROLL;
        panoBase.images[i].fileName = preprocessedUrl.toLocalFile();
    }

    switch (fileType)
    {
        case TIFF:
            panoBase.lastComments << QLatin1String("#hugin_outputImageType tif");
            panoBase.lastComments << QLatin1String("#hugin_outputImageTypeCompression LZW");
            break;
        case JPEG:
            panoBase.lastComments << QLatin1String("#hugin_outputImageType jpg");
            panoBase.lastComments << QLatin1String("#hugin_outputJPEGQuality 90");
            break;
        case HDR:
            // TODO: HDR
            break;
    }

    panoBase.createFile(ptoUrl.toLocalFile());

    successFlag = true;
    return;
}