[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; int count = 0;
if (camera->isOpen()) { if (camera->isOpen()) {
camera->frameRate(static_cast<uint>(framerate)); camera->frameRate(static_cast<uint>(framerate));
camera->exposureTime(exposure);
Pylon::CGrabResultPtr frame; Pylon::CGrabResultPtr frame;
Pylon::CInstantCamera *cam = camera->getCamera(); Pylon::CInstantCamera *cam = camera->getCamera();
cam->StartGrabbing(); cam->StartGrabbing();

View File

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

View File

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

View File

@ -76,7 +76,7 @@ private:
void applyScaling(); void applyScaling();
void adjustScrollBar(QScrollBar *scrollBar, double factor); void adjustScrollBar(QScrollBar *scrollBar, double factor);
int defaultBufferSize = 1000, defaultFrameRate = 30, movieCount = 0; int defaultBufferSize = 1000, defaultFrameRate = 30, movieCount = 0, defaultExposureTime = 3000;
QImage image; QImage image;
QTimer *frameTimer, *preassureTimer, *labelTimer; QTimer *frameTimer, *preassureTimer, *labelTimer;
QLabel *imageLabel, *writingLabel, *grabbingLabel, *cameraConnectedLabel, *fileLabel; QLabel *imageLabel, *writingLabel, *grabbingLabel, *cameraConnectedLabel, *fileLabel;
@ -94,7 +94,7 @@ private:
QString activeLabelStyleHigh = "QLabel { font-size: 10px;font-family: Arial; color : red; }"; 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 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; }"); 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) #if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer)

View File

@ -59,6 +59,29 @@ double PylonWrapper::frameRate() {
return rate; 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 PylonWrapper::getImageSettings() {
ImageSettings settings; ImageSettings settings;
if (valid) { if (valid) {

View File

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

View File

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