[metadata] store metadata fix nix output bug
This commit is contained in:
parent
3e2dfe2b3b
commit
b56a6a39d6
@ -599,6 +599,10 @@ void PylonRecorder::startRecording() {
|
|||||||
if (gainSpinner->value() != int(grabber->currentGain()))
|
if (gainSpinner->value() != int(grabber->currentGain()))
|
||||||
grabber->setGain(static_cast<double>(gainSpinner->value()));
|
grabber->setGain(static_cast<double>(gainSpinner->value()));
|
||||||
writer->setVideoSpecs(specs);
|
writer->setVideoSpecs(specs);
|
||||||
|
QSettings s;
|
||||||
|
this->mdata.read(s);
|
||||||
|
writer->setProjectMetadata(mdata);
|
||||||
|
|
||||||
buffer->clear();
|
buffer->clear();
|
||||||
grabber->start();
|
grabber->start();
|
||||||
if (!dryRunCheckBox->isChecked()) {
|
if (!dryRunCheckBox->isChecked()) {
|
||||||
|
30
writer.cpp
30
writer.cpp
@ -1,18 +1,32 @@
|
|||||||
#include "writer.h"
|
#include "writer.h"
|
||||||
#include <nix.hpp>
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
|
|
||||||
void Writer::setVideoSpecs(VideoSpecs specs) {
|
void Writer::setVideoSpecs(VideoSpecs specs) {
|
||||||
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() {
|
void Writer::run() {
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
size_t chunksize = 256;
|
size_t chunksize = 256;
|
||||||
|
|
||||||
if (valid) {
|
if (specs_valid) {
|
||||||
stop_request = false;
|
stop_request = false;
|
||||||
stopNow = false;
|
stopNow = false;
|
||||||
Pylon::CVideoWriter videoWriter;
|
Pylon::CVideoWriter videoWriter;
|
||||||
@ -36,13 +50,21 @@ void Writer::run() {
|
|||||||
hw_sec.createProperty("manufacturer", nix::Value("Basler AG"));
|
hw_sec.createProperty("manufacturer", nix::Value("Basler AG"));
|
||||||
nix::Property p = hw_sec.createProperty("framerate", nix::Value(static_cast<int>(videoSpecs.fps)));
|
nix::Property p = hw_sec.createProperty("framerate", nix::Value(static_cast<int>(videoSpecs.fps)));
|
||||||
p.unit("Hz");
|
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::NDSize initial_shape(1, chunksize);
|
||||||
nix::DataArray frametimes = b.createDataArray("frametimes", "nix.imaging.frametimes", nix::DataType::String, initial_shape);
|
nix::DataArray frametimes = b.createDataArray("frametimes", "nix.imaging.frametimes", nix::DataType::String, initial_shape);
|
||||||
frametimes.label("time");
|
frametimes.label("time");
|
||||||
frametimes.appendSetDimension();
|
frametimes.appendSetDimension();
|
||||||
nix::DataArray frameindices = b.createDataArray("frameindex", "nix.imaging.frameid", nix::DataType::Int64, initial_shape);
|
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<std::string> stamps_buffer(chunksize);
|
||||||
std::vector<int64_t> ids_buffer(chunksize);
|
std::vector<int64_t> ids_buffer(chunksize);
|
||||||
|
8
writer.h
8
writer.h
@ -4,8 +4,11 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <pylon/PylonIncludes.h>
|
#include <pylon/PylonIncludes.h>
|
||||||
|
#include <nix.hpp>
|
||||||
|
|
||||||
#include "pylonwrapper.h"
|
#include "pylonwrapper.h"
|
||||||
#include "imagebuffer.h"
|
#include "imagebuffer.h"
|
||||||
|
#include "projectsettings.h"
|
||||||
|
|
||||||
struct VideoSpecs {
|
struct VideoSpecs {
|
||||||
std::string filename;
|
std::string filename;
|
||||||
@ -25,6 +28,7 @@ public:
|
|||||||
QThread(parent), buffer(buffer) {}
|
QThread(parent), buffer(buffer) {}
|
||||||
|
|
||||||
void setVideoSpecs(VideoSpecs specs);
|
void setVideoSpecs(VideoSpecs specs);
|
||||||
|
void setProjectMetadata(ProjectMetadata mdata);
|
||||||
void run() override;
|
void run() override;
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
@ -35,8 +39,10 @@ signals:
|
|||||||
private:
|
private:
|
||||||
ImageBuffer *buffer;
|
ImageBuffer *buffer;
|
||||||
VideoSpecs videoSpecs;
|
VideoSpecs videoSpecs;
|
||||||
|
ProjectMetadata metadata;
|
||||||
bool stop_request = false, stopNow = false;
|
bool stop_request = false, stopNow = false;
|
||||||
bool valid = false;
|
bool specs_valid = false, metadata_valid = false;
|
||||||
|
void writeMetadata(nix::Section &s);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void requestStop() {
|
void requestStop() {
|
||||||
|
Loading…
Reference in New Issue
Block a user