fixed load meter during saving, writer emits signal when done
This commit is contained in:
parent
6a0570666e
commit
519b84064e
@ -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<size_t>(current_read_index)];
|
||||
static_cast<size_t>(current_read_index) < (buffer.capacity() - 1) ? current_read_index += 1 : current_read_index = 0;
|
||||
load -= 1;
|
||||
|
BIN
images/exit.png
BIN
images/exit.png
Binary file not shown.
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.0 KiB |
@ -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<int>(buffer->bufferLoad());
|
||||
loadBar->setValue(load);
|
||||
}
|
||||
|
||||
void PylonRecorder::grabStillFromPylon() {
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
|
7
writer.h
7
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
|
||||
|
Loading…
Reference in New Issue
Block a user