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