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

Small fixes, can now set pixel format

parent 02e566a2
No related branches found
No related tags found
1 merge request!312Support new basler cameras
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <ftl/rgbd/source.hpp> #include <ftl/rgbd/source.hpp>
#include <pylon/PylonIncludes.h> #include <pylon/PylonIncludes.h>
#include <pylon/BaslerUniversalInstantCamera.h>
#include <opencv2/imgproc.hpp> #include <opencv2/imgproc.hpp>
...@@ -33,14 +34,12 @@ PylonSource::PylonSource(ftl::rgbd::Source *host) ...@@ -33,14 +34,12 @@ PylonSource::PylonSource(ftl::rgbd::Source *host)
} }
try { 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_->RegisterConfiguration( new Pylon::CSoftwareTriggerConfiguration, Pylon::RegistrationMode_ReplaceAll, Pylon::Cleanup_Delete);
lcam_->Open(); lcam_->Open();
lcam_->StartGrabbing( Pylon::GrabStrategy_OneByOne);
// Get the camera control object. // Get the camera control object.
GenApi::INodeMap& nodemap = lcam_->GetNodeMap(); GenApi::INodeMap& nodemap = lcam_->GetNodeMap();
// Get the parameters for setting the image area of interest (Image AOI). // Get the parameters for setting the image area of interest (Image AOI).
...@@ -64,6 +63,8 @@ PylonSource::PylonSource(ftl::rgbd::Source *host) ...@@ -64,6 +63,8 @@ PylonSource::PylonSource(ftl::rgbd::Source *host)
LOG(WARNING) << "Could not change pixel format"; LOG(WARNING) << "Could not change pixel format";
} }
lcam_->StartGrabbing( Pylon::GrabStrategy_OneByOne);
ready_ = true; ready_ = true;
} catch (const Pylon::GenericException &e) { } catch (const Pylon::GenericException &e) {
// Error handling. // Error handling.
...@@ -92,7 +93,7 @@ bool PylonSource::capture(int64_t ts) { ...@@ -92,7 +93,7 @@ bool PylonSource::capture(int64_t ts) {
if (!lcam_) return false; if (!lcam_) return false;
try { try {
if ( lcam_->WaitForFrameTriggerReady( 20, Pylon::TimeoutHandling_ThrowException)) { if ( lcam_->WaitForFrameTriggerReady( 50, Pylon::TimeoutHandling_ThrowException)) {
lcam_->ExecuteSoftwareTrigger(); lcam_->ExecuteSoftwareTrigger();
LOG(INFO) << "TRIGGER"; LOG(INFO) << "TRIGGER";
} }
...@@ -111,14 +112,17 @@ bool PylonSource::retrieve() { ...@@ -111,14 +112,17 @@ bool PylonSource::retrieve() {
frame.setOrigin(&state_); frame.setOrigin(&state_);
try { try {
if ( lcam_->GetGrabResultWaitObject().Wait( 0)) { /*if ( lcam_->GetGrabResultWaitObject().Wait(40)) {
LOG(INFO) << "Grad result waiting"; LOG(INFO) << "Grad result waiting";
} } else {
LOG(INFO) << "No results";
return false;
}*/
Pylon::CGrabResultPtr ptrGrabResult; Pylon::CGrabResultPtr ptrGrabResult;
int count = 0; 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()) { if (count == 0 || !ptrGrabResult->GrabSucceeded()) {
LOG(ERROR) << "Retrieve failed"; LOG(ERROR) << "Retrieve failed";
...@@ -131,10 +135,8 @@ bool PylonSource::retrieve() { ...@@ -131,10 +135,8 @@ bool PylonSource::retrieve() {
CV_8UC3, CV_8UC3,
(uint8_t*)ptrGrabResult->GetBuffer()); (uint8_t*)ptrGrabResult->GetBuffer());
cv::Mat tmp; cv::cvtColor(wrap, tmp_, cv::COLOR_BGR2BGRA);
cv::cvtColor(wrap, tmp, cv::COLOR_BGR2BGRA); frame.create<cv::cuda::GpuMat>(ftl::codecs::Channel::Colour).upload(tmp_);
frame.create<cv::cuda::GpuMat>(ftl::codecs::Channel::Colour).upload(tmp);
} catch (const GenericException &e) { } catch (const GenericException &e) {
LOG(ERROR) << "Pylon: An exception occurred - " << e.GetDescription(); LOG(ERROR) << "Pylon: An exception occurred - " << e.GetDescription();
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include <string> #include <string>
namespace Pylon { namespace Pylon {
class CInstantCamera; class CBaslerUniversalInstantCamera;
} }
namespace ftl { namespace ftl {
...@@ -28,8 +28,9 @@ class PylonSource : public ftl::rgbd::detail::Source { ...@@ -28,8 +28,9 @@ class PylonSource : public ftl::rgbd::detail::Source {
private: private:
bool ready_; bool ready_;
Pylon::CInstantCamera *lcam_; Pylon::CBaslerUniversalInstantCamera *lcam_;
Frame frames_[2]; Frame frames_[2];
cv::Mat tmp_;
}; };
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment