Commit 0a05db5f authored by Thiago Santini's avatar Thiago Santini

Handles monocular recordings playback

parent d3796708
...@@ -557,10 +557,21 @@ void PostProcessingWidget::startPlayback(QFileInfo& info) ...@@ -557,10 +557,21 @@ void PostProcessingWidget::startPlayback(QFileInfo& info)
ui->playbackSlider->setMaximum(videoSource->getFrameCount()); ui->playbackSlider->setMaximum(videoSource->getFrameCount());
ui->playbackSlider->setValue(0); ui->playbackSlider->setValue(0);
leftEyeVideoSource = new VideoSource(); auto openVideo = [&](const QFileInfo &info) {
leftEyeVideoSource->init(leftEyeInfo.absoluteFilePath(), findAssociatedDataFile(dir, leftEyeInfo)); VideoSource *vs = nullptr;
rightEyeVideoSource = new VideoSource(); if (info.exists() && info.isFile()) {
rightEyeVideoSource->init(rightEyeInfo.absoluteFilePath(), findAssociatedDataFile(dir, rightEyeInfo)); vs = new VideoSource();
vs->init(info.absoluteFilePath(), findAssociatedDataFile(dir, info));
if (!vs->isReady()) {
vs->deleteLater();
vs = nullptr;
}
}
return vs;
};
leftEyeVideoSource = openVideo(leftEyeInfo);
rightEyeVideoSource = openVideo(rightEyeInfo);
QMetaObject::invokeMethod(videoSource, "play"); QMetaObject::invokeMethod(videoSource, "play");
ui->statusbar->showMessage("Playing..."); ui->statusbar->showMessage("Playing...");
...@@ -600,9 +611,6 @@ void PostProcessingWidget::present(const VideoFrame& videoFrame) ...@@ -600,9 +611,6 @@ void PostProcessingWidget::present(const VideoFrame& videoFrame)
tuple.field.input = videoFrame.frame; tuple.field.input = videoFrame.frame;
if (ui->showEyesCheckBox->isChecked()) { if (ui->showEyesCheckBox->isChecked()) {
tuple.lEye.input = leftEyeVideoSource->getFrameAt(tuple.lEye.timestamp);
tuple.rEye.input = rightEyeVideoSource->getFrameAt(tuple.rEye.timestamp);
// TODO: // TODO:
// temporary solution to get the eye projection, fix later // temporary solution to get the eye projection, fix later
auto projectEye = [](EyeData& ed, float radius = 12) { auto projectEye = [](EyeData& ed, float radius = 12) {
...@@ -613,12 +621,18 @@ void PostProcessingWidget::present(const VideoFrame& videoFrame) ...@@ -613,12 +621,18 @@ void PostProcessingWidget::present(const VideoFrame& videoFrame)
projection.center.y = 0.5 * ed.input.rows + focal_length * center(1) / center(2); projection.center.y = 0.5 * ed.input.rows + focal_length * center(1) / center(2);
projection.size.width = projection.size.height = 2 * focal_length * radius / center(2); projection.size.width = projection.size.height = 2 * focal_length * radius / center(2);
}; };
projectEye(tuple.lEye);
projectEye(tuple.rEye);
if (leftEyeVideoSource && leftEyeVideoSource->isReady()) {
tuple.lEye.input = leftEyeVideoSource->getFrameAt(tuple.lEye.timestamp);
projectEye(tuple.lEye);
emit leftEyePresent(tuple.lEye); emit leftEyePresent(tuple.lEye);
}
if (rightEyeVideoSource && rightEyeVideoSource->isReady()) {
tuple.rEye.input = rightEyeVideoSource->getFrameAt(tuple.rEye.timestamp);
projectEye(tuple.rEye);
emit rightEyePresent(tuple.rEye); emit rightEyePresent(tuple.rEye);
} }
}
emit present(tuple); emit present(tuple);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment