[exposure] enable to set the exposure time

This commit is contained in:
Jan Grewe 2020-11-19 09:02:15 +01:00
parent e28c0b159b
commit 0290ecb192
7 changed files with 51 additions and 4 deletions

View File

@ -7,6 +7,7 @@ void Grabber::run() {
int count = 0;
if (camera->isOpen()) {
camera->frameRate(static_cast<uint>(framerate));
camera->exposureTime(exposure);
Pylon::CGrabResultPtr frame;
Pylon::CInstantCamera *cam = camera->getCamera();
cam->StartGrabbing();

View File

@ -19,11 +19,16 @@ public:
return framerate;
}
double currentExposureTime() {
return exposure;
}
private:
bool stop_request = false;
PylonWrapper *camera;
ImageBuffer *buffer;
int framerate;
double exposure;
public slots:
void requestStop() {
@ -32,6 +37,9 @@ public slots:
void setFrameRate(int newFramerate) {
framerate = newFramerate;
}
void setExposureTime(double newExposureTime) {
exposure = newExposureTime;
}
signals:
void terminated();
};

View File

@ -385,6 +385,13 @@ void PylonRecorder::createActions() {
buffersizeSpinner->setFixedSize(120, 25);
buffersizeSpinner->setStyleSheet("QSpinBox{font-size: 10px;font-family: Arial;color: rgb(0, 0, 0);background-color: rgb(255,255,255);}");
exposureSpinner = new QSpinBox();
exposureSpinner->setRange(10, 50000);
exposureSpinner->setSingleStep(10);
exposureSpinner->setValue(defaultExposureTime);
exposureSpinner->setFixedSize(120, 25);
exposureSpinner->setStyleSheet("QSpinBox{font-size: 10px;font-family: Arial;color: rgb(0, 0, 0);background-color: rgb(255,255,255);}");
dryRunCheckBox = new QCheckBox("Dry run, no writing");
dryRunCheckBox->setChecked(false);
dryRunCheckBox->setFixedSize(150, 25);
@ -400,9 +407,12 @@ void PylonRecorder::createActions() {
toolbar->addAction(grab_continuous_action);
toolbar->addAction(grab_stop_action);
toolbar->addSeparator();
toolbar->addWidget(new QLabel("frame rate:"));
toolbar->addWidget(new QLabel("frame rate (Hz):"));
toolbar->addWidget(framerateSpinner);
toolbar->addSeparator();
toolbar->addWidget(new QLabel("exposure time (us):"));
toolbar->addWidget(exposureSpinner);
toolbar->addSeparator();
toolbar->addWidget(new QLabel("buffer size:"));
toolbar->addWidget(buffersizeSpinner);
toolbar->addSeparator();
@ -480,11 +490,11 @@ void PylonRecorder::disconnectCamera() {
void PylonRecorder::startRecording() {
std::string filename = createFilename();
//std::cerr << filename << std::endl;
fileLabel->setText(QString::fromStdString(filename));
VideoSpecs specs;
specs.fps = framerateSpinner->value();
specs.filename = filename;
specs.exposureTime = static_cast<double>(exposureSpinner->value());
ImageSettings settings = pylon->getImageSettings();
specs.width = static_cast<uint32_t>(settings.width);
specs.height= static_cast<uint32_t>(settings.height);
@ -497,6 +507,8 @@ void PylonRecorder::startRecording() {
}
if (framerateSpinner->value() != grabber->currentFramerate())
grabber->setFrameRate(framerateSpinner->value());
if (exposureSpinner->value() != int(grabber->currentExposureTime()))
grabber->setExposureTime(static_cast<double>(exposureSpinner->value()));
writer->setVideoSpecs(specs);
buffer->clear();
grabber->start();

View File

@ -76,7 +76,7 @@ private:
void applyScaling();
void adjustScrollBar(QScrollBar *scrollBar, double factor);
int defaultBufferSize = 1000, defaultFrameRate = 30, movieCount = 0;
int defaultBufferSize = 1000, defaultFrameRate = 30, movieCount = 0, defaultExposureTime = 3000;
QImage image;
QTimer *frameTimer, *preassureTimer, *labelTimer;
QLabel *imageLabel, *writingLabel, *grabbingLabel, *cameraConnectedLabel, *fileLabel;
@ -94,7 +94,7 @@ private:
QString activeLabelStyleHigh = "QLabel { font-size: 10px;font-family: Arial; color : red; }";
QString activeLabelStyleLow = "QLabel { font-size: 10px;font-family: Arial; color : cmyk(0, 255, 255, 0, 50); }";
QString inactiveLabelStyle = ("QLabel { font-size: 10px;font-family: Arial; color :gray; }");
QSpinBox *framerateSpinner, *buffersizeSpinner;
QSpinBox *framerateSpinner, *buffersizeSpinner, *exposureSpinner;
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer)

View File

@ -59,6 +59,29 @@ double PylonWrapper::frameRate() {
return rate;
}
double PylonWrapper::exposureTime() {
double time = -1.;
if (valid) {
GenApi::INodeMap& nodemap = camera->GetNodeMap();
GenApi::INode* n = nodemap.GetNode( "ExposureTime" );
Pylon::CFloatParameter exposure_time( n );
time = exposure_time.GetValue();
}
return time;
}
bool PylonWrapper::exposureTime(double exposure_time) {
if (valid) {
GenApi::INodeMap& nodemap = camera->GetNodeMap();
GenApi::CEnumerationPtr(nodemap.GetNode( "ExposureTimeMode" ))->FromString("Standard");
GenApi::INode* n = nodemap.GetNode( "ExposureTime" );
Pylon::CFloatParameter exp_time( n );
exp_time.SetValue( exposure_time );
return true;
}
return false;
}
ImageSettings PylonWrapper::getImageSettings() {
ImageSettings settings;
if (valid) {

View File

@ -27,6 +27,8 @@ public:
bool frameRate(uint framerate);
double frameRate();
double maxFrameRate();
double exposureTime();
bool exposureTime(double exposure_time);
Pylon::CInstantCamera *getCamera();
private:

View File

@ -11,6 +11,7 @@ struct VideoSpecs {
std::string filename;
uint32_t width, height, quality = 95;
int fps;
double exposureTime;
Pylon::EPixelType pixelType;
Pylon::EImageOrientation orientation;
};