[wrapper] setting of framerates

This commit is contained in:
Jan Grewe 2020-03-12 17:48:07 +01:00
parent e2b1f44997
commit 3071c0bc3b
2 changed files with 55 additions and 10 deletions

View File

@ -22,25 +22,62 @@ bool PylonWrapper::isOpen() {
return valid; return valid;
} }
double PylonWrapper::maxFrameRate() {
double max_rate = -1;
if (valid) {
GenApi::INodeMap& nodemap = camera->GetNodeMap();
GenApi::INode* n = nodemap.GetNode( "AcquisitionFrameRate" );
Pylon::CFloatParameter framerate( n );
return framerate.GetMax();
}
return max_rate;
}
bool PylonWrapper::frameRate(uint new_framerate) {
if (valid) {
GenApi::INodeMap& nodemap = camera->GetNodeMap();
GenApi::INode* n = nodemap.GetNode( "AcquisitionFrameRateEnable" );
Pylon::CBooleanParameter enableframerate(n);
enableframerate.SetValue(true);
n = nodemap.GetNode( "AcquisitionFrameRate" );
Pylon::CFloatParameter framerate( n );
framerate.SetValue( new_framerate );
return true;
}
return false;
}
double PylonWrapper::frameRate() {
double rate = -1.;
if (valid) {
GenApi::INodeMap& nodemap = camera->GetNodeMap();
GenApi::INode* n = nodemap.GetNode( "AcquisitionFrameRate" );
Pylon::CFloatParameter framerate( n );
rate = framerate.GetValue();
}
return rate;
}
ImageSettings PylonWrapper::getImageSettings() { ImageSettings PylonWrapper::getImageSettings() {
ImageSettings settings; ImageSettings settings;
if (valid) { if (valid) {
Pylon::CIntegerParameter width( camera->GetNodeMap(), "Width"); Pylon::CIntegerParameter width( camera->GetNodeMap(), "Width");
Pylon::CIntegerParameter height( camera->GetNodeMap(), "Height"); Pylon::CIntegerParameter height( camera->GetNodeMap(), "Height");
Pylon::CEnumParameter pixelFormat( camera->GetNodeMap(), "PixelFormat"); Pylon::CEnumParameter pixelFormat( camera->GetNodeMap(), "PixelFormat");
settings.width = width.GetValue(); settings.width = width.GetValue();
settings.height = height.GetValue(); settings.height = height.GetValue();
} }
return settings; return settings;
} }
bool PylonWrapper::grabFrame(MyImage &img) { bool PylonWrapper::grabFrame(MyImage &img) {
Pylon::CGrabResultPtr frame; Pylon::CGrabResultPtr frame;
if (valid) { if (valid) {
camera->StartGrabbing(); camera->StartGrabbing();
camera->RetrieveResult( 5000, frame, Pylon::TimeoutHandling_ThrowException); camera->RetrieveResult( 5000, frame, Pylon::TimeoutHandling_ThrowException);
camera->StopGrabbing(); camera->StopGrabbing();
} }
img.setFrame(frame); img.setFrame(frame);
return frame.IsValid(); return frame.IsValid();
} }
@ -69,3 +106,7 @@ void PylonWrapper::closeCamera() {
} }
} }
} }
Pylon::CInstantCamera *PylonWrapper::getCamera() {
return camera;
}

View File

@ -22,6 +22,10 @@ public:
bool openCamera(std::string &message); bool openCamera(std::string &message);
void closeCamera(); void closeCamera();
bool grabFrame(MyImage &img); bool grabFrame(MyImage &img);
bool frameRate(uint framerate);
double frameRate();
double maxFrameRate();
Pylon::CInstantCamera *getCamera();
private: private:
Pylon::CInstantCamera *camera; Pylon::CInstantCamera *camera;