diff --git a/components/rgbd-sources/src/sources/pylon/pylon.cpp b/components/rgbd-sources/src/sources/pylon/pylon.cpp index 50346b5cbc4e95f0a648618d2143e82a6c241619..42ea6e07c0da8759ad61e96de2ea2db2d83df4ed 100644 --- a/components/rgbd-sources/src/sources/pylon/pylon.cpp +++ b/components/rgbd-sources/src/sources/pylon/pylon.cpp @@ -5,6 +5,7 @@ #include <ftl/rgbd/source.hpp> #include <pylon/PylonIncludes.h> +#include <pylon/BaslerUniversalInstantCamera.h> #include <opencv2/imgproc.hpp> @@ -33,14 +34,12 @@ PylonSource::PylonSource(ftl::rgbd::Source *host) } try { - lcam_ = new CInstantCamera( CTlFactory::GetInstance().CreateFirstDevice()); + lcam_ = new CBaslerUniversalInstantCamera( CTlFactory::GetInstance().CreateFirstDevice()); lcam_->RegisterConfiguration( new Pylon::CSoftwareTriggerConfiguration, Pylon::RegistrationMode_ReplaceAll, Pylon::Cleanup_Delete); lcam_->Open(); - lcam_->StartGrabbing( Pylon::GrabStrategy_OneByOne); - // Get the camera control object. GenApi::INodeMap& nodemap = lcam_->GetNodeMap(); // Get the parameters for setting the image area of interest (Image AOI). @@ -64,6 +63,8 @@ PylonSource::PylonSource(ftl::rgbd::Source *host) LOG(WARNING) << "Could not change pixel format"; } + lcam_->StartGrabbing( Pylon::GrabStrategy_OneByOne); + ready_ = true; } catch (const Pylon::GenericException &e) { // Error handling. @@ -92,7 +93,7 @@ bool PylonSource::capture(int64_t ts) { if (!lcam_) return false; try { - if ( lcam_->WaitForFrameTriggerReady( 20, Pylon::TimeoutHandling_ThrowException)) { + if ( lcam_->WaitForFrameTriggerReady( 50, Pylon::TimeoutHandling_ThrowException)) { lcam_->ExecuteSoftwareTrigger(); LOG(INFO) << "TRIGGER"; } @@ -111,14 +112,17 @@ bool PylonSource::retrieve() { frame.setOrigin(&state_); try { - if ( lcam_->GetGrabResultWaitObject().Wait( 0)) { + /*if ( lcam_->GetGrabResultWaitObject().Wait(40)) { LOG(INFO) << "Grad result waiting"; - } + } else { + LOG(INFO) << "No results"; + return false; + }*/ Pylon::CGrabResultPtr ptrGrabResult; int count = 0; - if (lcam_->RetrieveResult( 0, ptrGrabResult, Pylon::TimeoutHandling_Return)) ++count; + if (lcam_->RetrieveResult(40, ptrGrabResult, Pylon::TimeoutHandling_Return)) ++count; if (count == 0 || !ptrGrabResult->GrabSucceeded()) { LOG(ERROR) << "Retrieve failed"; @@ -131,10 +135,8 @@ bool PylonSource::retrieve() { CV_8UC3, (uint8_t*)ptrGrabResult->GetBuffer()); - cv::Mat tmp; - cv::cvtColor(wrap, tmp, cv::COLOR_BGR2BGRA); - - frame.create<cv::cuda::GpuMat>(ftl::codecs::Channel::Colour).upload(tmp); + cv::cvtColor(wrap, tmp_, cv::COLOR_BGR2BGRA); + frame.create<cv::cuda::GpuMat>(ftl::codecs::Channel::Colour).upload(tmp_); } catch (const GenericException &e) { LOG(ERROR) << "Pylon: An exception occurred - " << e.GetDescription(); diff --git a/components/rgbd-sources/src/sources/pylon/pylon.hpp b/components/rgbd-sources/src/sources/pylon/pylon.hpp index c81bdae21187e9126e429ccf6075045233531f56..d5df32bdf97b747197bfbe1a10cdb1e13cd4ff2b 100644 --- a/components/rgbd-sources/src/sources/pylon/pylon.hpp +++ b/components/rgbd-sources/src/sources/pylon/pylon.hpp @@ -6,7 +6,7 @@ #include <string> namespace Pylon { -class CInstantCamera; +class CBaslerUniversalInstantCamera; } namespace ftl { @@ -28,8 +28,9 @@ class PylonSource : public ftl::rgbd::detail::Source { private: bool ready_; - Pylon::CInstantCamera *lcam_; + Pylon::CBaslerUniversalInstantCamera *lcam_; Frame frames_[2]; + cv::Mat tmp_; }; }