[metadata] store metadata fix nix output bug

This commit is contained in:
Jan Grewe 2021-04-26 18:17:12 +02:00
parent 3e2dfe2b3b
commit b56a6a39d6
3 changed files with 37 additions and 5 deletions

View File

@ -599,6 +599,10 @@ void PylonRecorder::startRecording() {
if (gainSpinner->value() != int(grabber->currentGain()))
grabber->setGain(static_cast<double>(gainSpinner->value()));
writer->setVideoSpecs(specs);
QSettings s;
this->mdata.read(s);
writer->setProjectMetadata(mdata);
buffer->clear();
grabber->start();
if (!dryRunCheckBox->isChecked()) {

View File

@ -1,18 +1,32 @@
#include "writer.h"
#include <nix.hpp>
#include <chrono>
void Writer::setVideoSpecs(VideoSpecs specs) {
videoSpecs = specs;
valid = true;
specs_valid = true;
}
void Writer::setProjectMetadata(ProjectMetadata mdata) {
metadata = mdata;
metadata_valid = true;
}
void Writer::writeMetadata(nix::Section &s){
s.createProperty("project", nix::Value(this->metadata.project().toStdString()));
s.createProperty("experimenter", nix::Value(this->metadata.experimenter().toStdString()));
s.createProperty("experiment", nix::Value(this->metadata.experiment().toStdString()));
s.createProperty("condition", nix::Value(this->metadata.condition().toStdString()));
s.createProperty("comment", nix::Value(this->metadata.comment().toStdString()));
s.createProperty("subject", nix::Value(this->metadata.subject().toStdString()));
s.createProperty("setup", nix::Value(this->metadata.setup().toStdString()));
}
void Writer::run() {
size_t count = 0;
size_t chunksize = 256;
if (valid) {
if (specs_valid) {
stop_request = false;
stopNow = false;
Pylon::CVideoWriter videoWriter;
@ -36,13 +50,21 @@ void Writer::run() {
hw_sec.createProperty("manufacturer", nix::Value("Basler AG"));
nix::Property p = hw_sec.createProperty("framerate", nix::Value(static_cast<int>(videoSpecs.fps)));
p.unit("Hz");
nix::Property p1 = hw_sec.createProperty("exposure time", nix::Value(static_cast<int>(videoSpecs.exposureTime)));
p1.unit("us");
nix::Property p2 = hw_sec.createProperty("detector gain", nix::Value(static_cast<int>(videoSpecs.detectorGain)));
p2.unit("dB");
if (metadata_valid) {
writeMetadata(s);
}
nix::NDSize initial_shape(1, chunksize);
nix::DataArray frametimes = b.createDataArray("frametimes", "nix.imaging.frametimes", nix::DataType::String, initial_shape);
frametimes.label("time");
frametimes.appendSetDimension();
nix::DataArray frameindices = b.createDataArray("frameindex", "nix.imaging.frameid", nix::DataType::Int64, initial_shape);
frametimes.appendSetDimension();
frameindices.appendSetDimension();
std::vector<std::string> stamps_buffer(chunksize);
std::vector<int64_t> ids_buffer(chunksize);

View File

@ -4,8 +4,11 @@
#include <QObject>
#include <QThread>
#include <pylon/PylonIncludes.h>
#include <nix.hpp>
#include "pylonwrapper.h"
#include "imagebuffer.h"
#include "projectsettings.h"
struct VideoSpecs {
std::string filename;
@ -25,6 +28,7 @@ public:
QThread(parent), buffer(buffer) {}
void setVideoSpecs(VideoSpecs specs);
void setProjectMetadata(ProjectMetadata mdata);
void run() override;
void stop();
@ -35,8 +39,10 @@ signals:
private:
ImageBuffer *buffer;
VideoSpecs videoSpecs;
ProjectMetadata metadata;
bool stop_request = false, stopNow = false;
bool valid = false;
bool specs_valid = false, metadata_valid = false;
void writeMetadata(nix::Section &s);
public slots:
void requestStop() {