1 |
#include "SMScanner.h"
|
1 |
#include "SMScanner.h"
|
2 |
|
2 |
|
3 |
#include "ui_SMScanner.h"
|
3 |
#include "ui_SMScanner.h"
|
4 |
|
4 |
|
5 |
#include <QMetaObject>
|
5 |
#include <QMetaObject>
|
6 |
#include <QFileDialog>
|
6 |
#include <QFileDialog>
|
7 |
#include <QMessageBox>
|
7 |
#include <QMessageBox>
|
8 |
#include <QProgressDialog>
|
8 |
#include <QProgressDialog>
|
9 |
#include <QDesktopServices>
|
9 |
#include <QDesktopServices>
|
10 |
#include <QCollator>
|
10 |
#include <QCollator>
|
11 |
|
11 |
|
12 |
#include <pcl/io/pcd_io.h>
|
12 |
#include <pcl/io/pcd_io.h>
|
13 |
#include <pcl/io/ascii_io.h>
|
13 |
#include <pcl/io/ascii_io.h>
|
14 |
#include <pcl/io/ply_io.h>
|
14 |
#include <pcl/io/ply_io.h>
|
15 |
#include <pcl/io/png_io.h>
|
15 |
#include <pcl/io/png_io.h>
|
16 |
#include <pcl/io/vtk_io.h>
|
16 |
#include <pcl/io/vtk_io.h>
|
17 |
#include <vtkPolyDataWriter.h>
|
17 |
#include <vtkPolyDataWriter.h>
|
18 |
#include <pcl/conversions.h>
|
18 |
#include <pcl/conversions.h>
|
19 |
|
19 |
|
20 |
#include "cvtools.h"
|
20 |
#include "cvtools.h"
|
21 |
|
21 |
|
22 |
SMScanner::SMScanner(QWidget *parent) :QMainWindow(parent), ui(new Ui::SMScanner),
|
22 |
SMScanner::SMScanner(QWidget *parent) :QMainWindow(parent), ui(new Ui::SMScanner),
|
23 |
calibrationReviewMode(false), captureReviewMode(false), lastCaptureId(-1){
|
23 |
calibrationReviewMode(false), captureReviewMode(false), lastCaptureId(-1){
|
24 |
|
24 |
|
25 |
// Register metatypes
|
25 |
// Register metatypes
|
26 |
qRegisterMetaType<cv::Mat>("cv::Mat");
|
26 |
qRegisterMetaType<cv::Mat>("cv::Mat");
|
27 |
qRegisterMetaType< std::vector<cv::Mat> >("std::vector<cv::Mat>");
|
27 |
qRegisterMetaType< std::vector<cv::Mat> >("std::vector<cv::Mat>");
|
28 |
qRegisterMetaType< std::vector<float> >("std::vector<float>");
|
28 |
qRegisterMetaType< std::vector<float> >("std::vector<float>");
|
29 |
qRegisterMetaType<SMCalibrationSet>("SMCalibrationSet");
|
29 |
qRegisterMetaType<SMCalibrationSet>("SMCalibrationSet");
|
30 |
qRegisterMetaType< std::vector<SMCalibrationSet> >("std::vector<SMCalibrationSet>");
|
30 |
qRegisterMetaType< std::vector<SMCalibrationSet> >("std::vector<SMCalibrationSet>");
|
31 |
qRegisterMetaType<SMFrameSequence>("SMFrameSequence");
|
31 |
qRegisterMetaType<SMFrameSequence>("SMFrameSequence");
|
32 |
qRegisterMetaType< std::vector<SMFrameSequence> >("std::vector<SMFrameSequence>");
|
32 |
qRegisterMetaType< std::vector<SMFrameSequence> >("std::vector<SMFrameSequence>");
|
33 |
qRegisterMetaType<pcl::PointCloud<pcl::PointXYZRGB>::Ptr>("pcl::PointCloud<pcl::PointXYZRGB>::Ptr");
|
33 |
qRegisterMetaType<pcl::PointCloud<pcl::PointXYZRGB>::Ptr>("pcl::PointCloud<pcl::PointXYZRGB>::Ptr");
|
34 |
qRegisterMetaType<SMPointCloud>("SMPointCloud");
|
34 |
qRegisterMetaType<SMPointCloud>("SMPointCloud");
|
35 |
qRegisterMetaType< std::vector<SMPointCloud> >("std::vector<SMPointCloud>");
|
35 |
qRegisterMetaType< std::vector<SMPointCloud> >("std::vector<SMPointCloud>");
|
36 |
|
36 |
|
37 |
// Setup ui (requires stream operators registered)
|
37 |
// Setup ui (requires stream operators registered)
|
38 |
ui->setupUi(this);
|
38 |
ui->setupUi(this);
|
39 |
|
39 |
|
40 |
// Restore geometry
|
40 |
// Restore geometry
|
41 |
this->restoreGeometry(settings.value("geometry/mainwindow").toByteArray());
|
41 |
this->restoreGeometry(settings.value("geometry/mainwindow").toByteArray());
|
42 |
this->restoreState(settings.value("state/mainwindow").toByteArray());
|
42 |
this->restoreState(settings.value("state/mainwindow").toByteArray());
|
43 |
|
43 |
|
- |
|
44 |
// Set up export thread
|
- |
|
45 |
exportWorker = new SMExportWorker();
|
- |
|
46 |
exportWorkerThread = new QThread(this);
|
- |
|
47 |
exportWorkerThread->setObjectName("exportWorkerThread");
|
- |
|
48 |
exportWorker->moveToThread(exportWorkerThread);
|
- |
|
49 |
exportWorkerThread->start();
|
- |
|
50 |
|
- |
|
51 |
// Connections
|
- |
|
52 |
connect(this, SIGNAL(exportFrameSequence(QString, SMFrameSequence)), exportWorker, SLOT(exportFrameSequence(QString, SMFrameSequence)));
|
- |
|
53 |
connect(exportWorker, SIGNAL(progressUpdate(int)), this, SLOT(onExportProgress(int)));
|
- |
|
54 |
connect(exportWorker, SIGNAL(aborted()), this, SLOT(onAbortedExport()));
|
- |
|
55 |
connect(exportWorker, SIGNAL(finished(int)), this, SLOT(onFinishedExport(int)));
|
- |
|
56 |
|
- |
|
57 |
// Start export timer
|
- |
|
58 |
exportTimer = new QTimer(this);
|
- |
|
59 |
connect(exportTimer, SIGNAL(timeout()), exportWorker, SLOT(work()));
|
- |
|
60 |
exportTimer->start(1000);
|
- |
|
61 |
|
44 |
// Set up capture thread
|
62 |
// Set up capture thread
|
45 |
captureWorker = new SMCaptureWorker;
|
63 |
captureWorker = new SMCaptureWorker;
|
46 |
captureWorkerThread = new QThread(this);
|
64 |
captureWorkerThread = new QThread(this);
|
47 |
captureWorkerThread->setObjectName("captureWorkerThread");
|
65 |
captureWorkerThread->setObjectName("captureWorkerThread");
|
48 |
captureWorker->moveToThread(captureWorkerThread);
|
66 |
captureWorker->moveToThread(captureWorkerThread);
|
49 |
captureWorkerThread->start();
|
67 |
captureWorkerThread->start();
|
50 |
|
68 |
|
51 |
// Connections
|
69 |
// Connections
|
52 |
connect(captureWorker, SIGNAL(newFrame(unsigned int, cv::Mat)), this, SLOT(onReceiveFrame(unsigned int, cv::Mat)));
|
70 |
connect(captureWorker, SIGNAL(newFrame(unsigned int, cv::Mat)), this, SLOT(onReceiveFrame(unsigned int, cv::Mat)));
|
53 |
connect(captureWorker, SIGNAL(newCalibrationSet(SMCalibrationSet)), this, SLOT(onReceiveCalibrationSet(SMCalibrationSet)));
|
71 |
connect(captureWorker, SIGNAL(newCalibrationSet(SMCalibrationSet)), this, SLOT(onReceiveCalibrationSet(SMCalibrationSet)));
|
54 |
connect(captureWorker, SIGNAL(newFrameSequence(SMFrameSequence)), this, SLOT(onReceiveFrameSequence(SMFrameSequence)));
|
72 |
connect(captureWorker, SIGNAL(newFrameSequence(SMFrameSequence)), this, SLOT(onReceiveFrameSequence(SMFrameSequence)));
|
55 |
connect(captureWorker, SIGNAL(rotatedTo(float)), this, SLOT(onReceiveRotatedTo(float)));
|
73 |
connect(captureWorker, SIGNAL(rotatedTo(float)), this, SLOT(onReceiveRotatedTo(float)));
|
56 |
|
74 |
|
57 |
// Start capturing
|
75 |
// Start capturing
|
58 |
QMetaObject::invokeMethod(captureWorker, "setup");
|
76 |
QMetaObject::invokeMethod(captureWorker, "setup");
|
59 |
QMetaObject::invokeMethod(captureWorker, "doWork");
|
77 |
QMetaObject::invokeMethod(captureWorker, "doWork");
|
60 |
|
78 |
|
61 |
// Set up calibration thread
|
79 |
// Set up calibration thread
|
62 |
calibrationWorker = new SMCalibrationWorker;
|
80 |
calibrationWorker = new SMCalibrationWorker;
|
63 |
calibrationWorkerThread = new QThread(this);
|
81 |
calibrationWorkerThread = new QThread(this);
|
64 |
calibrationWorkerThread->setObjectName("calibrationWorkerThread");
|
82 |
calibrationWorkerThread->setObjectName("calibrationWorkerThread");
|
65 |
calibrationWorker->moveToThread(calibrationWorkerThread);
|
83 |
calibrationWorker->moveToThread(calibrationWorkerThread);
|
66 |
calibrationWorkerThread->start();
|
84 |
calibrationWorkerThread->start();
|
67 |
|
85 |
|
68 |
// Connections
|
86 |
// Connections
|
69 |
connect(calibrationWorker, SIGNAL(newCheckerboardResult(int, SMCalibrationSet)), this, SLOT(onReceiveCheckerboardResult(int, SMCalibrationSet)));
|
87 |
connect(calibrationWorker, SIGNAL(newCheckerboardResult(int, SMCalibrationSet)), this, SLOT(onReceiveCheckerboardResult(int, SMCalibrationSet)));
|
70 |
connect(calibrationWorker, SIGNAL(done()), this, SLOT(onReceiveCalibrationDone()));
|
88 |
connect(calibrationWorker, SIGNAL(done()), this, SLOT(onReceiveCalibrationDone()));
|
71 |
connect(calibrationWorker, SIGNAL(done()), ui->pointCloudWidget, SLOT(updateCalibrationParameters()));
|
89 |
connect(calibrationWorker, SIGNAL(done()), ui->pointCloudWidget, SLOT(updateCalibrationParameters()));
|
72 |
// connect(calibrationWorker, SIGNAL(done()), calibrationWorkerThread, SLOT(quit()));
|
90 |
// connect(calibrationWorker, SIGNAL(done()), calibrationWorkerThread, SLOT(quit()));
|
73 |
// connect(calibrationWorker, SIGNAL(done()), calibrationWorker, SLOT(deleteLater()));
|
91 |
// connect(calibrationWorker, SIGNAL(done()), calibrationWorker, SLOT(deleteLater()));
|
74 |
connect(calibrationWorker, SIGNAL(logMessage(QString)), &logDialog, SLOT(showLogMessage(QString)));
|
92 |
connect(calibrationWorker, SIGNAL(logMessage(QString)), &logDialog, SLOT(showLogMessage(QString)));
|
75 |
|
93 |
|
76 |
// Set up reconstruction thread
|
94 |
// Set up reconstruction thread
|
77 |
reconstructionWorker = new SMReconstructionWorker;
|
95 |
reconstructionWorker = new SMReconstructionWorker;
|
78 |
reconstructionWorkerThread = new QThread(this);
|
96 |
reconstructionWorkerThread = new QThread(this);
|
79 |
reconstructionWorkerThread->setObjectName("reconstructionWorkerThread");
|
97 |
reconstructionWorkerThread->setObjectName("reconstructionWorkerThread");
|
80 |
reconstructionWorker->moveToThread(reconstructionWorkerThread);
|
98 |
reconstructionWorker->moveToThread(reconstructionWorkerThread);
|
81 |
reconstructionWorkerThread->start();
|
99 |
reconstructionWorkerThread->start();
|
82 |
|
100 |
|
83 |
// Connections
|
101 |
// Connections
|
84 |
connect(reconstructionWorker, SIGNAL(newPointCloud(SMPointCloud)), this, SLOT(onReceivePointCloud(SMPointCloud)));
|
102 |
connect(reconstructionWorker, SIGNAL(newPointCloud(SMPointCloud)), this, SLOT(onReceivePointCloud(SMPointCloud)));
|
85 |
connect(reconstructionWorker, SIGNAL(done()), reconstructionWorkerThread, SLOT(quit()));
|
103 |
connect(reconstructionWorker, SIGNAL(done()), reconstructionWorkerThread, SLOT(quit()));
|
86 |
connect(reconstructionWorker, SIGNAL(done()), reconstructionWorker, SLOT(deleteLater()));
|
104 |
connect(reconstructionWorker, SIGNAL(done()), reconstructionWorker, SLOT(deleteLater()));
|
87 |
|
105 |
|
88 |
}
|
106 |
}
|
89 |
|
107 |
|
90 |
void SMScanner::onReceiveFrame(unsigned int camId, cv::Mat frame){
|
108 |
void SMScanner::onReceiveFrame(unsigned int camId, cv::Mat frame){
|
91 |
|
109 |
|
92 |
if(camId == 0){
|
110 |
if(camId == 0){
|
93 |
if(!calibrationReviewMode)
|
111 |
if(!calibrationReviewMode)
|
94 |
ui->calibrationCamera0Widget->showImageCV(frame);
|
112 |
ui->calibrationCamera0Widget->showImageCV(frame);
|
95 |
if(!captureReviewMode)
|
113 |
if(!captureReviewMode)
|
96 |
ui->captureCamera0Widget->showImageCV(frame);
|
114 |
ui->captureCamera0Widget->showImageCV(frame);
|
97 |
} else if(camId == 1){
|
115 |
} else if(camId == 1){
|
98 |
if(!calibrationReviewMode)
|
116 |
if(!calibrationReviewMode)
|
99 |
ui->calibrationCamera1Widget->showImageCV(frame);
|
117 |
ui->calibrationCamera1Widget->showImageCV(frame);
|
100 |
if(!captureReviewMode)
|
118 |
if(!captureReviewMode)
|
101 |
ui->captureCamera1Widget->showImageCV(frame);
|
119 |
ui->captureCamera1Widget->showImageCV(frame);
|
102 |
}
|
120 |
}
|
103 |
}
|
121 |
}
|
104 |
|
122 |
|
105 |
void SMScanner::on_actionPreferences_triggered(){
|
123 |
void SMScanner::on_actionPreferences_triggered(){
|
106 |
|
124 |
|
107 |
connect(&preferenceDialog, SIGNAL(accepted()), this, SLOT(onPreferencesChanged()));
|
125 |
connect(&preferenceDialog, SIGNAL(accepted()), this, SLOT(onPreferencesChanged()));
|
108 |
|
126 |
|
109 |
preferenceDialog.show();
|
127 |
preferenceDialog.show();
|
110 |
}
|
128 |
}
|
111 |
|
129 |
|
112 |
void SMScanner::onPreferencesChanged(){
|
130 |
void SMScanner::onPreferencesChanged(){
|
113 |
|
131 |
|
114 |
// Stop capture worker
|
132 |
// Stop capture worker
|
115 |
// connect(captureWorker, SIGNAL(finished()), captureWorker, SLOT(deleteLater()));
|
133 |
// connect(captureWorker, SIGNAL(finished()), captureWorker, SLOT(deleteLater()));
|
116 |
// connect(captureWorker, SIGNAL(finished()), captureWorkerThread, SLOT(quit()));
|
134 |
// connect(captureWorker, SIGNAL(finished()), captureWorkerThread, SLOT(quit()));
|
117 |
QMetaObject::invokeMethod(captureWorker, "stopWork");
|
135 |
QMetaObject::invokeMethod(captureWorker, "stopWork");
|
118 |
// captureWorkerThread->quit();
|
136 |
// captureWorkerThread->quit();
|
119 |
// captureWorkerThread->wait();
|
137 |
// captureWorkerThread->wait();
|
120 |
|
138 |
|
121 |
// // Restart capture worker
|
139 |
// // Restart capture worker
|
122 |
// captureWorker = new SMCaptureWorker;
|
140 |
// captureWorker = new SMCaptureWorker;
|
123 |
// captureWorkerThread = new QThread(this);
|
141 |
// captureWorkerThread = new QThread(this);
|
124 |
// captureWorkerThread->setObjectName("captureWorkerThread");
|
142 |
// captureWorkerThread->setObjectName("captureWorkerThread");
|
125 |
// captureWorker->moveToThread(captureWorkerThread);
|
143 |
// captureWorker->moveToThread(captureWorkerThread);
|
126 |
// captureWorkerThread->start();
|
144 |
// captureWorkerThread->start();
|
127 |
|
145 |
|
128 |
// connect(captureWorker, SIGNAL(newFrame(unsigned int, cv::Mat)), this, SLOT(onReceiveFrame(unsigned int, cv::Mat)));
|
146 |
// connect(captureWorker, SIGNAL(newFrame(unsigned int, cv::Mat)), this, SLOT(onReceiveFrame(unsigned int, cv::Mat)));
|
129 |
// connect(captureWorker, SIGNAL(newCalibrationSet(SMCalibrationSet)), this, SLOT(onReceiveCalibrationSet(SMCalibrationSet)));
|
147 |
// connect(captureWorker, SIGNAL(newCalibrationSet(SMCalibrationSet)), this, SLOT(onReceiveCalibrationSet(SMCalibrationSet)));
|
130 |
// connect(captureWorker, SIGNAL(newFrameSequence(SMFrameSequence)), this, SLOT(onReceiveFrameSequence(SMFrameSequence)));
|
148 |
// connect(captureWorker, SIGNAL(newFrameSequence(SMFrameSequence)), this, SLOT(onReceiveFrameSequence(SMFrameSequence)));
|
131 |
// connect(captureWorker, SIGNAL(rotatedTo(float)), this, SLOT(onReceiveRotatedTo(float)));
|
149 |
// connect(captureWorker, SIGNAL(rotatedTo(float)), this, SLOT(onReceiveRotatedTo(float)));
|
132 |
|
150 |
|
133 |
QMetaObject::invokeMethod(captureWorker, "setup");
|
151 |
QMetaObject::invokeMethod(captureWorker, "setup");
|
134 |
QMetaObject::invokeMethod(captureWorker, "doWork");
|
152 |
QMetaObject::invokeMethod(captureWorker, "doWork");
|
135 |
|
153 |
|
136 |
}
|
154 |
}
|
137 |
|
155 |
|
138 |
void SMScanner::closeEvent(QCloseEvent *event){
|
156 |
void SMScanner::closeEvent(QCloseEvent *event){
|
139 |
|
157 |
|
140 |
// Close dialogs
|
158 |
// Close dialogs
|
141 |
preferenceDialog.close();
|
159 |
preferenceDialog.close();
|
142 |
logDialog.close();
|
160 |
logDialog.close();
|
143 |
|
161 |
|
144 |
// Stop capturing thread
|
162 |
// Stop capturing thread
|
145 |
connect(captureWorker, SIGNAL(finished()), captureWorker, SLOT(deleteLater()));
|
163 |
connect(captureWorker, SIGNAL(finished()), captureWorker, SLOT(deleteLater()));
|
146 |
connect(captureWorker, SIGNAL(finished()), captureWorkerThread, SLOT(quit()));
|
164 |
connect(captureWorker, SIGNAL(finished()), captureWorkerThread, SLOT(quit()));
|
147 |
QMetaObject::invokeMethod(captureWorker, "stopWork");
|
165 |
QMetaObject::invokeMethod(captureWorker, "stopWork");
|
148 |
captureWorkerThread->quit();
|
166 |
captureWorkerThread->quit();
|
149 |
captureWorkerThread->wait();
|
167 |
captureWorkerThread->wait();
|
150 |
|
168 |
|
151 |
// Save window geometry
|
169 |
// Save window geometry
|
152 |
settings.setValue("geometry/mainwindow", this->saveGeometry());
|
170 |
settings.setValue("geometry/mainwindow", this->saveGeometry());
|
153 |
settings.setValue("state/mainwindow", this->saveState());
|
171 |
settings.setValue("state/mainwindow", this->saveState());
|
154 |
|
172 |
|
155 |
event->accept();
|
173 |
event->accept();
|
156 |
|
174 |
|
157 |
}
|
175 |
}
|
158 |
|
176 |
|
159 |
SMScanner::~SMScanner(){
|
177 |
SMScanner::~SMScanner(){
|
160 |
delete ui;
|
178 |
delete ui;
|
161 |
}
|
179 |
}
|
162 |
|
180 |
|
163 |
void SMScanner::on_singleCalibrationButton_clicked(){
|
181 |
void SMScanner::on_singleCalibrationButton_clicked(){
|
164 |
|
182 |
|
165 |
// If in review mode, go back to aquisition mode
|
183 |
// If in review mode, go back to aquisition mode
|
166 |
if(calibrationReviewMode){
|
184 |
if(calibrationReviewMode){
|
167 |
ui->calibrationListWidget->clearSelection();
|
185 |
ui->calibrationListWidget->clearSelection();
|
168 |
ui->singleCalibrationButton->setText("Single Aquisition");
|
186 |
ui->singleCalibrationButton->setText("Single Aquisition");
|
169 |
ui->batchCalibrationButton->setText("Batch Aquisition");
|
187 |
ui->batchCalibrationButton->setText("Batch Aquisition");
|
170 |
calibrationReviewMode = false;
|
188 |
calibrationReviewMode = false;
|
171 |
return;
|
189 |
return;
|
172 |
}
|
190 |
}
|
173 |
|
191 |
|
174 |
QMetaObject::invokeMethod(captureWorker, "acquireCalibrationSet", Q_ARG(float, -1.0));
|
192 |
QMetaObject::invokeMethod(captureWorker, "acquireCalibrationSet", Q_ARG(float, -1.0));
|
175 |
|
193 |
|
176 |
}
|
194 |
}
|
177 |
|
195 |
|
178 |
|
196 |
|
179 |
void SMScanner::on_batchCalibrationButton_clicked(){
|
197 |
void SMScanner::on_batchCalibrationButton_clicked(){
|
180 |
|
198 |
|
181 |
// If in review mode, go back to aquisition mode
|
199 |
// If in review mode, go back to aquisition mode
|
182 |
if(calibrationReviewMode){
|
200 |
if(calibrationReviewMode){
|
183 |
ui->calibrationListWidget->clearSelection();
|
201 |
ui->calibrationListWidget->clearSelection();
|
184 |
ui->singleCalibrationButton->setText("Single Aquisition");
|
202 |
ui->singleCalibrationButton->setText("Single Aquisition");
|
185 |
ui->batchCalibrationButton->setText("Batch Aquisition");
|
203 |
ui->batchCalibrationButton->setText("Batch Aquisition");
|
186 |
calibrationReviewMode = false;
|
204 |
calibrationReviewMode = false;
|
187 |
return;
|
205 |
return;
|
188 |
}
|
206 |
}
|
189 |
|
207 |
|
190 |
// Construct vector of angles
|
208 |
// Construct vector of angles
|
191 |
int angleStart = ui->calibrationBatchStartSpinBox->value();
|
209 |
int angleStart = ui->calibrationBatchStartSpinBox->value();
|
192 |
int angleEnd = ui->calibrationBatchEndSpinBox->value();
|
210 |
int angleEnd = ui->calibrationBatchEndSpinBox->value();
|
193 |
int angleStep = ui->calibrationBatchStepSpinBox->value();
|
211 |
int angleStep = ui->calibrationBatchStepSpinBox->value();
|
194 |
|
212 |
|
195 |
if(angleStart > angleEnd)
|
213 |
if(angleStart > angleEnd)
|
196 |
angleEnd += 360;
|
214 |
angleEnd += 360;
|
197 |
|
215 |
|
198 |
std::vector<float> angles;
|
216 |
std::vector<float> angles;
|
199 |
for(int i=angleStart; i<=angleEnd; i+=angleStep)
|
217 |
for(int i=angleStart; i<=angleEnd; i+=angleStep)
|
200 |
angles.push_back(i % 360);
|
218 |
angles.push_back(i % 360);
|
201 |
|
219 |
|
202 |
QMetaObject::invokeMethod(captureWorker, "acquireCalibrationSets", Q_ARG(std::vector<float>, angles));
|
220 |
QMetaObject::invokeMethod(captureWorker, "acquireCalibrationSets", Q_ARG(std::vector<float>, angles));
|
203 |
|
221 |
|
204 |
std::cout << "Aquiring sets at ";
|
222 |
std::cout << "Aquiring sets at ";
|
205 |
for(unsigned int i=0; i<angles.size(); i++)
|
223 |
for(unsigned int i=0; i<angles.size(); i++)
|
206 |
std::cout << angles[i] << " ";
|
224 |
std::cout << angles[i] << " ";
|
207 |
std::cout << " degrees" <<std::endl;
|
225 |
std::cout << " degrees" <<std::endl;
|
208 |
}
|
226 |
}
|
209 |
|
227 |
|
210 |
|
228 |
|
211 |
void SMScanner::on_calibrationRotationDial_sliderReleased(){
|
229 |
void SMScanner::on_calibrationRotationDial_sliderReleased(){
|
212 |
|
230 |
|
213 |
float angle = ui->calibrationRotationDial->value();
|
231 |
float angle = ui->calibrationRotationDial->value();
|
214 |
std::cout << "Rotation stage target: " << angle << std::endl;
|
232 |
std::cout << "Rotation stage target: " << angle << std::endl;
|
215 |
QMetaObject::invokeMethod(captureWorker, "rotateTo", Q_ARG(float, angle));
|
233 |
QMetaObject::invokeMethod(captureWorker, "rotateTo", Q_ARG(float, angle));
|
216 |
|
234 |
|
217 |
ui->calibrationRotationSpinBox->setValue(angle);
|
235 |
ui->calibrationRotationSpinBox->setValue(angle);
|
218 |
|
236 |
|
219 |
ui->captureRotationDial->setValue(angle);
|
237 |
ui->captureRotationDial->setValue(angle);
|
220 |
ui->captureRotationSpinBox->setValue(angle);
|
238 |
ui->captureRotationSpinBox->setValue(angle);
|
221 |
}
|
239 |
}
|
222 |
|
240 |
|
223 |
|
241 |
|
224 |
void SMScanner::on_calibrationRotationSpinBox_editingFinished(){
|
242 |
void SMScanner::on_calibrationRotationSpinBox_editingFinished(){
|
225 |
|
243 |
|
226 |
float angle = ui->calibrationRotationSpinBox->value();
|
244 |
float angle = ui->calibrationRotationSpinBox->value();
|
227 |
std::cout << "Rotation stage target: " << angle << std::endl;
|
245 |
std::cout << "Rotation stage target: " << angle << std::endl;
|
228 |
QMetaObject::invokeMethod(captureWorker, "rotateTo", Q_ARG(float, angle));
|
246 |
QMetaObject::invokeMethod(captureWorker, "rotateTo", Q_ARG(float, angle));
|
229 |
|
247 |
|
230 |
ui->calibrationRotationDial->setValue(angle);
|
248 |
ui->calibrationRotationDial->setValue(angle);
|
231 |
|
249 |
|
232 |
ui->captureRotationSpinBox->setValue(angle);
|
250 |
ui->captureRotationSpinBox->setValue(angle);
|
233 |
ui->captureRotationDial->setValue(angle);
|
251 |
ui->captureRotationDial->setValue(angle);
|
234 |
}
|
252 |
}
|
235 |
|
253 |
|
236 |
void SMScanner::onReceiveCalibrationSet(SMCalibrationSet calibrationSet){
|
254 |
void SMScanner::onReceiveCalibrationSet(SMCalibrationSet calibrationSet){
|
237 |
|
255 |
|
238 |
// Send to checkerboard detection on calibration thread
|
256 |
// Send to checkerboard detection on calibration thread
|
239 |
|
257 |
|
240 |
if(settings.value("calibration/method").toString() == "Charuco")
|
258 |
if(settings.value("calibration/method").toString() == "Charuco")
|
241 |
QMetaObject::invokeMethod(calibrationWorker, "checkerboardDetectionCharuco", Q_ARG(SMCalibrationSet, calibrationSet));
|
259 |
QMetaObject::invokeMethod(calibrationWorker, "checkerboardDetectionCharuco", Q_ARG(SMCalibrationSet, calibrationSet));
|
242 |
else
|
260 |
else
|
243 |
QMetaObject::invokeMethod(calibrationWorker, "checkerboardDetection", Q_ARG(SMCalibrationSet, calibrationSet));
|
261 |
QMetaObject::invokeMethod(calibrationWorker, "checkerboardDetection", Q_ARG(SMCalibrationSet, calibrationSet));
|
244 |
|
262 |
|
245 |
}
|
263 |
}
|
246 |
|
264 |
|
247 |
void SMScanner::on_calibrateCamerasButton_clicked(){
|
265 |
void SMScanner::on_calibrateCamerasButton_clicked(){
|
248 |
|
266 |
|
249 |
// disable ui elements
|
267 |
// disable ui elements
|
250 |
ui->calibrateCamerasButton->setEnabled(false);
|
268 |
ui->calibrateCamerasButton->setEnabled(false);
|
251 |
ui->calibrateRotationStageButton->setEnabled(false);
|
269 |
ui->calibrateRotationStageButton->setEnabled(false);
|
252 |
ui->calibrationFrame->setEnabled(false);
|
270 |
ui->calibrationFrame->setEnabled(false);
|
253 |
|
271 |
|
254 |
// if none items are selected, we will use all available items
|
272 |
// if none items are selected, we will use all available items
|
255 |
if(ui->calibrationListWidget->selectedItems().empty())
|
273 |
if(ui->calibrationListWidget->selectedItems().empty())
|
256 |
ui->calibrationListWidget->selectAll();
|
274 |
ui->calibrationListWidget->selectAll();
|
257 |
|
275 |
|
258 |
// set selected flags
|
276 |
// set selected flags
|
259 |
for(unsigned int i=0; i<calibrationData.size(); i++){
|
277 |
for(unsigned int i=0; i<calibrationData.size(); i++){
|
260 |
if(ui->calibrationListWidget->item(i)->isSelected())
|
278 |
if(ui->calibrationListWidget->item(i)->isSelected())
|
261 |
calibrationData[i].selected = true;
|
279 |
calibrationData[i].selected = true;
|
262 |
else
|
280 |
else
|
263 |
calibrationData[i].selected = false;
|
281 |
calibrationData[i].selected = false;
|
264 |
}
|
282 |
}
|
265 |
|
283 |
|
266 |
logDialog.show();
|
284 |
logDialog.show();
|
267 |
|
285 |
|
268 |
// start calibration
|
286 |
// start calibration
|
269 |
QSettings settings;
|
287 |
QSettings settings;
|
270 |
if(settings.value("calibration/method").toString() == "Charuco")
|
288 |
if(settings.value("calibration/method").toString() == "Charuco")
|
271 |
QMetaObject::invokeMethod(calibrationWorker, "cameraCalibrationCharuco", Q_ARG(std::vector<SMCalibrationSet>, calibrationData));
|
289 |
QMetaObject::invokeMethod(calibrationWorker, "cameraCalibrationCharuco", Q_ARG(std::vector<SMCalibrationSet>, calibrationData));
|
272 |
else
|
290 |
else
|
273 |
QMetaObject::invokeMethod(calibrationWorker, "cameraCalibration", Q_ARG(std::vector<SMCalibrationSet>, calibrationData));
|
291 |
QMetaObject::invokeMethod(calibrationWorker, "cameraCalibration", Q_ARG(std::vector<SMCalibrationSet>, calibrationData));
|
274 |
|
292 |
|
275 |
|
293 |
|
276 |
}
|
294 |
}
|
277 |
|
295 |
|
278 |
void SMScanner::onReceiveCheckerboardResult(int idx, SMCalibrationSet calibrationSet){
|
296 |
void SMScanner::onReceiveCheckerboardResult(int, SMCalibrationSet calibrationSet){
|
279 |
|
297 |
|
280 |
int id = ui->calibrationListWidget->count();
|
298 |
int id = ui->calibrationListWidget->count();
|
281 |
calibrationSet.id = id;
|
299 |
calibrationSet.id = id;
|
282 |
|
300 |
|
283 |
calibrationData.push_back(calibrationSet);
|
301 |
calibrationData.push_back(calibrationSet);
|
284 |
|
302 |
|
285 |
// Add identifier to list
|
303 |
// Add identifier to list
|
286 |
QListWidgetItem* item = new QListWidgetItem(QString("Calibration Set %1 -- %2 deg").arg(id).arg(calibrationSet.rotationAngle), ui->calibrationListWidget);
|
304 |
QListWidgetItem* item = new QListWidgetItem(QString("Calibration Set %1 -- %2 deg").arg(id).arg(calibrationSet.rotationAngle), ui->calibrationListWidget);
|
287 |
ui->calibrationListWidget->addItem(item);
|
305 |
ui->calibrationListWidget->addItem(item);
|
288 |
item->setSelected(true);
|
306 |
item->setSelected(true);
|
289 |
ui->calibrationListWidget->setCurrentItem(item);
|
307 |
ui->calibrationListWidget->setCurrentItem(item);
|
290 |
|
308 |
|
291 |
// Enable calibration button
|
309 |
// Enable calibration button
|
292 |
if(calibrationData.size() >= 2){
|
310 |
if(calibrationData.size() >= 2){
|
293 |
ui->calibrateCamerasButton->setEnabled(true);
|
311 |
ui->calibrateCamerasButton->setEnabled(true);
|
294 |
ui->calibrateRotationStageButton->setEnabled(true);
|
312 |
ui->calibrateRotationStageButton->setEnabled(true);
|
295 |
}
|
313 |
}
|
296 |
|
314 |
|
297 |
//ui->calibrationListWidget->setCurrentRow(idx);
|
315 |
//ui->calibrationListWidget->setCurrentRow(idx);
|
298 |
}
|
316 |
}
|
299 |
|
317 |
|
300 |
void SMScanner::onReceiveCalibrationDone(){
|
318 |
void SMScanner::onReceiveCalibrationDone(){
|
301 |
|
319 |
|
302 |
std::cout << "Calibration done!" << std::endl;
|
320 |
std::cout << "Calibration done!" << std::endl;
|
303 |
ui->calibrateCamerasButton->setEnabled(true);
|
321 |
ui->calibrateCamerasButton->setEnabled(true);
|
304 |
ui->calibrateRotationStageButton->setEnabled(true);
|
322 |
ui->calibrateRotationStageButton->setEnabled(true);
|
305 |
ui->calibrationFrame->setEnabled(true);
|
323 |
ui->calibrationFrame->setEnabled(true);
|
306 |
|
324 |
|
307 |
}
|
325 |
}
|
308 |
|
326 |
|
309 |
void SMScanner::on_calibrationListWidget_itemSelectionChanged(){
|
327 |
void SMScanner::on_calibrationListWidget_itemSelectionChanged(){
|
310 |
|
328 |
|
311 |
// if selection is just cleared
|
329 |
// if selection is just cleared
|
312 |
if(ui->calibrationListWidget->selectedItems().empty())
|
330 |
if(ui->calibrationListWidget->selectedItems().empty())
|
313 |
return;
|
331 |
return;
|
314 |
|
332 |
|
315 |
calibrationReviewMode = true;
|
333 |
calibrationReviewMode = true;
|
316 |
ui->singleCalibrationButton->setText("Live View");
|
334 |
ui->singleCalibrationButton->setText("Live View");
|
317 |
ui->batchCalibrationButton->setText("Live View");
|
335 |
ui->batchCalibrationButton->setText("Live View");
|
318 |
|
336 |
|
319 |
int currentRow = ui->calibrationListWidget->currentRow();
|
337 |
int currentRow = ui->calibrationListWidget->currentRow();
|
320 |
if(currentRow < 0)
|
338 |
if(currentRow < 0)
|
321 |
return;
|
339 |
return;
|
322 |
|
340 |
|
323 |
assert(currentRow < (int)calibrationData.size());
|
341 |
assert(currentRow < (int)calibrationData.size());
|
324 |
|
342 |
|
325 |
// if checkerboard results are available, show them, otherwise show the frame
|
343 |
// if checkerboard results are available, show them, otherwise show the frame
|
326 |
if(calibrationData[currentRow].frame0Result.empty())
|
344 |
if(calibrationData[currentRow].frame0Result.empty())
|
327 |
ui->calibrationCamera0Widget->showImageCV(calibrationData[currentRow].frame0);
|
345 |
ui->calibrationCamera0Widget->showImageCV(calibrationData[currentRow].frame0);
|
328 |
else
|
346 |
else
|
329 |
ui->calibrationCamera0Widget->showImageCV(calibrationData[currentRow].frame0Result);
|
347 |
ui->calibrationCamera0Widget->showImageCV(calibrationData[currentRow].frame0Result);
|
330 |
|
348 |
|
331 |
if(calibrationData[currentRow].frame1Result.empty())
|
349 |
if(calibrationData[currentRow].frame1Result.empty())
|
332 |
ui->calibrationCamera1Widget->showImageCV(calibrationData[currentRow].frame1);
|
350 |
ui->calibrationCamera1Widget->showImageCV(calibrationData[currentRow].frame1);
|
333 |
else
|
351 |
else
|
334 |
ui->calibrationCamera1Widget->showImageCV(calibrationData[currentRow].frame1Result);
|
352 |
ui->calibrationCamera1Widget->showImageCV(calibrationData[currentRow].frame1Result);
|
335 |
|
353 |
|
336 |
}
|
354 |
}
|
337 |
|
355 |
|
338 |
void SMScanner::on_captureRotationDial_sliderReleased(){
|
356 |
void SMScanner::on_captureRotationDial_sliderReleased(){
|
339 |
|
357 |
|
340 |
float angle = ui->captureRotationDial->value();
|
358 |
float angle = ui->captureRotationDial->value();
|
341 |
std::cout << "Rotation stage target: " << angle << std::endl;
|
359 |
std::cout << "Rotation stage target: " << angle << std::endl;
|
342 |
QMetaObject::invokeMethod(captureWorker, "rotateTo", Q_ARG(float, angle));
|
360 |
QMetaObject::invokeMethod(captureWorker, "rotateTo", Q_ARG(float, angle));
|
343 |
|
361 |
|
344 |
ui->captureRotationSpinBox->setValue(ui->captureRotationDial->value());
|
362 |
ui->captureRotationSpinBox->setValue(ui->captureRotationDial->value());
|
345 |
|
363 |
|
346 |
ui->calibrationRotationDial->setValue(ui->captureRotationDial->value());
|
364 |
ui->calibrationRotationDial->setValue(ui->captureRotationDial->value());
|
347 |
ui->calibrationRotationSpinBox->setValue(ui->captureRotationDial->value());
|
365 |
ui->calibrationRotationSpinBox->setValue(ui->captureRotationDial->value());
|
348 |
}
|
366 |
}
|
349 |
|
367 |
|
350 |
void SMScanner::on_captureRotationSpinBox_editingFinished(){
|
368 |
void SMScanner::on_captureRotationSpinBox_editingFinished(){
|
351 |
|
369 |
|
352 |
float angle = ui->captureRotationSpinBox->value();
|
370 |
float angle = ui->captureRotationSpinBox->value();
|
353 |
std::cout << "Rotation stage target: " << angle << std::endl;
|
371 |
std::cout << "Rotation stage target: " << angle << std::endl;
|
354 |
QMetaObject::invokeMethod(captureWorker, "rotateTo", Q_ARG(float, angle));
|
372 |
QMetaObject::invokeMethod(captureWorker, "rotateTo", Q_ARG(float, angle));
|
355 |
|
373 |
|
356 |
ui->captureRotationDial->setValue(angle);
|
374 |
ui->captureRotationDial->setValue(angle);
|
357 |
|
375 |
|
358 |
ui->calibrationRotationSpinBox->setValue(angle);
|
376 |
ui->calibrationRotationSpinBox->setValue(angle);
|
359 |
ui->calibrationRotationDial->setValue(angle);
|
377 |
ui->calibrationRotationDial->setValue(angle);
|
360 |
}
|
378 |
}
|
361 |
|
379 |
|
362 |
void SMScanner::on_singleCaptureButton_clicked(){
|
380 |
void SMScanner::on_singleCaptureButton_clicked(){
|
363 |
|
381 |
|
364 |
// If in review mode, go back to aquisition mode
|
382 |
// If in review mode, go back to aquisition mode
|
365 |
if(captureReviewMode){
|
383 |
if(captureReviewMode){
|
366 |
ui->captureTreeWidget->clearSelection();
|
384 |
ui->captureTreeWidget->clearSelection();
|
367 |
ui->singleCaptureButton->setText("Single Aquisition");
|
385 |
ui->singleCaptureButton->setText("Single Aquisition");
|
368 |
ui->batchCaptureButton->setText("Batch Aquisition");
|
386 |
ui->batchCaptureButton->setText("Batch Aquisition");
|
369 |
captureReviewMode = false;
|
387 |
captureReviewMode = false;
|
370 |
return;
|
388 |
return;
|
371 |
}
|
389 |
}
|
372 |
|
390 |
|
373 |
QMetaObject::invokeMethod(captureWorker, "acquireFrameSequence", Q_ARG(float, -1.0));
|
391 |
QMetaObject::invokeMethod(captureWorker, "acquireFrameSequence", Q_ARG(float, -1.0));
|
374 |
|
392 |
|
375 |
}
|
393 |
}
|
376 |
|
394 |
|
377 |
|
395 |
|
378 |
void SMScanner::on_batchCaptureButton_clicked(){
|
396 |
void SMScanner::on_batchCaptureButton_clicked(){
|
379 |
|
397 |
|
380 |
// If in review mode, go back to aquisition mode
|
398 |
// If in review mode, go back to aquisition mode
|
381 |
if(captureReviewMode){
|
399 |
if(captureReviewMode){
|
382 |
ui->captureTreeWidget->clearSelection();
|
400 |
ui->captureTreeWidget->clearSelection();
|
383 |
ui->singleCaptureButton->setText("Single Aquisition");
|
401 |
ui->singleCaptureButton->setText("Single Aquisition");
|
384 |
ui->batchCaptureButton->setText("Batch Aquisition");
|
402 |
ui->batchCaptureButton->setText("Batch Aquisition");
|
385 |
captureReviewMode = false;
|
403 |
captureReviewMode = false;
|
386 |
return;
|
404 |
return;
|
387 |
}
|
405 |
}
|
388 |
|
406 |
|
389 |
// Construct vector of angles
|
407 |
// Construct vector of angles
|
- |
|
408 |
int repeatsteps = ui->captureBatchStepRepeatSpinBox->value();
|
- |
|
409 |
int repeatsequence = ui->captureBatchSequenceRepeatSpinBox->value();
|
390 |
int angleStart = ui->captureBatchStartSpinBox->value();
|
410 |
int angleStart = ui->captureBatchStartSpinBox->value();
|
391 |
int angleEnd = ui->captureBatchEndSpinBox->value();
|
411 |
int angleEnd = ui->captureBatchEndSpinBox->value();
|
392 |
int angleStep = ui->captureBatchStepSpinBox->value();
|
412 |
int angleStep = ui->captureBatchStepSpinBox->value();
|
393 |
|
413 |
|
394 |
if(angleStart > angleEnd)
|
414 |
if(angleStart > angleEnd)
|
395 |
angleEnd += 360;
|
415 |
angleEnd += 360;
|
396 |
|
416 |
|
397 |
std::vector<float> angles;
|
417 |
std::vector<float> angles;
|
398 |
for(int i=angleStart; i<=angleEnd; i+=angleStep)
|
418 |
for(int i=angleStart; i<=angleEnd; i+=angleStep) {
|
399 |
angles.push_back(i % 360);
|
419 |
angles.push_back(i % 360);
|
- |
|
420 |
for(int j=1; j<repeatsteps; ++j)
|
- |
|
421 |
angles.push_back(-1);
|
- |
|
422 |
}
|
- |
|
423 |
for(int l=1; l<repeatsequence; ++l) {
|
- |
|
424 |
for(int i=angleStart; i<=angleEnd; i+=angleStep) {
|
- |
|
425 |
angles.push_back(i % 360);
|
- |
|
426 |
for(int j=1; j<repeatsteps; ++j)
|
- |
|
427 |
angles.push_back(-1);
|
- |
|
428 |
}
|
- |
|
429 |
}
|
400 |
|
430 |
|
401 |
std::cout << "Aquiring sequences at ";
|
431 |
std::cout << "Aquiring sequences at ";
|
402 |
for(unsigned int i=0; i<angles.size(); i++)
|
432 |
for(unsigned int i=0; i<angles.size(); i++)
|
403 |
std::cout << angles[i] << " ";
|
433 |
std::cout << angles[i] << " ";
|
404 |
std::cout << " degrees" <<std::endl;
|
434 |
std::cout << " degrees" <<std::endl;
|
405 |
|
435 |
|
406 |
QMetaObject::invokeMethod(captureWorker, "acquireFrameSequences", Q_ARG(std::vector<float>, angles));
|
436 |
QMetaObject::invokeMethod(captureWorker, "acquireFrameSequences", Q_ARG(std::vector<float>, angles));
|
407 |
}
|
437 |
}
|
408 |
|
438 |
|
409 |
void SMScanner::onReceiveFrameSequence(SMFrameSequence frameSequence){
|
439 |
void SMScanner::onReceiveFrameSequence(SMFrameSequence frameSequence){
|
410 |
|
440 |
|
411 |
frameSequence.id = ++lastCaptureId;
|
441 |
frameSequence.id = ++lastCaptureId;
|
412 |
|
442 |
|
413 |
// Add identifier to list
|
443 |
// Add identifier to list
|
414 |
QTreeWidgetItem* item = new QTreeWidgetItem(ui->captureTreeWidget);
|
444 |
QTreeWidgetItem* item = new QTreeWidgetItem(ui->captureTreeWidget);
|
415 |
item->setText(0, QString("Frame Sequence %1 -- %2 deg").arg(frameSequence.id).arg(frameSequence.rotationAngle));
|
445 |
item->setText(0, QString("Frame Sequence %1 -- %2 deg").arg(frameSequence.id).arg(frameSequence.rotationAngle));
|
416 |
//item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
446 |
//item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
417 |
item->setData(0, Qt::UserRole, QPoint(frameSequence.id, -1));
|
447 |
item->setData(0, Qt::UserRole, QPoint(frameSequence.id, -1));
|
418 |
//item->setCheckState(0, Qt::Checked);
|
448 |
//item->setCheckState(0, Qt::Checked);
|
419 |
//ui->captureTreeWidget->addItem(item);
|
449 |
//ui->captureTreeWidget->addItem(item);
|
420 |
|
450 |
|
421 |
for(unsigned int i=0; i<frameSequence.frames0.size(); i++){
|
451 |
for(unsigned int i=0; i<frameSequence.frames0.size(); i++){
|
422 |
QTreeWidgetItem* subItem = new QTreeWidgetItem(item);
|
452 |
QTreeWidgetItem* subItem = new QTreeWidgetItem(item);
|
423 |
subItem->setText(0, QString("frames %1").arg(i));
|
453 |
subItem->setText(0, QString("frames %1").arg(i));
|
424 |
subItem->setData(0, Qt::UserRole, QPoint(frameSequence.id, i));
|
454 |
subItem->setData(0, Qt::UserRole, QPoint(frameSequence.id, i));
|
425 |
}
|
455 |
}
|
426 |
|
456 |
|
427 |
// Indicate that the current item is currently reconstructing
|
457 |
// Indicate that the current item is currently reconstructing
|
428 |
item->setTextColor(0, QColor(128, 128, 128));
|
458 |
item->setTextColor(0, QColor(128, 128, 128));
|
429 |
item->setIcon(0, QIcon::fromTheme("system-run"));
|
459 |
item->setIcon(0, QIcon::fromTheme("system-run"));
|
430 |
|
460 |
|
431 |
// Reconstruct the frame sequence
|
461 |
// Reconstruct the frame sequence
|
432 |
QMetaObject::invokeMethod(reconstructionWorker, "reconstructPointCloud", Q_ARG(SMFrameSequence, frameSequence));
|
462 |
QMetaObject::invokeMethod(reconstructionWorker, "reconstructPointCloud", Q_ARG(SMFrameSequence, frameSequence));
|
433 |
frameSequence.reconstructed = true;
|
463 |
frameSequence.reconstructed = true;
|
434 |
|
464 |
|
435 |
captureData.push_back(frameSequence);
|
465 |
captureData.push_back(frameSequence);
|
436 |
|
466 |
|
437 |
}
|
467 |
}
|
438 |
|
468 |
|
439 |
void SMScanner::on_captureTreeWidget_itemSelectionChanged(){
|
469 |
void SMScanner::on_captureTreeWidget_itemSelectionChanged(){
|
440 |
|
470 |
|
441 |
// if selection is just cleared
|
471 |
// if selection is just cleared
|
442 |
if(ui->captureTreeWidget->selectedItems().empty())
|
472 |
if(ui->captureTreeWidget->selectedItems().empty())
|
443 |
return;
|
473 |
return;
|
444 |
|
474 |
|
445 |
QTreeWidgetItem *item = ui->captureTreeWidget->currentItem();
|
475 |
QTreeWidgetItem *item = ui->captureTreeWidget->currentItem();
|
446 |
|
476 |
|
447 |
captureReviewMode = true;
|
477 |
captureReviewMode = true;
|
448 |
|
478 |
|
449 |
ui->singleCaptureButton->setText("Live View");
|
479 |
ui->singleCaptureButton->setText("Live View");
|
450 |
ui->batchCaptureButton->setText("Live View");
|
480 |
ui->batchCaptureButton->setText("Live View");
|
451 |
|
481 |
|
452 |
QPoint idx = item->data(0, Qt::UserRole).toPoint();
|
482 |
QPoint idx = item->data(0, Qt::UserRole).toPoint();
|
453 |
|
483 |
|
454 |
if( idx.y() != -1 && idx.x()>=0 && idx.x()<(int)captureData.size()
|
484 |
if( idx.y() != -1 && idx.x()>=0 && idx.x()<(int)captureData.size()
|
455 |
&& idx.y()<(int)captureData[idx.x()].frames0.size()
|
485 |
&& idx.y()<(int)captureData[idx.x()].frames0.size()
|
456 |
&& idx.y()<(int)captureData[idx.x()].frames1.size() ){
|
486 |
&& idx.y()<(int)captureData[idx.x()].frames1.size() ){
|
457 |
// TODO idx.x() can & WILL be out of bounds
|
487 |
// TODO idx.x() can & WILL be out of bounds
|
458 |
ui->captureCamera0Widget->showImageCV(captureData[idx.x()].frames0[idx.y()]);
|
488 |
ui->captureCamera0Widget->showImageCV(captureData[idx.x()].frames0[idx.y()]);
|
459 |
ui->captureCamera1Widget->showImageCV(captureData[idx.x()].frames1[idx.y()]);
|
489 |
ui->captureCamera1Widget->showImageCV(captureData[idx.x()].frames1[idx.y()]);
|
460 |
}
|
490 |
}
|
461 |
|
491 |
|
462 |
// std::cout << "on_captureTreeWidget_itemSelectionChanged" << std::endl;
|
492 |
// std::cout << "on_captureTreeWidget_itemSelectionChanged" << std::endl;
|
463 |
}
|
493 |
}
|
464 |
|
494 |
|
465 |
|
495 |
|
466 |
void SMScanner::onReceiveRotatedTo(float angle){
|
496 |
void SMScanner::onReceiveRotatedTo(float angle){
|
467 |
|
497 |
|
468 |
// update ui with new position
|
498 |
// update ui with new position
|
469 |
ui->calibrationRotationDial->setValue(angle);
|
499 |
ui->calibrationRotationDial->setValue(angle);
|
470 |
ui->captureRotationDial->setValue(angle);
|
500 |
ui->captureRotationDial->setValue(angle);
|
471 |
|
501 |
|
472 |
ui->calibrationRotationSpinBox->setValue(angle);
|
502 |
ui->calibrationRotationSpinBox->setValue(angle);
|
473 |
ui->captureRotationSpinBox->setValue(angle);
|
503 |
ui->captureRotationSpinBox->setValue(angle);
|
474 |
}
|
504 |
}
|
475 |
|
505 |
|
476 |
void SMScanner::on_actionExport_Sets_triggered(){
|
506 |
void SMScanner::on_actionExport_Sets_triggered(){
|
477 |
|
507 |
|
478 |
QString dirName = QFileDialog::getExistingDirectory(this, "Export calibration sets", QString());
|
508 |
QString dirName = QFileDialog::getExistingDirectory(this, "Export calibration sets", QString());
|
479 |
|
509 |
|
480 |
QProgressDialog progressDialog("Exporting Sets...", "Cancel", 0, 100, this);
|
510 |
QProgressDialog progressDialog("Exporting Sets...", "Cancel", 0, 100, this);
|
481 |
progressDialog.setWindowModality(Qt::WindowModal);
|
511 |
progressDialog.setWindowModality(Qt::WindowModal);
|
482 |
progressDialog.setMinimumDuration(1000);
|
512 |
progressDialog.setMinimumDuration(1000);
|
483 |
|
513 |
|
484 |
progressDialog.show();
|
514 |
progressDialog.show();
|
485 |
cv::Mat frameBGR;
|
515 |
cv::Mat frameBGR;
|
486 |
for(unsigned int i=0; i<calibrationData.size(); i++){
|
516 |
for(unsigned int i=0; i<calibrationData.size(); i++){
|
487 |
QString fileName = QString("%1/frame0_%2.png").arg(dirName).arg(i);
|
517 |
QString fileName = QString("%1/frame0_%2.png").arg(dirName).arg(i);
|
488 |
|
518 |
|
489 |
progressDialog.setValue(100.0*i/calibrationData.size());
|
519 |
progressDialog.setValue(100.0*i/calibrationData.size());
|
490 |
|
520 |
|
491 |
// Convert to BGR
|
521 |
// Convert to BGR
|
492 |
if(calibrationData[i].frame0.channels() == 1)
|
522 |
if(calibrationData[i].frame0.channels() == 1)
|
493 |
cv::cvtColor(calibrationData[i].frame0, frameBGR, CV_BayerBG2BGR);
|
523 |
cv::cvtColor(calibrationData[i].frame0, frameBGR, CV_BayerBG2BGR);
|
494 |
else
|
524 |
else
|
495 |
cv::cvtColor(calibrationData[i].frame1, frameBGR, CV_RGB2BGR);
|
525 |
cv::cvtColor(calibrationData[i].frame1, frameBGR, CV_RGB2BGR);
|
496 |
|
526 |
|
497 |
cv::imwrite(fileName.toStdString(), frameBGR);
|
527 |
cv::imwrite(fileName.toStdString(), frameBGR);
|
498 |
fileName = QString("%1/frame1_%2.png").arg(dirName).arg(i);
|
528 |
fileName = QString("%1/frame1_%2.png").arg(dirName).arg(i);
|
499 |
|
529 |
|
500 |
// Convert to BGR
|
530 |
// Convert to BGR
|
501 |
if(calibrationData[i].frame1.channels() == 1)
|
531 |
if(calibrationData[i].frame1.channels() == 1)
|
502 |
cv::cvtColor(calibrationData[i].frame1, frameBGR, CV_BayerBG2BGR);
|
532 |
cv::cvtColor(calibrationData[i].frame1, frameBGR, CV_BayerBG2BGR);
|
503 |
else
|
533 |
else
|
504 |
cv::cvtColor(calibrationData[i].frame1, frameBGR, CV_RGB2BGR);
|
534 |
cv::cvtColor(calibrationData[i].frame1, frameBGR, CV_RGB2BGR);
|
505 |
|
535 |
|
506 |
cv::imwrite(fileName.toStdString(), frameBGR);
|
536 |
cv::imwrite(fileName.toStdString(), frameBGR);
|
507 |
|
537 |
|
508 |
// Necessary to prevent pileup of video frame signals
|
538 |
// Necessary to prevent pileup of video frame signals
|
509 |
QCoreApplication::processEvents();
|
539 |
QCoreApplication::processEvents();
|
510 |
|
540 |
|
511 |
if(progressDialog.wasCanceled())
|
541 |
if(progressDialog.wasCanceled())
|
512 |
return;
|
542 |
return;
|
513 |
}
|
543 |
}
|
514 |
|
544 |
|
515 |
}
|
545 |
}
|
516 |
|
546 |
|
517 |
void SMScanner::on_actionExport_Sequences_triggered(){
|
547 |
void SMScanner::on_actionExport_Sequences_triggered(){
|
518 |
|
548 |
|
519 |
QString dirName = QFileDialog::getExistingDirectory(this, "Export frame sequences", QString());
|
549 |
QString dirName = QFileDialog::getExistingDirectory(this, "Export frame sequences", QString());
|
520 |
|
550 |
|
521 |
QProgressDialog progressDialog("Exporting Sequences...", "Cancel", 0, 100, this);
|
551 |
QProgressDialog progressDialog("Exporting Sequences...", "Cancel", 0, 100, this);
|
522 |
progressDialog.setWindowModality(Qt::WindowModal);
|
552 |
progressDialog.setWindowModality(Qt::WindowModal);
|
523 |
progressDialog.setMinimumDuration(1000);
|
553 |
progressDialog.setMinimumDuration(1000);
|
524 |
|
554 |
|
525 |
progressDialog.show();
|
555 |
progressDialog.show();
|
526 |
|
556 |
|
527 |
cv::Mat frameBGR;
|
557 |
cv::Mat frameBGR;
|
528 |
for(unsigned int i=0; i<captureData.size(); i++){
|
558 |
for(unsigned int i=0; i<captureData.size(); i++){
|
529 |
|
- |
|
530 |
QString format;
|
- |
|
531 |
if(captureData[i].frames0[0].depth() == CV_32F)
|
- |
|
532 |
format = "hdr";
|
- |
|
533 |
else
|
- |
|
534 |
format = "png";
|
- |
|
535 |
|
- |
|
536 |
QString seqDirName = QString("%1/sequence_%2").arg(dirName).arg(i);
|
- |
|
537 |
if(!QDir().mkdir(seqDirName))
|
- |
|
538 |
std::cerr << "Could not create directory " << seqDirName.toStdString() << std::endl;
|
- |
|
539 |
for(unsigned int j=0; j<captureData[i].frames0.size(); j++){
|
- |
|
540 |
|
- |
|
541 |
progressDialog.setValue(100.0*i/captureData.size() + 100.0/captureData.size()*j/captureData[i].frames0.size());
|
- |
|
542 |
|
- |
|
543 |
QString fileName0 = QString("%1/frames0_%2.%3").arg(seqDirName).arg(j).arg(format);
|
- |
|
544 |
|
- |
|
545 |
// Convert Bayer to rgb (png needs BGR order)
|
- |
|
546 |
if(captureData[i].frames0[j].type() == CV_8UC1)
|
- |
|
547 |
cv::cvtColor(captureData[i].frames0[j], frameBGR, CV_BayerBG2BGR);
|
- |
|
548 |
else
|
- |
|
549 |
cv::cvtColor(captureData[i].frames0[j], frameBGR, CV_RGB2BGR);
|
- |
|
550 |
|
- |
|
551 |
cv::imwrite(fileName0.toStdString(), frameBGR);
|
- |
|
552 |
|
- |
|
553 |
// Necessary to prevent pileup of video frame signals
|
- |
|
554 |
QCoreApplication::processEvents();
|
- |
|
555 |
|
- |
|
556 |
QString fileName1 = QString("%1/frames1_%2.%3").arg(seqDirName).arg(j).arg(format);
|
- |
|
557 |
|
- |
|
558 |
// Convert Bayer to rgb (png needs BGR order)
|
- |
|
559 |
if(captureData[i].frames1[j].type() == CV_8UC1)
|
- |
|
560 |
cv::cvtColor(captureData[i].frames1[j], frameBGR, CV_BayerBG2BGR);
|
- |
|
561 |
else
|
- |
|
562 |
cv::cvtColor(captureData[i].frames1[j], frameBGR, CV_RGB2BGR);
|
- |
|
563 |
|
- |
|
564 |
cv::imwrite(fileName1.toStdString(), frameBGR);
|
- |
|
565 |
|
- |
|
566 |
// Necessary to prevent pileup of video frame signals
|
- |
|
567 |
QCoreApplication::processEvents();
|
559 |
emit exportFrameSequence(dirName, captureData[i]);
|
568 |
if(progressDialog.wasCanceled())
|
- |
|
569 |
return;
|
- |
|
570 |
}
|
- |
|
571 |
}
|
560 |
}
|
572 |
}
|
561 |
}
|
573 |
|
562 |
|
574 |
void SMScanner::on_actionExport_White_Frames_triggered(){
|
563 |
void SMScanner::on_actionExport_White_Frames_triggered(){
|
575 |
|
564 |
|
576 |
QString dirName = QFileDialog::getExistingDirectory(this, "Export frame sequences", QString());
|
565 |
QString dirName = QFileDialog::getExistingDirectory(this, "Export frame sequences", QString());
|
577 |
|
566 |
|
578 |
QProgressDialog progressDialog("Exporting White Frames...", "Cancel", 0, 100, this);
|
567 |
QProgressDialog progressDialog("Exporting White Frames...", "Cancel", 0, 100, this);
|
579 |
progressDialog.setWindowModality(Qt::WindowModal);
|
568 |
progressDialog.setWindowModality(Qt::WindowModal);
|
580 |
progressDialog.setMinimumDuration(1000);
|
569 |
progressDialog.setMinimumDuration(1000);
|
581 |
|
570 |
|
582 |
cv::Mat frameBGR;
|
571 |
cv::Mat frameBGR;
|
583 |
for(unsigned int i=0; i<captureData.size(); i++){
|
572 |
for(unsigned int i=0; i<captureData.size(); i++){
|
584 |
|
573 |
|
585 |
progressDialog.setValue(100.0*i/captureData.size());
|
574 |
progressDialog.setValue(100.0*i/captureData.size());
|
586 |
|
575 |
|
587 |
QString seqDirName = QString("%1/sequence_%2").arg(dirName).arg(i);
|
576 |
QString seqDirName = QString("%1/sequence_%2").arg(dirName).arg(i);
|
588 |
if(!QDir().mkdir(seqDirName))
|
577 |
if(!QDir().mkdir(seqDirName))
|
589 |
std::cerr << "Could not create directory " << seqDirName.toStdString() << std::endl;
|
578 |
std::cerr << "Could not create directory " << seqDirName.toStdString() << std::endl;
|
590 |
|
579 |
|
591 |
QString fileName = QString("%1/frames0_0.png").arg(seqDirName);
|
580 |
QString fileName = QString("%1/frames0_0.png").arg(seqDirName);
|
592 |
// Convert Bayer to rgb (png needs BGR order)
|
581 |
// Convert Bayer to rgb (png needs BGR order)
|
593 |
cv::cvtColor(captureData[i].frames0[0], frameBGR, CV_BayerBG2BGR);
|
582 |
cv::cvtColor(captureData[i].frames0[0], frameBGR, CV_BayerBG2BGR);
|
594 |
cv::imwrite(fileName.toStdString(), frameBGR);
|
583 |
cv::imwrite(fileName.toStdString(), frameBGR);
|
595 |
// Necessary to prevent memory pileup
|
584 |
// Necessary to prevent memory pileup
|
596 |
QCoreApplication::processEvents();
|
585 |
QCoreApplication::processEvents();
|
597 |
|
586 |
|
598 |
fileName = QString("%1/frames1_0.png").arg(seqDirName);
|
587 |
fileName = QString("%1/frames1_0.png").arg(seqDirName);
|
599 |
// Convert Bayer to rgb (png needs BGR order)
|
588 |
// Convert Bayer to rgb (png needs BGR order)
|
600 |
cv::cvtColor(captureData[i].frames1[0], frameBGR, CV_BayerBG2BGR);
|
589 |
cv::cvtColor(captureData[i].frames1[0], frameBGR, CV_BayerBG2BGR);
|
601 |
cv::imwrite(fileName.toStdString(), frameBGR);
|
590 |
cv::imwrite(fileName.toStdString(), frameBGR);
|
602 |
// Necessary to prevent memory pileup
|
591 |
// Necessary to prevent memory pileup
|
603 |
QCoreApplication::processEvents();
|
592 |
QCoreApplication::processEvents();
|
604 |
if(progressDialog.wasCanceled())
|
593 |
if(progressDialog.wasCanceled())
|
605 |
return;
|
594 |
return;
|
606 |
}
|
595 |
}
|
607 |
|
596 |
|
608 |
}
|
597 |
}
|
609 |
|
598 |
|
610 |
|
599 |
|
611 |
void SMScanner::onReceivePointCloud(SMPointCloud smCloud){
|
600 |
void SMScanner::onReceivePointCloud(SMPointCloud smCloud){
|
612 |
|
601 |
|
613 |
pointCloudData.push_back(smCloud);
|
602 |
pointCloudData.push_back(smCloud);
|
614 |
|
603 |
|
615 |
// Add identifier to list
|
604 |
// Add identifier to list
|
616 |
QListWidgetItem* item = new QListWidgetItem(QString("Point Cloud %1 -- %2 deg").arg(smCloud.id).arg(smCloud.rotationAngle));
|
605 |
QListWidgetItem* item = new QListWidgetItem(QString("Point Cloud %1 -- %2 deg").arg(smCloud.id).arg(smCloud.rotationAngle));
|
617 |
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
606 |
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
618 |
item->setData(Qt::UserRole, QVariant(smCloud.id));
|
607 |
item->setData(Qt::UserRole, QVariant(smCloud.id));
|
619 |
item->setCheckState(Qt::Checked);
|
608 |
item->setCheckState(Qt::Checked);
|
620 |
|
609 |
|
621 |
ui->pointCloudsListWidget->addItem(item);
|
610 |
ui->pointCloudsListWidget->addItem(item);
|
622 |
ui->pointCloudWidget->addPointCloud(smCloud, smCloud.id);
|
611 |
ui->pointCloudWidget->addPointCloud(smCloud, smCloud.id);
|
623 |
|
612 |
|
624 |
// Indicate completed reconstruction in captureTreeWidget
|
613 |
// Indicate completed reconstruction in captureTreeWidget
|
625 |
for(int i=0; i<ui->captureTreeWidget->topLevelItemCount(); i++){
|
614 |
for(int i=0; i<ui->captureTreeWidget->topLevelItemCount(); i++){
|
626 |
QTreeWidgetItem *captureItem = ui->captureTreeWidget->topLevelItem(i);
|
615 |
QTreeWidgetItem *captureItem = ui->captureTreeWidget->topLevelItem(i);
|
627 |
if(captureItem->data(0, Qt::UserRole).toPoint() == QPoint(smCloud.id, -1)){
|
616 |
if(captureItem->data(0, Qt::UserRole).toPoint() == QPoint(smCloud.id, -1)){
|
628 |
captureItem->setTextColor(0, QColor(0, 0, 0));
|
617 |
captureItem->setTextColor(0, QColor(0, 0, 0));
|
629 |
captureItem->setIcon(0, QIcon());
|
618 |
captureItem->setIcon(0, QIcon());
|
630 |
}
|
619 |
}
|
631 |
}
|
620 |
}
|
632 |
|
621 |
|
- |
|
622 |
if (ui->exportCheckBox->isChecked()) {
|
- |
|
623 |
QString path = ui->exportPathLineEdit->text();
|
- |
|
624 |
for(unsigned int i = 0; i < captureData.size(); i++) {
|
- |
|
625 |
if (captureData[i].id == smCloud.id) {
|
- |
|
626 |
emit exportFrameSequence(path, captureData[i]);
|
- |
|
627 |
break;
|
- |
|
628 |
}
|
- |
|
629 |
}
|
- |
|
630 |
}
|
- |
|
631 |
}
|
- |
|
632 |
|
- |
|
633 |
void SMScanner::onExportProgress(int progress) {
|
- |
|
634 |
ui->exportProgressBar->setEnabled(true);
|
- |
|
635 |
ui->abortExportPushButton->setEnabled(true);
|
- |
|
636 |
ui->exportProgressBar->setValue(progress);
|
- |
|
637 |
}
|
- |
|
638 |
|
- |
|
639 |
void SMScanner::onAbortedExport() {
|
- |
|
640 |
ui->exportProgressBar->setEnabled(false);
|
- |
|
641 |
ui->abortExportPushButton->setEnabled(false);
|
- |
|
642 |
ui->exportProgressBar->setValue(100);
|
- |
|
643 |
}
|
- |
|
644 |
|
- |
|
645 |
void SMScanner::onFinishedExport(int id) {
|
- |
|
646 |
if (ui->deleteExportCheckBox->isChecked()) {
|
- |
|
647 |
for(unsigned int i = 0; i < captureData.size(); i++) {
|
- |
|
648 |
if (captureData[i].id == id) {
|
- |
|
649 |
captureData.erase(captureData.begin()+i);
|
- |
|
650 |
ui->captureTreeWidget->takeTopLevelItem(i);
|
- |
|
651 |
break;
|
- |
|
652 |
}
|
- |
|
653 |
}
|
- |
|
654 |
}
|
- |
|
655 |
onAbortedExport();
|
633 |
}
|
656 |
}
|
634 |
|
657 |
|
635 |
void SMScanner::on_actionExport_Point_Clouds_triggered(){
|
658 |
void SMScanner::on_actionExport_Point_Clouds_triggered(){
|
636 |
|
659 |
|
637 |
QString directory = QFileDialog::getExistingDirectory(this, "Export Point Clouds", QString());
|
660 |
QString directory = QFileDialog::getExistingDirectory(this, "Export Point Clouds", QString());
|
638 |
|
661 |
|
639 |
// // Non native file dialog
|
662 |
// // Non native file dialog
|
640 |
// QFileDialog saveDirectoryDialog(this, "Export Point Clouds", QString(), "*.pcd;;*.ply;;*.vtk;;*.png;;*.txt");
|
663 |
// QFileDialog saveDirectoryDialog(this, "Export Point Clouds", QString(), "*.pcd;;*.ply;;*.vtk;;*.png;;*.txt");
|
641 |
// saveDirectoryDialog.setDefaultSuffix("ply");
|
664 |
// saveDirectoryDialog.setDefaultSuffix("ply");
|
642 |
// saveDirectoryDialog.setFileMode(QFileDialog::Directory);
|
665 |
// saveDirectoryDialog.setFileMode(QFileDialog::Directory);
|
643 |
// saveDirectoryDialog.exec();
|
666 |
// saveDirectoryDialog.exec();
|
644 |
// QString directory = saveDirectoryDialog.directory().path();
|
667 |
// QString directory = saveDirectoryDialog.directory().path();
|
645 |
// QString type = saveDirectoryDialog.selectedNameFilter();
|
668 |
// QString type = saveDirectoryDialog.selectedNameFilter();
|
646 |
|
669 |
|
647 |
QProgressDialog progressDialog("Exporting Point Clouds...", "Cancel", 0, 100, this);
|
670 |
QProgressDialog progressDialog("Exporting Point Clouds...", "Cancel", 0, 100, this);
|
648 |
progressDialog.setWindowModality(Qt::WindowModal);
|
671 |
progressDialog.setWindowModality(Qt::WindowModal);
|
649 |
progressDialog.setMinimumDuration(1000);
|
672 |
progressDialog.setMinimumDuration(1000);
|
650 |
|
673 |
|
651 |
// save point clouds in ply format
|
674 |
// save point clouds in ply format
|
652 |
for(unsigned int i=0; i<pointCloudData.size(); i++){
|
675 |
for(unsigned int i=0; i<pointCloudData.size(); i++){
|
653 |
|
676 |
|
654 |
progressDialog.setValue(100.0*i/pointCloudData.size());
|
677 |
progressDialog.setValue(100.0*i/pointCloudData.size());
|
655 |
if(pointCloudData[i].id != -1){
|
678 |
if(pointCloudData[i].id != -1){
|
656 |
QString fileName = QString("%1/pointcloud_%2.ply").arg(directory).arg(i);
|
679 |
QString fileName = QString("%1/pointcloud_%2.ply").arg(directory).arg(pointCloudData[i].id);
|
657 |
pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr pointCloudPCL(pointCloudData[i].pointCloud);
|
680 |
pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr pointCloudPCL(pointCloudData[i].pointCloud);
|
658 |
//pcl::io::savePLYFileBinary(fileName.toStdString(), *pointCloudPCL);
|
681 |
//pcl::io::savePLYFileBinary(fileName.toStdString(), *pointCloudPCL);
|
659 |
pcl::PLYWriter w;
|
682 |
pcl::PLYWriter w;
|
660 |
// Write to ply in binary without camera
|
683 |
// Write to ply in binary without camera
|
661 |
w.write<pcl::PointXYZRGBNormal> (fileName.toStdString(), *pointCloudPCL, true, false);
|
684 |
w.write<pcl::PointXYZRGBNormal> (fileName.toStdString(), *pointCloudPCL, true, false);
|
662 |
}
|
685 |
}
|
663 |
QCoreApplication::processEvents();
|
686 |
QCoreApplication::processEvents();
|
664 |
if(progressDialog.wasCanceled())
|
687 |
if(progressDialog.wasCanceled())
|
665 |
return;
|
688 |
return;
|
666 |
}
|
689 |
}
|
667 |
|
690 |
|
668 |
// save meshlab aln project file
|
691 |
// save meshlab aln project file
|
669 |
std::ofstream s(QString("%1/alignment.aln").arg(directory).toLocal8Bit());
|
692 |
std::ofstream s(QString("%1/alignment.aln").arg(directory).toLocal8Bit());
|
670 |
s << pointCloudData.size() << std::endl;
|
693 |
s << pointCloudData.size() << std::endl;
|
671 |
for(unsigned int i=0; i<pointCloudData.size(); i++){
|
694 |
for(unsigned int i=0; i<pointCloudData.size(); i++){
|
672 |
if(pointCloudData[i].id != -1){
|
695 |
if(pointCloudData[i].id != -1){
|
673 |
QString fileName = QString("pointcloud_%1.ply").arg(pointCloudData[i].id);
|
696 |
QString fileName = QString("pointcloud_%1.ply").arg(pointCloudData[i].id);
|
674 |
s << fileName.toStdString() << std::endl << "#" << std::endl;
|
697 |
s << fileName.toStdString() << std::endl << "#" << std::endl;
|
675 |
cv::Mat Tr = cv::Mat::eye(4, 4, CV_32F);
|
698 |
cv::Mat Tr = cv::Mat::eye(4, 4, CV_32F);
|
676 |
cv::Mat(pointCloudData[i].R.t()).copyTo(Tr.colRange(0, 3).rowRange(0, 3));
|
699 |
cv::Mat(pointCloudData[i].R.t()).copyTo(Tr.colRange(0, 3).rowRange(0, 3));
|
677 |
cv::Mat(-pointCloudData[i].R.t()*pointCloudData[i].T).copyTo(Tr.col(3).rowRange(0, 3));
|
700 |
cv::Mat(-pointCloudData[i].R.t()*pointCloudData[i].T).copyTo(Tr.col(3).rowRange(0, 3));
|
678 |
for(int j=0; j<Tr.rows; j++){
|
701 |
for(int j=0; j<Tr.rows; j++){
|
679 |
for(int k=0; k<Tr.cols; k++){
|
702 |
for(int k=0; k<Tr.cols; k++){
|
680 |
s << Tr.at<float>(j,k) << " ";
|
703 |
s << Tr.at<float>(j,k) << " ";
|
681 |
}
|
704 |
}
|
682 |
s << std::endl;
|
705 |
s << std::endl;
|
683 |
}
|
706 |
}
|
684 |
}
|
707 |
}
|
685 |
}
|
708 |
}
|
686 |
s << "0" << std::flush;
|
709 |
s << "0" << std::flush;
|
687 |
s.close();
|
710 |
s.close();
|
688 |
}
|
711 |
}
|
689 |
|
712 |
|
690 |
void SMScanner::on_pointCloudsListWidget_itemChanged(QListWidgetItem *item){
|
713 |
void SMScanner::on_pointCloudsListWidget_itemChanged(QListWidgetItem *item){
|
691 |
|
714 |
|
692 |
int id = item->data(Qt::UserRole).toInt();
|
715 |
int id = item->data(Qt::UserRole).toInt();
|
693 |
assert((int)pointCloudData.size()>id);
|
716 |
// assert((int)pointCloudData.size()>id);
|
694 |
|
717 |
|
695 |
if(item->checkState() == Qt::Checked){
|
718 |
if(item->checkState() == Qt::Checked){
|
696 |
id = std::min(int(pointCloudData.size())-1,std::max(0,id));// clamp range
|
719 |
id = std::min(int(pointCloudData.size())-1,std::max(0,id));// clamp range
|
697 |
ui->pointCloudWidget->addPointCloud(pointCloudData[id], id);
|
720 |
ui->pointCloudWidget->addPointCloud(pointCloudData[id], id);
|
698 |
}
|
721 |
}
|
699 |
else
|
722 |
else
|
700 |
ui->pointCloudWidget->removePointCloud(id);
|
723 |
ui->pointCloudWidget->removePointCloud(id);
|
701 |
|
724 |
|
702 |
}
|
725 |
}
|
703 |
|
726 |
|
704 |
void SMScanner::on_actionExport_Parameters_triggered(){
|
727 |
void SMScanner::on_actionExport_Parameters_triggered(){
|
705 |
|
728 |
|
706 |
QString fileName = QFileDialog::getSaveFileName(this, "Export calibration parameters", QString(), "*.xml");
|
729 |
QString fileName = QFileDialog::getSaveFileName(this, "Export calibration parameters", QString(), "*.xml");
|
707 |
QFileInfo info(fileName);
|
730 |
QFileInfo info(fileName);
|
708 |
QString type = info.suffix();
|
731 |
QString type = info.suffix();
|
709 |
if(type == ""){
|
732 |
if(type == ""){
|
710 |
fileName.append(".xml");
|
733 |
fileName.append(".xml");
|
711 |
}
|
734 |
}
|
712 |
|
735 |
|
713 |
SMCalibrationParameters calibration = settings.value("calibration/parameters").value<SMCalibrationParameters>();
|
736 |
SMCalibrationParameters calibration = settings.value("calibration/parameters").value<SMCalibrationParameters>();
|
714 |
calibration.exportToXML(fileName);
|
737 |
calibration.exportToXML(fileName);
|
715 |
}
|
738 |
}
|
716 |
|
739 |
|
717 |
void SMScanner::on_actionClear_Sequences_triggered(){
|
740 |
void SMScanner::on_actionClear_Sequences_triggered(){
|
718 |
|
741 |
|
719 |
int res = QMessageBox::question(this, "Clear Captured Sequences", "Clear all captured data?", QMessageBox::Ok, QMessageBox::Cancel);
|
742 |
int res = QMessageBox::question(this, "Clear Captured Sequences", "Clear all captured data?", QMessageBox::Ok, QMessageBox::Cancel);
|
720 |
|
743 |
|
721 |
if(res == QMessageBox::Ok){
|
744 |
if(res == QMessageBox::Ok){
|
722 |
captureData.clear();
|
745 |
captureData.clear();
|
723 |
ui->captureTreeWidget->clear();
|
746 |
ui->captureTreeWidget->clear();
|
724 |
lastCaptureId=-1;
|
747 |
lastCaptureId=-1;
|
725 |
}
|
748 |
}
|
726 |
}
|
749 |
}
|
727 |
|
750 |
|
728 |
|
751 |
|
729 |
|
752 |
|
730 |
void SMScanner::on_actionImport_Parameters_triggered(){
|
753 |
void SMScanner::on_actionImport_Parameters_triggered(){
|
731 |
|
754 |
|
732 |
QString fileName = QFileDialog::getOpenFileName(this, "Import calibration parameters", QString(), "*.xml");
|
755 |
QString fileName = QFileDialog::getOpenFileName(this, "Import calibration parameters", QString(), "*.xml");
|
733 |
QFileInfo info(fileName);
|
756 |
QFileInfo info(fileName);
|
734 |
QString type = info.suffix();
|
757 |
QString type = info.suffix();
|
735 |
if(type != "xml"){
|
758 |
if(type != "xml"){
|
736 |
std::cerr << "Error: calibration parameters must be in .xml file." << std::endl;
|
759 |
std::cerr << "Error: calibration parameters must be in .xml file." << std::endl;
|
737 |
return;
|
760 |
return;
|
738 |
}
|
761 |
}
|
739 |
|
762 |
|
740 |
SMCalibrationParameters cal;
|
763 |
SMCalibrationParameters cal;
|
741 |
cal.importFromXML(fileName);
|
764 |
cal.importFromXML(fileName);
|
742 |
|
765 |
|
743 |
settings.setValue("calibration/parameters", QVariant::fromValue(cal));
|
766 |
settings.setValue("calibration/parameters", QVariant::fromValue(cal));
|
744 |
ui->pointCloudWidget->updateCalibrationParameters();
|
767 |
ui->pointCloudWidget->updateCalibrationParameters();
|
745 |
|
768 |
|
746 |
std::cout << "Imported calibration parameters " << fileName.toStdString() << std::endl;
|
769 |
std::cout << "Imported calibration parameters " << fileName.toStdString() << std::endl;
|
747 |
}
|
770 |
}
|
748 |
|
771 |
|
749 |
void SMScanner::on_actionImport_Sets_triggered(){
|
772 |
void SMScanner::on_actionImport_Sets_triggered(){
|
750 |
|
773 |
|
751 |
QString dirName = QFileDialog::getExistingDirectory(this, "Import calibration sets", QString());
|
774 |
QString dirName = QFileDialog::getExistingDirectory(this, "Import calibration sets", QString());
|
752 |
|
775 |
|
753 |
QDir dir(dirName);
|
776 |
QDir dir(dirName);
|
754 |
QStringList fileNames0 = dir.entryList(QStringList("frame0_*.png"));
|
777 |
QStringList fileNames0 = dir.entryList(QStringList("frame0_*.png"));
|
755 |
QStringList fileNames1 = dir.entryList(QStringList("frame1_*.png"));
|
778 |
QStringList fileNames1 = dir.entryList(QStringList("frame1_*.png"));
|
756 |
|
779 |
|
757 |
if(fileNames0.empty() || fileNames1.empty() || fileNames0.count() != fileNames1.count()){
|
780 |
if(fileNames0.empty() || fileNames1.empty() || fileNames0.count() != fileNames1.count()){
|
758 |
std::cerr << "Error: could not load calibration sets. Directory must contain .png files for both cameras." << std::endl;
|
781 |
std::cerr << "Error: could not load calibration sets. Directory must contain .png files for both cameras." << std::endl;
|
759 |
return;
|
782 |
return;
|
760 |
}
|
783 |
}
|
761 |
|
784 |
|
762 |
calibrationData.clear();
|
785 |
calibrationData.clear();
|
763 |
ui->calibrationListWidget->clear();
|
786 |
ui->calibrationListWidget->clear();
|
764 |
|
787 |
|
765 |
QProgressDialog progressDialog("Importing Sets...", "Cancel", 0, 100, this);
|
788 |
QProgressDialog progressDialog("Importing Sets...", "Cancel", 0, 100, this);
|
766 |
progressDialog.setWindowModality(Qt::WindowModal);
|
789 |
progressDialog.setWindowModality(Qt::WindowModal);
|
767 |
progressDialog.setMinimumDuration(1000);
|
790 |
progressDialog.setMinimumDuration(1000);
|
768 |
|
791 |
|
769 |
size_t nSets = fileNames0.size();
|
792 |
size_t nSets = fileNames0.size();
|
770 |
for(unsigned int i=0; i<nSets; i++){
|
793 |
for(unsigned int i=0; i<nSets; i++){
|
771 |
|
794 |
|
772 |
progressDialog.setValue(100.0*i/nSets);
|
795 |
progressDialog.setValue(100.0*i/nSets);
|
773 |
|
796 |
|
774 |
SMCalibrationSet calibrationSet;
|
797 |
SMCalibrationSet calibrationSet;
|
775 |
|
798 |
|
776 |
QString fileName0 = QString("%1/frame0_%2.png").arg(dirName).arg(i);
|
799 |
QString fileName0 = QString("%1/frame0_%2.png").arg(dirName).arg(i);
|
777 |
cv::Mat frame0BGR = cv::imread(fileName0.toStdString());
|
800 |
cv::Mat frame0BGR = cv::imread(fileName0.toStdString());
|
778 |
cvtools::cvtColorBGRToBayerBG(frame0BGR, calibrationSet.frame0);
|
801 |
cvtools::cvtColorBGRToBayerBG(frame0BGR, calibrationSet.frame0);
|
779 |
|
802 |
|
780 |
QString fileName1 = QString("%1/frame1_%2.png").arg(dirName).arg(i);
|
803 |
QString fileName1 = QString("%1/frame1_%2.png").arg(dirName).arg(i);
|
781 |
cv::Mat frame1BGR = cv::imread(fileName1.toStdString());
|
804 |
cv::Mat frame1BGR = cv::imread(fileName1.toStdString());
|
782 |
cvtools::cvtColorBGRToBayerBG(frame1BGR, calibrationSet.frame1);
|
805 |
cvtools::cvtColorBGRToBayerBG(frame1BGR, calibrationSet.frame1);
|
783 |
|
806 |
|
784 |
// int id = ui->calibrationListWidget->count();
|
807 |
// int id = ui->calibrationListWidget->count();
|
785 |
// calibrationSet.id = id;
|
808 |
// calibrationSet.id = id;
|
786 |
|
809 |
|
787 |
// calibrationData.push_back(calibrationSet);
|
810 |
// calibrationData.push_back(calibrationSet);
|
788 |
|
811 |
|
789 |
// // Add identifier to list
|
812 |
// // Add identifier to list
|
790 |
// QListWidgetItem* item = new QListWidgetItem(QString("Calibration Set %1 -- %2 deg").arg(id).arg(calibrationSet.rotationAngle), ui->calibrationListWidget);
|
813 |
// QListWidgetItem* item = new QListWidgetItem(QString("Calibration Set %1 -- %2 deg").arg(id).arg(calibrationSet.rotationAngle), ui->calibrationListWidget);
|
791 |
// item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
814 |
// item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
792 |
// item->setCheckState(Qt::Checked);
|
815 |
// item->setCheckState(Qt::Checked);
|
793 |
// ui->calibrationListWidget->addItem(item);
|
816 |
// ui->calibrationListWidget->addItem(item);
|
794 |
|
817 |
|
795 |
this->onReceiveCalibrationSet(calibrationSet);
|
818 |
this->onReceiveCalibrationSet(calibrationSet);
|
796 |
|
819 |
|
797 |
QCoreApplication::processEvents();
|
820 |
QCoreApplication::processEvents();
|
798 |
if(progressDialog.wasCanceled())
|
821 |
if(progressDialog.wasCanceled())
|
799 |
return;
|
822 |
return;
|
800 |
}
|
823 |
}
|
801 |
|
824 |
|
802 |
// Set enabled checkmark
|
825 |
// Set enabled checkmark
|
803 |
if(calibrationData.size() >= 2){
|
826 |
if(calibrationData.size() >= 2){
|
804 |
ui->calibrateCamerasButton->setEnabled(true);
|
827 |
ui->calibrateCamerasButton->setEnabled(true);
|
805 |
ui->calibrateRotationStageButton->setEnabled(true);
|
828 |
ui->calibrateRotationStageButton->setEnabled(true);
|
806 |
}
|
829 |
}
|
807 |
}
|
830 |
}
|
808 |
|
831 |
|
809 |
void SMScanner::on_actionImport_Sequences_triggered(){
|
832 |
void SMScanner::on_actionImport_Sequences_triggered(){
|
810 |
|
833 |
|
811 |
// NOTE: we do not know which algorithm was used!!!
|
834 |
// NOTE: we do not know which algorithm was used!!!
|
812 |
|
835 |
|
813 |
QString dirName = QFileDialog::getExistingDirectory(this, "Import captured sequences", QString());
|
836 |
QString dirName = QFileDialog::getExistingDirectory(this, "Import captured sequences", QString());
|
814 |
|
837 |
|
815 |
QDir dir(dirName);
|
838 |
QDir dir(dirName);
|
816 |
QStringList sequenceDirNames = dir.entryList(QStringList("sequence_*"));
|
839 |
QStringList sequenceDirNames = dir.entryList(QStringList("sequence_*"));
|
817 |
|
840 |
|
818 |
//If we have more than 10 sequences, natural sorting is needed as no leading zeros used in naming
|
841 |
//If we have more than 10 sequences, natural sorting is needed as no leading zeros used in naming
|
819 |
QCollator collator;
|
842 |
QCollator collator;
|
820 |
collator.setNumericMode(true);
|
843 |
collator.setNumericMode(true);
|
821 |
std::sort(sequenceDirNames.begin(), sequenceDirNames.end(), collator);
|
844 |
std::sort(sequenceDirNames.begin(), sequenceDirNames.end(), collator);
|
822 |
|
845 |
|
823 |
if(sequenceDirNames.empty()){
|
846 |
if(sequenceDirNames.empty()){
|
824 |
std::cerr << "Error: could not find sequences." << std::endl;
|
847 |
std::cerr << "Error: could not find sequences." << std::endl;
|
825 |
return;
|
848 |
return;
|
826 |
}
|
849 |
}
|
827 |
|
850 |
|
828 |
captureData.clear();
|
851 |
captureData.clear();
|
829 |
ui->captureTreeWidget->clear();
|
852 |
ui->captureTreeWidget->clear();
|
830 |
lastCaptureId=-1;
|
853 |
lastCaptureId=-1;
|
831 |
|
854 |
|
832 |
QProgressDialog progressDialog("Importing Sequences...", "Cancel", 0, 100, this);
|
855 |
QProgressDialog progressDialog("Importing Sequences...", "Cancel", 0, 100, this);
|
833 |
progressDialog.setWindowModality(Qt::WindowModal);
|
856 |
progressDialog.setWindowModality(Qt::WindowModal);
|
834 |
progressDialog.setMinimumDuration(1000);
|
857 |
progressDialog.setMinimumDuration(1000);
|
835 |
|
858 |
|
836 |
for(int s=0; s<sequenceDirNames.count(); s++){
|
859 |
for(int s=0; s<sequenceDirNames.count(); s++){
|
837 |
|
860 |
|
838 |
QDir sequenceDir(QString("%1/%2").arg(dirName).arg(sequenceDirNames.at(s)));
|
861 |
QDir sequenceDir(QString("%1/%2").arg(dirName).arg(sequenceDirNames.at(s)));
|
839 |
|
862 |
|
840 |
QStringList fileNames0 = sequenceDir.entryList(QStringList("frames0_*.png"));
|
863 |
QStringList fileNames0 = sequenceDir.entryList(QStringList("frames0_*.png"));
|
841 |
QStringList fileNames1 = sequenceDir.entryList(QStringList("frames1_*.png"));
|
864 |
QStringList fileNames1 = sequenceDir.entryList(QStringList("frames1_*.png"));
|
842 |
|
865 |
|
843 |
if(fileNames0.empty() || fileNames1.empty() || fileNames0.count() != fileNames1.count()){
|
866 |
if(fileNames0.empty() || fileNames1.empty() || fileNames0.count() != fileNames1.count()){
|
844 |
std::cerr << "Error: could not load sequence. Directory must contain .png files for both cameras." << std::endl;
|
867 |
std::cerr << "Error: could not load sequence. Directory must contain .png files for both cameras." << std::endl;
|
845 |
return;
|
868 |
return;
|
846 |
}
|
869 |
}
|
847 |
|
870 |
|
848 |
int nFrames = fileNames0.size();
|
871 |
int nFrames = fileNames0.size();
|
849 |
|
872 |
|
850 |
SMFrameSequence sequence;
|
873 |
SMFrameSequence sequence;
|
851 |
|
874 |
|
852 |
for(int f=0; f<nFrames; f++){
|
875 |
for(int f=0; f<nFrames; f++){
|
853 |
|
876 |
|
854 |
progressDialog.setValue(100.0*s/sequenceDirNames.count() + 100.0/sequenceDirNames.count()*f/nFrames);
|
877 |
progressDialog.setValue(100.0*s/sequenceDirNames.count() + 100.0/sequenceDirNames.count()*f/nFrames);
|
855 |
|
878 |
|
856 |
cv::Mat frame0BGR, frame0BayerBG, frame1BGR, frame1BayerBG;
|
879 |
cv::Mat frame0BGR, frame0BayerBG, frame1BGR, frame1BayerBG;
|
857 |
|
880 |
|
858 |
QString fileName0 = QString("%1/%2/frames0_%3.png").arg(dirName).arg(sequenceDirNames.at(s)).arg(f);
|
881 |
QString fileName0 = QString("%1/%2/frames0_%3.png").arg(dirName).arg(sequenceDirNames.at(s)).arg(f);
|
859 |
frame0BGR = cv::imread(fileName0.toStdString());
|
882 |
frame0BGR = cv::imread(fileName0.toStdString());
|
860 |
cvtools::cvtColorBGRToBayerBG(frame0BGR, frame0BayerBG);
|
883 |
cvtools::cvtColorBGRToBayerBG(frame0BGR, frame0BayerBG);
|
861 |
|
884 |
|
862 |
QString fileName1 = QString("%1/%2/frames1_%3.png").arg(dirName).arg(sequenceDirNames.at(s)).arg(f);
|
885 |
QString fileName1 = QString("%1/%2/frames1_%3.png").arg(dirName).arg(sequenceDirNames.at(s)).arg(f);
|
863 |
frame1BGR = cv::imread(fileName1.toStdString());
|
886 |
frame1BGR = cv::imread(fileName1.toStdString());
|
864 |
cvtools::cvtColorBGRToBayerBG(frame1BGR, frame1BayerBG);
|
887 |
cvtools::cvtColorBGRToBayerBG(frame1BGR, frame1BayerBG);
|
865 |
|
888 |
|
866 |
sequence.frames0.push_back(frame0BayerBG);
|
889 |
sequence.frames0.push_back(frame0BayerBG);
|
867 |
sequence.frames1.push_back(frame1BayerBG);
|
890 |
sequence.frames1.push_back(frame1BayerBG);
|
868 |
|
891 |
|
869 |
QCoreApplication::processEvents();
|
892 |
QCoreApplication::processEvents();
|
870 |
if(progressDialog.wasCanceled())
|
893 |
if(progressDialog.wasCanceled())
|
871 |
return;
|
894 |
return;
|
872 |
}
|
895 |
}
|
873 |
|
896 |
|
874 |
// Assign whatever algorithm is configured
|
897 |
// Assign whatever algorithm is configured
|
875 |
sequence.codec = settings.value("algorithm").toString();
|
898 |
sequence.codec = settings.value("algorithm").toString();
|
876 |
sequence.rotationAngle = 0;
|
899 |
sequence.rotationAngle = 0;
|
877 |
sequence.reconstructed = false;
|
900 |
sequence.reconstructed = false;
|
878 |
sequence.shutters.push_back(16.6666);
|
901 |
sequence.shutters.push_back(16.6666);
|
879 |
|
902 |
|
880 |
onReceiveFrameSequence(sequence);
|
903 |
onReceiveFrameSequence(sequence);
|
881 |
}
|
904 |
}
|
882 |
|
905 |
|
883 |
}
|
906 |
}
|
884 |
|
907 |
|
885 |
void SMScanner::on_actionClear_Point_Clouds_triggered(){
|
908 |
void SMScanner::on_actionClear_Point_Clouds_triggered(){
|
886 |
|
909 |
|
887 |
int res = QMessageBox::question(this, "Clear Reconstructed Point Clouds", "Clear all reconstructed point clouds?", QMessageBox::Ok, QMessageBox::Cancel);
|
910 |
int res = QMessageBox::question(this, "Clear Reconstructed Point Clouds", "Clear all reconstructed point clouds?", QMessageBox::Ok, QMessageBox::Cancel);
|
888 |
|
911 |
|
889 |
if(res == QMessageBox::Ok){
|
912 |
if(res == QMessageBox::Ok){
|
890 |
|
913 |
|
891 |
pointCloudData.clear();
|
914 |
pointCloudData.clear();
|
892 |
ui->pointCloudsListWidget->clear();
|
915 |
ui->pointCloudsListWidget->clear();
|
893 |
ui->pointCloudWidget->removeAllPointClouds();
|
916 |
ui->pointCloudWidget->removeAllPointClouds();
|
894 |
|
917 |
|
895 |
for(unsigned int i=0; i<captureData.size(); i++)
|
918 |
for(unsigned int i=0; i<captureData.size(); i++)
|
896 |
captureData[i].reconstructed = false;
|
919 |
captureData[i].reconstructed = false;
|
897 |
}
|
920 |
}
|
898 |
}
|
921 |
}
|
899 |
|
922 |
|
900 |
|
923 |
|
901 |
void SMScanner::on_actionProject_Focusing_Pattern_triggered(){
|
924 |
void SMScanner::on_actionProject_Focusing_Pattern_triggered(){
|
902 |
|
925 |
|
903 |
bool projectFocusingPattern = ui->actionProject_Focusing_Pattern->isChecked();
|
926 |
bool projectFocusingPattern = ui->actionProject_Focusing_Pattern->isChecked();
|
904 |
QMetaObject::invokeMethod(captureWorker, "setProjectFocusingPattern", Q_ARG(bool, projectFocusingPattern));
|
927 |
QMetaObject::invokeMethod(captureWorker, "setProjectFocusingPattern", Q_ARG(bool, projectFocusingPattern));
|
905 |
|
928 |
|
906 |
}
|
929 |
}
|
907 |
|
930 |
|
908 |
void SMScanner::on_calibrateRotationStageButton_clicked(){
|
931 |
void SMScanner::on_calibrateRotationStageButton_clicked(){
|
909 |
|
932 |
|
910 |
// disable ui elements
|
933 |
// disable ui elements
|
911 |
ui->calibrateCamerasButton->setEnabled(false);
|
934 |
ui->calibrateCamerasButton->setEnabled(false);
|
912 |
ui->calibrateRotationStageButton->setEnabled(false);
|
935 |
ui->calibrateRotationStageButton->setEnabled(false);
|
913 |
ui->calibrationFrame->setEnabled(false);
|
936 |
ui->calibrationFrame->setEnabled(false);
|
914 |
|
937 |
|
915 |
// if none items are selected, we will use all available items
|
938 |
// if none items are selected, we will use all available items
|
916 |
if(ui->calibrationListWidget->selectedItems().empty())
|
939 |
if(ui->calibrationListWidget->selectedItems().empty())
|
917 |
ui->calibrationListWidget->selectAll();
|
940 |
ui->calibrationListWidget->selectAll();
|
918 |
|
941 |
|
919 |
// set selected flags
|
942 |
// set selected flags
|
920 |
for(unsigned int i=0; i<calibrationData.size(); i++){
|
943 |
for(unsigned int i=0; i<calibrationData.size(); i++){
|
921 |
if(ui->calibrationListWidget->item(i)->isSelected())
|
944 |
if(ui->calibrationListWidget->item(i)->isSelected())
|
922 |
calibrationData[i].selected = true;
|
945 |
calibrationData[i].selected = true;
|
923 |
else
|
946 |
else
|
924 |
calibrationData[i].selected = false;
|
947 |
calibrationData[i].selected = false;
|
925 |
}
|
948 |
}
|
926 |
|
949 |
|
927 |
logDialog.show();
|
950 |
logDialog.show();
|
928 |
logDialog.activateWindow();
|
951 |
logDialog.activateWindow();
|
929 |
|
952 |
|
930 |
// start calibration
|
953 |
// start calibration
|
931 |
QMetaObject::invokeMethod(calibrationWorker, "rotationStageCalibration", Q_ARG(std::vector<SMCalibrationSet>, calibrationData));
|
954 |
QMetaObject::invokeMethod(calibrationWorker, "rotationStageCalibration", Q_ARG(std::vector<SMCalibrationSet>, calibrationData));
|
932 |
|
955 |
|
933 |
}
|
956 |
}
|
934 |
|
957 |
|
935 |
|
958 |
|
936 |
void SMScanner::on_actionView_Log_Messages_triggered()
|
959 |
void SMScanner::on_actionView_Log_Messages_triggered()
|
937 |
{
|
960 |
{
|
938 |
logDialog.show();
|
961 |
logDialog.show();
|
939 |
logDialog.activateWindow();
|
962 |
logDialog.activateWindow();
|
940 |
}
|
963 |
}
|
941 |
|
964 |
|
942 |
void SMScanner::on_tabWidget_currentChanged(int index)
|
965 |
void SMScanner::on_tabWidget_currentChanged(int index)
|
943 |
{
|
966 |
{
|
944 |
if(index==0){
|
967 |
if(index==0){
|
945 |
ui->calibrationCamera0Widget->fitImage();
|
968 |
ui->calibrationCamera0Widget->fitImage();
|
946 |
ui->calibrationCamera1Widget->fitImage();
|
969 |
ui->calibrationCamera1Widget->fitImage();
|
947 |
}
|
970 |
}
|
948 |
if(index==1){
|
971 |
if(index==1){
|
949 |
ui->captureCamera0Widget->fitImage();
|
972 |
ui->captureCamera0Widget->fitImage();
|
950 |
ui->captureCamera1Widget->fitImage();
|
973 |
ui->captureCamera1Widget->fitImage();
|
951 |
}
|
974 |
}
|
952 |
}
|
975 |
}
|
953 |
|
976 |
|
954 |
void SMScanner::on_calibrationListWidget_currentRowChanged(int currentRow)
|
977 |
void SMScanner::on_calibrationListWidget_currentRowChanged(int currentRow)
|
955 |
{
|
978 |
{
|
956 |
std::cout << "Current row: " << currentRow << std::endl;
|
979 |
std::cout << "Current row: " << currentRow << std::endl;
|
957 |
on_calibrationListWidget_itemSelectionChanged();
|
980 |
on_calibrationListWidget_itemSelectionChanged();
|
958 |
}
|
981 |
}
|
959 |
|
982 |
|
960 |
void SMScanner::on_actionEdit_Configuration_File_triggered()
|
983 |
void SMScanner::on_actionEdit_Configuration_File_triggered()
|
961 |
{
|
984 |
{
|
962 |
QDesktopServices::openUrl(QUrl::fromLocalFile(settings.fileName()));
|
985 |
QDesktopServices::openUrl(QUrl::fromLocalFile(settings.fileName()));
|
963 |
}
|
986 |
}
|
- |
|
987 |
|
- |
|
988 |
void SMScanner::on_exportCheckBox_toggled(bool checked)
|
- |
|
989 |
{
|
- |
|
990 |
ui->exportPathLineEdit->setEnabled(checked);
|
- |
|
991 |
ui->browseExportPushButton->setEnabled(checked);
|
- |
|
992 |
ui->exportedPathLabel->setEnabled(checked);
|
- |
|
993 |
ui->deleteExportCheckBox->setEnabled(checked);
|
- |
|
994 |
}
|
- |
|
995 |
|
- |
|
996 |
void SMScanner::on_browseExportPushButton_clicked()
|
- |
|
997 |
{
|
- |
|
998 |
QString dirName = QFileDialog::getExistingDirectory(this, "Export frame sequences", QString());
|
- |
|
999 |
ui->exportPathLineEdit->setText(dirName);
|
- |
|
1000 |
}
|
964 |
|
1001 |
|