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