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;
|
bool ret = false;
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
if (load > 0) {
|
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)];
|
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;
|
static_cast<size_t>(current_read_index) < (buffer.capacity() - 1) ? current_read_index += 1 : current_read_index = 0;
|
||||||
load -= 1;
|
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->setWidget(imageLabel);
|
||||||
scrollArea->setVisible(false);
|
scrollArea->setVisible(false);
|
||||||
setCentralWidget(scrollArea);
|
setCentralWidget(scrollArea);
|
||||||
|
|
||||||
pylon = new PylonWrapper();
|
pylon = new PylonWrapper();
|
||||||
buffer = new ImageBuffer(1000);
|
buffer = new ImageBuffer(1000);
|
||||||
grabber = new Grabber(pylon, buffer);
|
grabber = new Grabber(pylon, buffer);
|
||||||
writer = new Writer(buffer);
|
writer = new Writer(buffer);
|
||||||
|
connect(writer, &Writer::writingDone, this, &PylonRecorder::writerDone);
|
||||||
|
|
||||||
createActions();
|
createActions();
|
||||||
updateActions();
|
updateActions();
|
||||||
|
|
||||||
@ -61,8 +64,15 @@ PylonRecorder::PylonRecorder(QWidget *parent)
|
|||||||
preassureBar->setPalette(progressPalette);
|
preassureBar->setPalette(progressPalette);
|
||||||
QLabel *preassureLabel = new QLabel("Buffer preassure:", this);
|
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(preassureLabel);
|
||||||
statusBar()->addWidget(preassureBar);
|
statusBar()->addWidget(preassureBar);
|
||||||
|
statusBar()->addWidget(loadLabel);
|
||||||
|
statusBar()->addWidget(loadBar);
|
||||||
|
|
||||||
resize(QGuiApplication::primaryScreen()->availableSize() * 3 / 5);
|
resize(QGuiApplication::primaryScreen()->availableSize() * 3 / 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -408,14 +418,18 @@ void PylonRecorder::startRecording() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PylonRecorder::stopRecording() {
|
void PylonRecorder::stopRecording() {
|
||||||
|
frameTimer->stop();
|
||||||
grabber->requestStop();
|
grabber->requestStop();
|
||||||
writer->requestStop();
|
writer->requestStop();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PylonRecorder::writerDone() {
|
||||||
|
preassureTimer->stop();
|
||||||
|
preassureBar->reset();
|
||||||
|
loadBar->reset();
|
||||||
grabber->wait(10000);
|
grabber->wait(10000);
|
||||||
writer->wait(10000);
|
writer->wait(10000);
|
||||||
grabbing = false;
|
grabbing = false;
|
||||||
frameTimer->stop();
|
|
||||||
preassureTimer->stop();
|
|
||||||
preassureBar->reset();
|
|
||||||
updateActions();
|
updateActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -448,6 +462,9 @@ void PylonRecorder::displayBufferPreassure() {
|
|||||||
QColor color = progressColor(value);
|
QColor color = progressColor(value);
|
||||||
progressPalette.setBrush(QPalette::Highlight, QBrush(color));
|
progressPalette.setBrush(QPalette::Highlight, QBrush(color));
|
||||||
preassureBar->setPalette(progressPalette);
|
preassureBar->setPalette(progressPalette);
|
||||||
|
|
||||||
|
int load = static_cast<int>(buffer->bufferLoad());
|
||||||
|
loadBar->setValue(load);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PylonRecorder::grabStillFromPylon() {
|
void PylonRecorder::grabStillFromPylon() {
|
||||||
|
@ -56,6 +56,7 @@ private slots:
|
|||||||
void quitApplication();
|
void quitApplication();
|
||||||
void displaySingleFrame();
|
void displaySingleFrame();
|
||||||
void displayBufferPreassure();
|
void displayBufferPreassure();
|
||||||
|
void writerDone();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createActions();
|
void createActions();
|
||||||
@ -74,6 +75,7 @@ private:
|
|||||||
QTimer *preassureTimer;
|
QTimer *preassureTimer;
|
||||||
QLabel *imageLabel;
|
QLabel *imageLabel;
|
||||||
QProgressBar *preassureBar;
|
QProgressBar *preassureBar;
|
||||||
|
QProgressBar *loadBar;
|
||||||
QScrollArea *scrollArea;
|
QScrollArea *scrollArea;
|
||||||
double scaleFactor = 1;
|
double scaleFactor = 1;
|
||||||
PylonWrapper *pylon;
|
PylonWrapper *pylon;
|
||||||
|
@ -6,6 +6,7 @@ void Writer::setVideoSpecs(VideoSpecs specs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Writer::run() {
|
void Writer::run() {
|
||||||
|
int64_t count = 0;
|
||||||
if (valid) {
|
if (valid) {
|
||||||
stop_request = false;
|
stop_request = false;
|
||||||
Pylon::CVideoWriter videoWriter;
|
Pylon::CVideoWriter videoWriter;
|
||||||
@ -13,9 +14,7 @@ void Writer::run() {
|
|||||||
videoSpecs.fps, videoSpecs.quality);
|
videoSpecs.fps, videoSpecs.quality);
|
||||||
videoWriter.Open(videoSpecs.filename.c_str());
|
videoWriter.Open(videoSpecs.filename.c_str());
|
||||||
MyImage img;
|
MyImage img;
|
||||||
int64_t count = 0;
|
|
||||||
while (!stop_request || buffer->bufferLoad() > 0) {
|
while (!stop_request || buffer->bufferLoad() > 0) {
|
||||||
std::cerr << "running!\n";
|
|
||||||
if (buffer->bufferLoad() > 0 ) {
|
if (buffer->bufferLoad() > 0 ) {
|
||||||
bool valid = buffer->pop(img);
|
bool valid = buffer->pop(img);
|
||||||
if (valid) {
|
if (valid) {
|
||||||
@ -40,4 +39,5 @@ void Writer::run() {
|
|||||||
} else {
|
} else {
|
||||||
std::cerr << "Got no video specifications, not writing!" << std::endl;
|
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 run() override;
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void terminated();
|
||||||
|
void writingDone();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ImageBuffer *buffer;
|
ImageBuffer *buffer;
|
||||||
VideoSpecs videoSpecs;
|
VideoSpecs videoSpecs;
|
||||||
@ -36,9 +40,6 @@ public slots:
|
|||||||
void requestStop() {
|
void requestStop() {
|
||||||
stop_request=true;
|
stop_request=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
signals:
|
|
||||||
void terminated();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WRITER_H
|
#endif // WRITER_H
|
||||||
|
Loading…
Reference in New Issue
Block a user