[wrapper] add sensor Size functions
This commit is contained in:
parent
b221a03d43
commit
6916899620
@ -117,6 +117,29 @@ bool DualcamWrapper::exposureTime(double exposure_time, int camindex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t DualcamWrapper::sensorWidth(int camindex) {
|
||||
qDebug() << "Reading SensorWidth from camera " << camindex;
|
||||
assert(camindex >= 0 && camindex < 2);
|
||||
uint32_t width = -1;
|
||||
if (valid) {
|
||||
GenApi::INodeMap &nodemap = getNodemap(camindex);
|
||||
Pylon::CIntegerParameter pwidth( nodemap, "SensorWidth" );
|
||||
width = (uint32_t)pwidth.GetValue();
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
uint32_t DualcamWrapper::sensorHeight(int camindex) {
|
||||
qDebug() << "Reading SensorHeight from camera " << camindex;
|
||||
assert(camindex >= 0 && camindex < 2);
|
||||
uint32_t height = -1;
|
||||
if (valid) {
|
||||
GenApi::INodeMap &nodemap = getNodemap(camindex);
|
||||
Pylon::CIntegerParameter pheight( nodemap, "SensorHeight" );
|
||||
height = (uint32_t)pheight.GetValue();
|
||||
}
|
||||
return height;
|
||||
}
|
||||
|
||||
double DualcamWrapper::gain(int camindex) {
|
||||
assert(camindex >= 0 && camindex < 2);
|
||||
@ -208,12 +231,12 @@ void DualcamWrapper::setROI() {
|
||||
|
||||
void DualcamWrapper::resetCamera(int camindex) {
|
||||
GenApi::INodeMap &nodemap = getNodemap( camindex );
|
||||
int64_t dfltWidth = 2048;
|
||||
int64_t dfltHeight = 1536;
|
||||
qDebug() << "resetting camera to default ROI (" << dfltWidth << ", " << dfltHeight << ")";
|
||||
uint32_t width = sensorWidth(camindex);
|
||||
uint32_t height = sensorHeight(camindex);
|
||||
qDebug() << "resetting camera to default ROI (" << width << ", " << height << ")";
|
||||
try {
|
||||
Pylon::CIntegerParameter(nodemap, "Width").SetValue(dfltWidth, false);
|
||||
Pylon::CIntegerParameter(nodemap, "Height").SetValue(dfltHeight, false);
|
||||
Pylon::CIntegerParameter(nodemap, "Width").SetValue(width, false);
|
||||
Pylon::CIntegerParameter(nodemap, "Height").SetValue(height, false);
|
||||
Pylon::CIntegerParameter(nodemap, "OffsetX").SetValue(0);
|
||||
Pylon::CIntegerParameter(nodemap, "OffsetY").SetValue(0);
|
||||
} catch (const Pylon::GenericException &e) {
|
||||
|
@ -16,6 +16,8 @@ public:
|
||||
~DualcamWrapper();
|
||||
|
||||
ImageSettings getImageSettings(int camindex);
|
||||
uint32_t sensorWidth(int camindex);
|
||||
uint32_t sensorHeight(int camindex);
|
||||
bool isOpen();
|
||||
void terminate();
|
||||
bool openCameras(std::string &message);
|
||||
|
@ -157,14 +157,43 @@ bool PylonWrapper::grabFrame(MyImage &img) {
|
||||
camera->StartGrabbing();
|
||||
camera->RetrieveResult( 5000, frame, Pylon::TimeoutHandling_ThrowException);
|
||||
camera->StopGrabbing();
|
||||
qDebug() << "grabFrame done";
|
||||
}
|
||||
|
||||
img.setFrame(frame);
|
||||
return frame.IsValid();
|
||||
}
|
||||
|
||||
uint32_t PylonWrapper::sensorWidth() {
|
||||
qDebug() << "Reading SensorWidth";
|
||||
uint32_t width = -1;
|
||||
if (valid) {
|
||||
qDebug() << "SensorWidth available";
|
||||
GenApi::INodeMap &nodemap = camera->GetNodeMap();
|
||||
if (GenApi::IsAvailable(nodemap.GetNode("SensorWidth"))) {
|
||||
Pylon::CIntegerParameter pwidth( nodemap, "SensorWidth" );
|
||||
width = (uint32_t)pwidth.GetValue();
|
||||
}
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
uint32_t PylonWrapper::sensorHeight() {
|
||||
qDebug() << "Reading SensorHeight";
|
||||
uint32_t height = -1;
|
||||
if (valid){
|
||||
GenApi::INodeMap &nodemap = camera->GetNodeMap();
|
||||
if (GenApi::IsAvailable(nodemap.GetNode("SensorHeight"))) {
|
||||
Pylon::CIntegerParameter pheight( nodemap, "SensorHeight" );
|
||||
height = (uint32_t)pheight.GetValue();
|
||||
}
|
||||
}
|
||||
return height;
|
||||
}
|
||||
|
||||
void PylonWrapper::resetCamera() {
|
||||
int64_t dfltWidth = 2048;
|
||||
int64_t dfltHeight = 1536;
|
||||
uint32_t dfltWidth = sensorWidth();
|
||||
uint32_t dfltHeight = sensorHeight();
|
||||
qDebug() << "resetting camera to default ROI (" << dfltWidth << ", " << dfltHeight << ")";
|
||||
try {
|
||||
GenApi::INodeMap& nodemap = camera->GetNodeMap();
|
||||
@ -179,6 +208,7 @@ void PylonWrapper::resetCamera() {
|
||||
std::cerr << "An exception occurred." << std::endl << e.GetDescription() << std::endl;
|
||||
valid = false;
|
||||
}
|
||||
qDebug() << "resetting camera to default ROI done";
|
||||
}
|
||||
|
||||
bool PylonWrapper::openCamera(std::string &message) {
|
||||
@ -236,5 +266,12 @@ Pylon::CInstantCamera *PylonWrapper::getCamera() {
|
||||
QString PylonWrapper::userName() {
|
||||
GenApi::INodeMap& nodemap = camera->GetNodeMap();
|
||||
QString username = Pylon::CStringParameter(nodemap, "DeviceUserID").GetValue().c_str();
|
||||
if (username.length() == 0) {
|
||||
username = Pylon::CStringParameter(nodemap, "DeviceModelName").GetValue().c_str();
|
||||
}
|
||||
return username;
|
||||
}
|
||||
|
||||
QString PylonWrapper::deviceName() {
|
||||
return QString::fromStdString(fullName);
|
||||
}
|
@ -27,9 +27,12 @@ public:
|
||||
bool exposureTime(double exposure_time);
|
||||
double gain();
|
||||
bool gain(double gain_db);
|
||||
uint32_t sensorHeight();
|
||||
uint32_t sensorWidth();
|
||||
QString userName();
|
||||
Pylon::CInstantCamera *getCamera();
|
||||
void resetCamera();
|
||||
QString deviceName();
|
||||
|
||||
private:
|
||||
Pylon::CInstantCamera *camera;
|
||||
|
Loading…
Reference in New Issue
Block a user