Subversion Repositories seema-scanner

Rev

Rev 141 | Rev 143 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 141 Rev 142
Line 436... Line 436...
436
 
436
 
437
}
437
}
438
 
438
 
439
void SMScanner::on_actionExport_Sequences_triggered(){
439
void SMScanner::on_actionExport_Sequences_triggered(){
440
 
440
 
441
    QProgressDialog progressDialog("Exporting Sequences.", "Cancel", 0, 100);
441
    QProgressDialog progressDialog("Exporting Sequences.", "Cancel", 0, 100, this);
-
 
442
    progressDialog.setWindowModality(Qt::WindowModal);
442
    progressDialog.setMinimumDuration(1000);
443
    progressDialog.setMinimumDuration(1000);
443
 
444
 
444
    progressDialog.setMinimum(1);
445
    progressDialog.show();
445
    progressDialog.setMaximum(captureData.size());
-
 
446
 
446
 
447
    cv::Mat frameBGR;
447
    cv::Mat frameBGR;
448
    QString dirName = QFileDialog::getExistingDirectory(this, "Export frame sequences", QString());
448
    QString dirName = QFileDialog::getExistingDirectory(this, "Export frame sequences", QString());
449
    for(unsigned int i=0; i<captureData.size(); i++){
449
    for(unsigned int i=0; i<captureData.size(); i++){
450
 
450
 
451
        progressDialog.setValue(i);
-
 
452
 
-
 
453
        QString seqDirName = QString("%1/sequence_%2").arg(dirName).arg(i);
451
        QString seqDirName = QString("%1/sequence_%2").arg(dirName).arg(i);
454
        if(!QDir().mkdir(seqDirName))
452
        if(!QDir().mkdir(seqDirName))
455
            std::cerr << "Could not create directory " << seqDirName.toStdString() << std::endl;
453
            std::cerr << "Could not create directory " << seqDirName.toStdString() << std::endl;
456
        for(unsigned int j=0; j<captureData[i].frames0.size(); j++){
454
        for(unsigned int j=0; j<captureData[i].frames0.size(); j++){
-
 
455
 
-
 
456
            progressDialog.setValue(100.0*i/captureData.size() + 100.0*i/captureData.size()*j/captureData[i].frames0.size());
-
 
457
            progressDialog.update();
-
 
458
 
457
            QString fileName = QString("%1/frames0_%2.png").arg(seqDirName).arg(j);
459
            QString fileName0 = QString("%1/frames0_%2.png").arg(seqDirName).arg(j);
458
            // Convert Bayer to rgb (png needs BGR order)
460
            // Convert Bayer to rgb (png needs BGR order)
459
            cv::cvtColor(captureData[i].frames0[j], frameBGR, CV_BayerBG2BGR);
461
            cv::cvtColor(captureData[i].frames0[j], frameBGR, CV_BayerBG2BGR);
460
            cv::imwrite(fileName.toStdString(), frameBGR);
462
            cv::imwrite(fileName0.toStdString(), frameBGR);
461
 
463
 
462
            // Necessary to prevent pileup of video frame signals
464
            // Necessary to prevent pileup of video frame signals
463
            QCoreApplication::processEvents();
465
            QCoreApplication::processEvents();
464
        }
466
 
465
        for(unsigned int j=0; j<captureData[i].frames1.size(); j++){
-
 
466
            QString fileName = QString("%1/frames1_%2.png").arg(seqDirName).arg(j);
467
            QString fileName1 = QString("%1/frames1_%2.png").arg(seqDirName).arg(j);
467
            // Convert Bayer to rgb (png needs BGR order)
468
            // Convert Bayer to rgb (png needs BGR order)
468
            cv::cvtColor(captureData[i].frames1[j], frameBGR, CV_BayerBG2BGR);
469
            cv::cvtColor(captureData[i].frames1[j], frameBGR, CV_BayerBG2BGR);
469
            cv::imwrite(fileName.toStdString(), frameBGR);
470
            cv::imwrite(fileName1.toStdString(), frameBGR);
470
 
471
 
471
            // Necessary to prevent pileup of video frame signals
472
            // Necessary to prevent pileup of video frame signals
472
            QCoreApplication::processEvents();
473
            QCoreApplication::processEvents();
-
 
474
            if(progressDialog.wasCanceled())
-
 
475
                return;
473
        }
476
        }
474
    }
477
    }
475
}
478
}
476
 
479
 
477
void SMScanner::on_actionExport_White_Frames_triggered(){
480
void SMScanner::on_actionExport_White_Frames_triggered(){