Subversion Repositories seema-scanner

Rev

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

Rev 136 Rev 137
Line 77... Line 77...
77
    preferenceDialog.show();
77
    preferenceDialog.show();
78
}
78
}
79
 
79
 
80
void SMScanner::onPreferencesChanged(){
80
void SMScanner::onPreferencesChanged(){
81
 
81
 
82
//    // Stop capturing thread
82
    // Stop capturing thread
83
//    connect(captureWorker, SIGNAL(finished()), captureWorker, SLOT(deleteLater()));
83
    connect(captureWorker, SIGNAL(finished()), captureWorker, SLOT(deleteLater()));
84
//    connect(captureWorker, SIGNAL(finished()), captureWorkerThread, SLOT(quit()));
84
    connect(captureWorker, SIGNAL(finished()), captureWorkerThread, SLOT(quit()));
85
//    QMetaObject::invokeMethod(captureWorker, "stopWork");
85
    QMetaObject::invokeMethod(captureWorker, "stopWork");
86
//    captureWorkerThread->quit();
86
    captureWorkerThread->quit();
87
//    captureWorkerThread->wait();
87
    captureWorkerThread->wait();
88
 
88
 
89
//    // Restart capture worker
89
    // Restart capture worker
90
//    captureWorker = new SMCaptureWorker;
90
    captureWorker = new SMCaptureWorker;
91
//    captureWorkerThread = new QThread(this);
91
    captureWorkerThread = new QThread(this);
92
//    captureWorkerThread->setObjectName("captureWorkerThread");
92
    captureWorkerThread->setObjectName("captureWorkerThread");
93
//    captureWorker->moveToThread(captureWorkerThread);
93
    captureWorker->moveToThread(captureWorkerThread);
94
//    captureWorkerThread->start();
94
    captureWorkerThread->start();
95
 
95
 
96
//    connect(captureWorker, SIGNAL(newFrame(unsigned int, cv::Mat)), this, SLOT(onReceiveFrame(unsigned int, cv::Mat)));
96
    connect(captureWorker, SIGNAL(newFrame(unsigned int, cv::Mat)), this, SLOT(onReceiveFrame(unsigned int, cv::Mat)));
97
//    connect(captureWorker, SIGNAL(newCalibrationSet(SMCalibrationSet)), this, SLOT(onReceiveCalibrationSet(SMCalibrationSet)));
97
    connect(captureWorker, SIGNAL(newCalibrationSet(SMCalibrationSet)), this, SLOT(onReceiveCalibrationSet(SMCalibrationSet)));
98
//    connect(captureWorker, SIGNAL(newFrameSequence(SMFrameSequence)), this, SLOT(onReceiveFrameSequence(SMFrameSequence)));
98
    connect(captureWorker, SIGNAL(newFrameSequence(SMFrameSequence)), this, SLOT(onReceiveFrameSequence(SMFrameSequence)));
99
//    connect(captureWorker, SIGNAL(rotatedTo(float)), this, SLOT(onReceiveRotatedTo(float)));
99
    connect(captureWorker, SIGNAL(rotatedTo(float)), this, SLOT(onReceiveRotatedTo(float)));
100
 
100
 
101
//    QMetaObject::invokeMethod(captureWorker, "setup");
101
    QMetaObject::invokeMethod(captureWorker, "setup");
102
//    QMetaObject::invokeMethod(captureWorker, "doWork");
102
    QMetaObject::invokeMethod(captureWorker, "doWork");
103
 
103
 
104
    QMessageBox::warning(this, "Information", "You must quit and restart the program for new settings to take effect!", QMessageBox::Ok);
104
//    QMessageBox::warning(this, "Information", "You must quit and restart the program for new settings to take effect!", QMessageBox::Ok);
105
 
105
 
106
}
106
}
107
 
107
 
