Skip to content
Snippets Groups Projects
Commit 81073fc9 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Create multiple devices

parent 8d6da5c3
No related branches found
No related tags found
1 merge request!312Support new basler cameras
Pipeline #27158 passed
......@@ -29,40 +29,24 @@ PylonSource::PylonSource(ftl::rgbd::Source *host)
return;
} else {
for (auto d : devices) {
LOG(INFO) << " - found Pylon device - " << d.GetModelName();
LOG(INFO) << " - found Pylon device - " << d.GetFullName() << "(" << d.GetModelName() << ")";
}
}
try {
lcam_ = new CBaslerUniversalInstantCamera( CTlFactory::GetInstance().CreateFirstDevice());
lcam_ = new CBaslerUniversalInstantCamera( CTlFactory::GetInstance().CreateDevice(devices[0]));
lcam_->RegisterConfiguration( new Pylon::CSoftwareTriggerConfiguration, Pylon::RegistrationMode_ReplaceAll, Pylon::Cleanup_Delete);
lcam_->Open();
// Get the camera control object.
GenApi::INodeMap& nodemap = lcam_->GetNodeMap();
// Get the parameters for setting the image area of interest (Image AOI).
CIntegerParameter width(nodemap, "Width");
CIntegerParameter height(nodemap, "Height");
CIntegerParameter offsetX(nodemap, "OffsetX");
CIntegerParameter offsetY(nodemap, "OffsetY");
params_.width = width.GetValue();
params_.height = height.GetValue();
LOG(INFO) << "Camera resolution = " << params_.width << "x" << params_.height;
// Set the pixel data format.
CEnumParameter format(nodemap, "PixelFormat");
LOG(INFO) << "Camera format: " << format.GetValue();
if (format.CanSetValue("BayerBG8")) { // YCbCr422_8
format.SetValue("BayerBG8");
} else {
LOG(WARNING) << "Could not change pixel format";
if (devices.size() >= 2) {
rcam_ = new CBaslerUniversalInstantCamera( CTlFactory::GetInstance().CreateDevice(devices[1]));
rcam_->RegisterConfiguration( new Pylon::CSoftwareTriggerConfiguration, Pylon::RegistrationMode_ReplaceAll, Pylon::Cleanup_Delete);
rcam_->Open();
}
_configureCamera(lcam_);
if (rcam_) _configureCamera(rcam_);
lcam_->StartGrabbing( Pylon::GrabStrategy_OneByOne);
ready_ = true;
......@@ -88,6 +72,31 @@ PylonSource::~PylonSource() {
}
void PylonSource::_configureCamera(CBaslerUniversalInstantCamera *cam) {
// Get the camera control object.
GenApi::INodeMap& nodemap = cam->GetNodeMap();
// Get the parameters for setting the image area of interest (Image AOI).
CIntegerParameter width(nodemap, "Width");
CIntegerParameter height(nodemap, "Height");
CIntegerParameter offsetX(nodemap, "OffsetX");
CIntegerParameter offsetY(nodemap, "OffsetY");
params_.width = width.GetValue();
params_.height = height.GetValue();
LOG(INFO) << "Camera resolution = " << params_.width << "x" << params_.height;
// Set the pixel data format.
CEnumParameter format(nodemap, "PixelFormat");
LOG(INFO) << "Camera format: " << format.GetValue();
if (format.CanSetValue("BayerBG8")) { // YCbCr422_8
format.SetValue("BayerBG8");
} else {
LOG(WARNING) << "Could not change pixel format";
}
}
bool PylonSource::capture(int64_t ts) {
timestamp_ = ts;
if (!isReady()) return false;
......
......@@ -32,6 +32,8 @@ class PylonSource : public ftl::rgbd::detail::Source {
Pylon::CBaslerUniversalInstantCamera *rcam_;
Frame frames_[2];
cv::Mat tmp_;
void _configureCamera(Pylon::CBaslerUniversalInstantCamera *cam);
};
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment