more messaging for user, reduce writer waiting time
This commit is contained in:
parent
519b84064e
commit
8b80bf11d9
@ -18,6 +18,5 @@ void Grabber::run() {
|
|||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
cam->StopGrabbing();
|
cam->StopGrabbing();
|
||||||
std::cerr << "terminated: " << count << std::endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,8 @@ PylonRecorder::PylonRecorder(QWidget *parent)
|
|||||||
connect(frameTimer, &QTimer::timeout, this, &PylonRecorder::displaySingleFrame);
|
connect(frameTimer, &QTimer::timeout, this, &PylonRecorder::displaySingleFrame);
|
||||||
preassureTimer = new QTimer(this);
|
preassureTimer = new QTimer(this);
|
||||||
connect(preassureTimer, &QTimer::timeout, this, &PylonRecorder::displayBufferPreassure);
|
connect(preassureTimer, &QTimer::timeout, this, &PylonRecorder::displayBufferPreassure);
|
||||||
|
labelTimer = new QTimer(this);
|
||||||
|
connect(labelTimer, &QTimer::timeout, this, &PylonRecorder::displayActivity);
|
||||||
|
|
||||||
preassureBar = new QProgressBar(this);
|
preassureBar = new QProgressBar(this);
|
||||||
preassureBar->setRange(0, 100);
|
preassureBar->setRange(0, 100);
|
||||||
@ -68,10 +70,23 @@ PylonRecorder::PylonRecorder(QWidget *parent)
|
|||||||
loadBar->setRange(0, 1000);
|
loadBar->setRange(0, 1000);
|
||||||
QLabel *loadLabel = new QLabel("Load:", this);
|
QLabel *loadLabel = new QLabel("Load:", this);
|
||||||
|
|
||||||
|
writingLabel = new QLabel("writing");
|
||||||
|
//writingLabel->setStyleSheet("QLabel { color : gray; }");
|
||||||
|
writingLabel->setEnabled(false);
|
||||||
|
grabbingLabel = new QLabel("grabbing");
|
||||||
|
//grabbingLabel->setStyleSheet("QLabel { color : gray; }");
|
||||||
|
grabbingLabel->setEnabled(false);
|
||||||
|
labelSwitch = false;
|
||||||
|
cameraConnectedLabel = new QLabel("disconnected");
|
||||||
|
|
||||||
|
statusBar()->addWidget(new QLabel("Camera:"));
|
||||||
|
statusBar()->addWidget(cameraConnectedLabel);
|
||||||
statusBar()->addWidget(preassureLabel);
|
statusBar()->addWidget(preassureLabel);
|
||||||
statusBar()->addWidget(preassureBar);
|
statusBar()->addWidget(preassureBar);
|
||||||
statusBar()->addWidget(loadLabel);
|
statusBar()->addWidget(loadLabel);
|
||||||
statusBar()->addWidget(loadBar);
|
statusBar()->addWidget(loadBar);
|
||||||
|
statusBar()->addWidget(grabbingLabel);
|
||||||
|
statusBar()->addWidget(writingLabel);
|
||||||
|
|
||||||
resize(QGuiApplication::primaryScreen()->availableSize() * 3 / 5);
|
resize(QGuiApplication::primaryScreen()->availableSize() * 3 / 5);
|
||||||
}
|
}
|
||||||
@ -384,7 +399,11 @@ void PylonRecorder::adjustScrollBar(QScrollBar *scrollBar, double factor) {
|
|||||||
|
|
||||||
void PylonRecorder::connectCamera() {
|
void PylonRecorder::connectCamera() {
|
||||||
std::string message;
|
std::string message;
|
||||||
pylon->openCamera(message);
|
bool success = pylon->openCamera(message);
|
||||||
|
if (success) {
|
||||||
|
cameraConnectedLabel->setText("connected");
|
||||||
|
cameraConnectedLabel->setStyleSheet("QLabel { color : green; }");
|
||||||
|
}
|
||||||
statusBar()->showMessage(QString::fromStdString(message));
|
statusBar()->showMessage(QString::fromStdString(message));
|
||||||
updateActions();
|
updateActions();
|
||||||
}
|
}
|
||||||
@ -392,6 +411,8 @@ void PylonRecorder::connectCamera() {
|
|||||||
void PylonRecorder::disconnectCamera() {
|
void PylonRecorder::disconnectCamera() {
|
||||||
pylon->closeCamera();
|
pylon->closeCamera();
|
||||||
statusBar()->showMessage(tr("Camera closed!"));
|
statusBar()->showMessage(tr("Camera closed!"));
|
||||||
|
cameraConnectedLabel->setText("disconnected");
|
||||||
|
cameraConnectedLabel->setStyleSheet("QLabel { color : black; }");
|
||||||
updateActions();
|
updateActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -410,29 +431,44 @@ void PylonRecorder::startRecording() {
|
|||||||
grabber->start();
|
grabber->start();
|
||||||
writer->start();
|
writer->start();
|
||||||
grabbing = true;
|
grabbing = true;
|
||||||
|
writing = true;
|
||||||
|
stopRequest = false;
|
||||||
|
|
||||||
preassureTimer->start(50);
|
preassureTimer->start(50);
|
||||||
frameTimer->start(50);
|
frameTimer->start(50);
|
||||||
|
labelTimer->start(333);
|
||||||
updateActions();
|
updateActions();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PylonRecorder::stopRecording() {
|
void PylonRecorder::stopRecording() {
|
||||||
frameTimer->stop();
|
if (!stopRequest) {
|
||||||
grabber->requestStop();
|
frameTimer->stop();
|
||||||
writer->requestStop();
|
grabber->requestStop();
|
||||||
|
writer->requestStop();
|
||||||
|
grabbing = false;
|
||||||
|
stopRequest = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PylonRecorder::writerDone() {
|
void PylonRecorder::writerDone() {
|
||||||
preassureTimer->stop();
|
preassureTimer->stop();
|
||||||
preassureBar->reset();
|
preassureBar->reset();
|
||||||
loadBar->reset();
|
loadBar->reset();
|
||||||
|
labelTimer->stop();
|
||||||
|
writingLabel->setEnabled(false);
|
||||||
|
grabbingLabel->setEnabled(false);
|
||||||
grabber->wait(10000);
|
grabber->wait(10000);
|
||||||
writer->wait(10000);
|
writer->wait(10000);
|
||||||
grabbing = false;
|
writing = false;
|
||||||
updateActions();
|
updateActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PylonRecorder::displayActivity() {
|
||||||
|
grabbingLabel->setEnabled(labelSwitch && grabbing);
|
||||||
|
writingLabel->setEnabled(labelSwitch && writing);
|
||||||
|
labelSwitch = !labelSwitch;
|
||||||
|
}
|
||||||
void PylonRecorder::displaySingleFrame() {
|
void PylonRecorder::displaySingleFrame() {
|
||||||
MyImage img;
|
MyImage img;
|
||||||
bool valid = buffer->readLast(img);
|
bool valid = buffer->readLast(img);
|
||||||
|
@ -56,6 +56,7 @@ private slots:
|
|||||||
void quitApplication();
|
void quitApplication();
|
||||||
void displaySingleFrame();
|
void displaySingleFrame();
|
||||||
void displayBufferPreassure();
|
void displayBufferPreassure();
|
||||||
|
void displayActivity();
|
||||||
void writerDone();
|
void writerDone();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -71,9 +72,8 @@ private:
|
|||||||
void adjustScrollBar(QScrollBar *scrollBar, double factor);
|
void adjustScrollBar(QScrollBar *scrollBar, double factor);
|
||||||
|
|
||||||
QImage image;
|
QImage image;
|
||||||
QTimer *frameTimer;
|
QTimer *frameTimer, *preassureTimer, *labelTimer;
|
||||||
QTimer *preassureTimer;
|
QLabel *imageLabel, *writingLabel, *grabbingLabel, *cameraConnectedLabel;
|
||||||
QLabel *imageLabel;
|
|
||||||
QProgressBar *preassureBar;
|
QProgressBar *preassureBar;
|
||||||
QProgressBar *loadBar;
|
QProgressBar *loadBar;
|
||||||
QScrollArea *scrollArea;
|
QScrollArea *scrollArea;
|
||||||
@ -82,7 +82,7 @@ private:
|
|||||||
ImageBuffer *buffer;
|
ImageBuffer *buffer;
|
||||||
Grabber *grabber;
|
Grabber *grabber;
|
||||||
Writer *writer;
|
Writer *writer;
|
||||||
bool grabbing;
|
bool grabbing, stopRequest, writing, labelSwitch;
|
||||||
QPalette progressPalette;
|
QPalette progressPalette;
|
||||||
|
|
||||||
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer)
|
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer)
|
||||||
|
@ -28,14 +28,12 @@ void Writer::run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while (buffer->bufferLoad() < 5 && !stop_request) {
|
while (buffer->bufferLoad() < 1 && !stop_request) {
|
||||||
msleep(10);
|
msleep(10);
|
||||||
std::cerr << "waiting.." << buffer->bufferLoad() << std::endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
videoWriter.Close();
|
videoWriter.Close();
|
||||||
std::cerr << "writer terminated: " << count << std::endl;
|
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "Got no video specifications, not writing!" << std::endl;
|
std::cerr << "Got no video specifications, not writing!" << std::endl;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user