108
void SMScanner::closeEvent(QCloseEvent *event){
108
void SMScanner::closeEvent(QCloseEvent *event){
109
 
109
 
Line 237... Line 237...
237
 
237
 
238
 
238
 
239
 
239
 
240
void SMScanner::onCalibrationSetProcessed(int idx){
240
void SMScanner::onCalibrationSetProcessed(int idx){
241
 
241
 
-
 
242
    if(calibrationData[idx].frame0Result.empty() && calibrationData[idx].frame1Result.empty())
-
 
243
        ui->calibrationListWidget->item(idx)->setCheckState(Qt::Unchecked);
-
 
244
 
242
    ui->calibrationListWidget->setCurrentRow(idx);
245
    ui->calibrationListWidget->setCurrentRow(idx);
243
}
246
}
244
 
247
 
245
void SMScanner::onCalibrationDone(){
248
void SMScanner::onCalibrationDone(){
246
 
249
 
Line 275... Line 278...
275
//     std::cout << "on_calibrationListWidget_itemSelectionChanged" << std::endl;
278
//     std::cout << "on_calibrationListWidget_itemSelectionChanged" << std::endl;
276
}
279
}
277
 
280
 
278
void SMScanner::onCalibrationFrameResult(int idx, int camID, bool success, cv::Mat result){
281
void SMScanner::onCalibrationFrameResult(int idx, int camID, bool success, cv::Mat result){
279
 
282
 
280
//    std::cout << "onCalibrationFrameResult " << idx << camID << std::endl;
-
 
281
 
-
 
282
    if(!success)
283
    if(success){
283
        ui->calibrationListWidget->item(idx)->setCheckState(Qt::Unchecked);
-
 
284
    else {
-
 
285
        if(camID == 0)
284
        if(camID == 0)
286
            calibrationData[idx].frame0Result = result;
285
            calibrationData[idx].frame0Result = result;
287
        else if(camID == 1)
286
        else if(camID == 1)
288
            calibrationData[idx].frame1Result = result;
287
            calibrationData[idx].frame1Result = result;
289
    }
288
    }
Line 425... Line 424...
425
            cv::cvtColor(calibrationData[i].frame1, frameBGR, CV_BayerBG2BGR);
424
            cv::cvtColor(calibrationData[i].frame1, frameBGR, CV_BayerBG2BGR);
426
        else
425
        else
427
            cv::cvtColor(calibrationData[i].frame1, frameBGR, CV_RGB2BGR);
426
            cv::cvtColor(calibrationData[i].frame1, frameBGR, CV_RGB2BGR);
428
 
427
 
429
        cv::imwrite(fileName.toStdString(), frameBGR);
428
        cv::imwrite(fileName.toStdString(), frameBGR);
-
 
429
 
430
        // Necessary to prevent memory pileup?
430
        // Necessary to prevent pileup of video frame signals
431
        QCoreApplication::processEvents();
431
        QCoreApplication::processEvents();
432
    }
432
    }
433
 
433
 
434
}
434
}
435
 
435
 
Line 444... Line 444...
444
        for(unsigned int j=0; j<captureData[i].frames0.size(); j++){
444
        for(unsigned int j=0; j<captureData[i].frames0.size(); j++){
445
            QString fileName = QString("%1/frames0_%2.png").arg(seqDirName).arg(j);
445
            QString fileName = QString("%1/frames0_%2.png").arg(seqDirName).arg(j);
446
            // Convert Bayer to rgb (png needs BGR order)
446
            // Convert Bayer to rgb (png needs BGR order)
447
            cv::cvtColor(captureData[i].frames0[j], frameBGR, CV_BayerBG2BGR);
447
            cv::cvtColor(captureData[i].frames0[j], frameBGR, CV_BayerBG2BGR);
448
            cv::imwrite(fileName.toStdString(), frameBGR);
448
            cv::imwrite(fileName.toStdString(), frameBGR);
-
 
449
 
449
            // Necessary to prevent memory pileup
450
            // Necessary to prevent pileup of video frame signals
450
            QCoreApplication::processEvents();
451
            QCoreApplication::processEvents();
451
        }
452
        }
452
        for(unsigned int j=0; j<captureData[i].frames1.size(); j++){
453
        for(unsigned int j=0; j<captureData[i].frames1.size(); j++){
453
            QString fileName = QString("%1/frames1_%2.png").arg(seqDirName).arg(j);
454
            QString fileName = QString("%1/frames1_%2.png").arg(seqDirName).arg(j);
454
            // Convert Bayer to rgb (png needs BGR order)
455
            // Convert Bayer to rgb (png needs BGR order)
455
            cv::cvtColor(captureData[i].frames1[j], frameBGR, CV_BayerBG2BGR);
456
            cv::cvtColor(captureData[i].frames1[j], frameBGR, CV_BayerBG2BGR);
456
            cv::imwrite(fileName.toStdString(), frameBGR);
457
            cv::imwrite(fileName.toStdString(), frameBGR);
-
 
458
 
457
            // Necessary to prevent memory pileup
459
            // Necessary to prevent pileup of video frame signals
458
            QCoreApplication::processEvents();
460
            QCoreApplication::processEvents();
459
        }
461
        }
460
    }
462
    }
461
}
463
}
462
 
464