diff --git a/imagebuffer.cpp b/imagebuffer.cpp index af9b3ef..a489e4d 100644 --- a/imagebuffer.cpp +++ b/imagebuffer.cpp @@ -60,7 +60,7 @@ bool ImageBuffer::pop(MyImage &img) { bool ret = false; mutex.lock(); if (load > 0) { - std::cerr << "Buffer.pop, load: " << load << " read_idx: " << current_read_index << " write_idx: " << current_write_index << std::endl; + // std::cerr << "Buffer.pop, load: " << load << " read_idx: " << current_read_index << " write_idx: " << current_write_index << std::endl; img = buffer[static_cast(current_read_index)]; static_cast(current_read_index) < (buffer.capacity() - 1) ? current_read_index += 1 : current_read_index = 0; load -= 1; diff --git a/images/exit.png b/images/exit.png index 74ce708..f66edf3 100644 Binary files a/images/exit.png and b/images/exit.png differ diff --git a/pylonrecorder.cpp b/pylonrecorder.cpp index f10d8c4..940544f 100644 --- a/pylonrecorder.cpp +++ b/pylonrecorder.cpp @@ -40,10 +40,13 @@ PylonRecorder::PylonRecorder(QWidget *parent) scrollArea->setWidget(imageLabel); scrollArea->setVisible(false); setCentralWidget(scrollArea); + pylon = new PylonWrapper(); buffer = new ImageBuffer(1000); grabber = new Grabber(pylon, buffer); writer = new Writer(buffer); + connect(writer, &Writer::writingDone, this, &PylonRecorder::writerDone); + createActions(); updateActions(); @@ -61,8 +64,15 @@ PylonRecorder::PylonRecorder(QWidget *parent) preassureBar->setPalette(progressPalette); QLabel *preassureLabel = new QLabel("Buffer preassure:", this); + loadBar = new QProgressBar(this); + loadBar->setRange(0, 1000); + QLabel *loadLabel = new QLabel("Load:", this); + statusBar()->addWidget(preassureLabel); statusBar()->addWidget(preassureBar); + statusBar()->addWidget(loadLabel); + statusBar()->addWidget(loadBar); + resize(QGuiApplication::primaryScreen()->availableSize() * 3 / 5); } @@ -408,14 +418,18 @@ void PylonRecorder::startRecording() { } void PylonRecorder::stopRecording() { + frameTimer->stop(); grabber->requestStop(); writer->requestStop(); +} + +void PylonRecorder::writerDone() { + preassureTimer->stop(); + preassureBar->reset(); + loadBar->reset(); grabber->wait(10000); writer->wait(10000); grabbing = false; - frameTimer->stop(); - preassureTimer->stop(); - preassureBar->reset(); updateActions(); } @@ -448,6 +462,9 @@ void PylonRecorder::displayBufferPreassure() { QColor color = progressColor(value); progressPalette.setBrush(QPalette::Highlight, QBrush(color)); preassureBar->setPalette(progressPalette); + + int load = static_cast(buffer->bufferLoad()); + loadBar->setValue(load); } void PylonRecorder::grabStillFromPylon() { diff --git a/pylonrecorder.h b/pylonrecorder.h index cf049fa..2a821e8 100644 --- a/pylonrecorder.h +++ b/pylonrecorder.h @@ -56,6 +56,7 @@ private slots: void quitApplication(); void displaySingleFrame(); void displayBufferPreassure(); + void writerDone(); private: void createActions(); @@ -74,6 +75,7 @@ private: QTimer *preassureTimer; QLabel *imageLabel; QProgressBar *preassureBar; + QProgressBar *loadBar; QScrollArea *scrollArea; double scaleFactor = 1; PylonWrapper *pylon; diff --git a/writer.cpp b/writer.cpp index 93918e0..2c23712 100644 --- a/writer.cpp +++ b/writer.cpp @@ -6,6 +6,7 @@ void Writer::setVideoSpecs(VideoSpecs specs) { } void Writer::run() { + int64_t count = 0; if (valid) { stop_request = false; Pylon::CVideoWriter videoWriter; @@ -13,9 +14,7 @@ void Writer::run() { videoSpecs.fps, videoSpecs.quality); videoWriter.Open(videoSpecs.filename.c_str()); MyImage img; - int64_t count = 0; while (!stop_request || buffer->bufferLoad() > 0) { - std::cerr << "running!\n"; if (buffer->bufferLoad() > 0 ) { bool valid = buffer->pop(img); if (valid) { @@ -40,4 +39,5 @@ void Writer::run() { } else { std::cerr << "Got no video specifications, not writing!" << std::endl; } + emit writingDone(); } diff --git a/writer.h b/writer.h index a5e69dd..f87b222 100644 --- a/writer.h +++ b/writer.h @@ -26,6 +26,10 @@ public: void run() override; void stop(); +signals: + void terminated(); + void writingDone(); + private: ImageBuffer *buffer; VideoSpecs videoSpecs; @@ -36,9 +40,6 @@ public slots: void requestStop() { stop_request=true; } - -signals: - void terminated(); }; #endif // WRITER_H