Commit 2aa1a358 authored by Abdelali Elaazzouzi's avatar Abdelali Elaazzouzi
Browse files

extand drivers for basler cam

parent 84242f07
......@@ -3,7 +3,8 @@
#include <iostream>
#include <sstream>
#include <limits>
//#include "pylon/Platform.h"
//#include "pylon/api_autoconf.h"
#include "drivers/gigecam/photonics/BufferInformation.h"
#include "drivers/gigecam/photonics/DoubleBufferHandler.h"
......@@ -195,6 +196,7 @@ void CCameraHandler::InitializeBGAPI() {
BGAPI2::Device * camera_pointer = dev_iter->second;
try {
camera_pointer->Open();
#ifdef _DEBUG
if (camera_pointer->GetRemoteNodeList()->GetNodePresent("DeviceLinkHeartbeatMode")) {
camera_pointer->GetRemoteNode("DeviceLinkHeartbeatMode")->SetValue("Off");
......@@ -271,7 +273,24 @@ bool CCameraControl::ExposureFeatureBGAPI() {
// check if the feature is writeable and write new value
if (exposure_node->IsWriteable()) {
exposure_node->SetDouble(exposure_time_);
}
std::cout <<"e>>>>>>>>>>>>>>>>exposure_time_ OK "<<camera_pointer_->GetRemoteNode("ExposureTimeRaw")->GetValue() << std::endl;
}
BGAPI2::Node* exposure_gain = camera_pointer_->GetRemoteNode("GainRaw");
// check if the feature is writeable and write new value
if (exposure_gain->IsWriteable()) {
exposure_gain->SetInt(exposure_gain_);
}
std::cout <<"e>>>>>>>>>>>>>>>>GainRaw OK "<<camera_pointer_->GetRemoteNode("GainRaw")->GetValue() << std::endl;
BGAPI2::Node* pixel_format = camera_pointer_->GetRemoteNode("PixelFormat");
std::cout <<"e>>>>>>>>>>>>>>>>pixel format OK "<<camera_pointer_->GetRemoteNode("PixelFormat")->GetValue() << std::endl;
// check if the feature is writeable and write new value
if (pixel_format->IsWriteable()) {
pixel_format->SetString("YUV422_YUYV_Packed");
}
std::cout <<"e>>>>>>>>>>>>>>>>pixel format OK "<<camera_pointer_->GetRemoteNode("PixelFormat")->GetValue() << std::endl;
// write some status information
std::lock_guard<std::mutex> lock(feature_command_message_list_lock_);
feature_command_message_list_.clear();
......@@ -293,10 +312,11 @@ bool CCameraControl::ExposureFeatureBGAPI() {
// the mutex protects the command_feature_ flag
// against parallel access from function CommandExposure
void CCameraControl::StartFeatureCommandExposure(double exposure_time) {
void CCameraControl::StartFeatureCommandExposure(double exposure_time,unsigned int exposure_gain) {
std::lock_guard<std::mutex> lock(feature_command_lock_);
exposure_time_ = exposure_time;
ExposureFeatureBGAPI();
exposure_gain_ = exposure_gain;
ExposureFeatureBGAPI();
// command_feature_ = true;
}
......@@ -406,8 +426,8 @@ bool CCameraControl::CaptureBGAPIImages(const bool * abort_flag, unsigned int nu
// fetch the buffers
BGAPI2::Buffer* buffer = datastream_pointer->GetFilledBuffer(exposure_time_ + 1000);
if (buffer) {
std::cout <<"GetFilledBuffer OK "<< std::endl;
FillBufferInformation(datastream_pointer, buffer);
std::cout <<"GetFilledBuffer OK "<< number_of_captured_images_<< " of " <<number_of_images_ <<std::endl;
FillBufferInformation(datastream_pointer, buffer);
number_of_captured_images_++;
buffer_handler_.PushBuffer(buffer);
}
......
......@@ -15,7 +15,7 @@ public:
// this function activates the feature command
// the feature command use the ExposureTime feature of the camera
// the parameter passes the new exposure time to be written to the camera
void StartFeatureCommandExposure(double exposure_time);
void StartFeatureCommandExposure(double exposure_time,unsigned int exposure_gain);
// this function activates the capture command
// the parameter passes the number of images to be captured
......@@ -89,6 +89,7 @@ public:
bool command_feature_;
// exposure time to be set
double exposure_time_;
unsigned int exposure_gain_;
private:
// mutex to synchronize the access to capture command flag of all cameras
std::mutex capture_command_lock_;
......
......@@ -18,6 +18,8 @@
#include "drivers/gigecam/photonics/RealPhotonicsDriver.h"
// Namespace for using pylon objects.
#include <boost/lexical_cast.hpp>
#include "CImg.h"
......@@ -25,6 +27,7 @@
#include "drivers/gigecam/photonics/PhotonicsDef.h"
#include "drivers/gigecam/photonics/PhotonicsDriver.h"
using namespace cimg_library;
// Setting for using Basler GigE cameras.
using namespace std;
......@@ -274,6 +277,8 @@ void RealPhotonicsDriver::writeParam() {
ostringstream buf_conf;
std::size_t found;
//CFeaturePersistence::Save( "camparam.txt", camera_pointer->GetNodeList() );
string err;
}
......@@ -305,7 +310,7 @@ void RealPhotonicsDriver::synchroniseRead() {
// if (!buffer->GetIsIncomplete()) {
unsigned char* image_buffer = static_cast<unsigned char*>(buffer->GetMemPtr());
int32 camindice = boost::lexical_cast<int32>((*camera_iter)->camera_pointer_->GetDisplayName());
cout << "get buffer for camera: " << camindice << endl;
cout << "get buffer for camera: " << camindice << " size "<< buffer->GetMemSize()<< endl;
datas[camindice - 1] = static_cast<uint16*>(buffer->GetMemPtr());
buffers[&camera_control->buffer_handler_] = buffer;
......@@ -376,10 +381,13 @@ void RealPhotonicsDriver::start() {
// Set exposure time
float64 exposure_time = owner()->time.setpoint() * 1000.;
uint32 exposure_gain = owner()->gain();
StartFeatureCommandExposure(&m_camera_handler, exposure_time);
std::cout << "Exposure time successfully written to cameras. Please hit 4 to print current exposure setting." << std::endl;
StartCaptureCommand(&m_camera_handler, 1);
StartFeatureCommandExposure(&m_camera_handler, exposure_time,exposure_gain);
std::cout << "Exposure time successfully written to cameras" << std::endl;
// owner()->nbFrame();
cout << "owner()->nbFrame() " <<owner()->nbFrame()<< endl;
StartCaptureCommand(&m_camera_handler, owner()->nbFrame());
WaitUntilStreamingIsActive(&m_camera_handler);
......@@ -472,11 +480,11 @@ void RealPhotonicsDriver::readStatus() {
PrintCameraStatus(*camera_iter);
ret=ret+m_camera_handler.CapturedImages();
cout << "RealPhotonicsDriver::readStatus 2 ret= " <<ret<< endl;
cout << "CapturedImages= " <<ret<< endl;
}
cout << "m_camera_handler.CapturedImages() = " << m_camera_handler.CapturedImages()
<< " , m_camera_handler.NumberOfCameras() = " << m_camera_handler.NumberOfCameras() << endl;
if (ret == 2) {
if (ret == owner()->nbCols()*owner()->nbRows()) {
cout << "RealPhotonicsDriver::readStatus 3 " << endl;
status |= END;
owner()->startActivated = false;
......@@ -695,12 +703,12 @@ int RealPhotonicsDriver:: WaitOfImages(CCameraHandler * camera_handler, unsigned
return return_code;
}
void RealPhotonicsDriver::StartFeatureCommandExposure(CCameraHandler * camera_handler, double exposure_time) {
void RealPhotonicsDriver::StartFeatureCommandExposure(CCameraHandler * camera_handler, double exposure_time,uint32 exposure_gain ) {
const std::vector<CCameraControl*>* camera_vector = camera_handler->GetCameraControlVector();
for (std::vector<CCameraControl*>::const_iterator camera_iter = camera_vector->begin();
camera_iter != camera_vector->end();
camera_iter++) {
(*camera_iter)->StartFeatureCommandExposure(exposure_time);
(*camera_iter)->StartFeatureCommandExposure(exposure_time,exposure_gain);
}
}
......
......@@ -129,7 +129,7 @@ private:
// this function activates the feature command on all connected cameras
// the feature command use the ExposureTime feature of the camera
// the parameter passes the new exposure time to be written to the cameras
void StartFeatureCommandExposure(CCameraHandler * camera_handler, double exposure_time);
void StartFeatureCommandExposure(CCameraHandler * camera_handler, double exposure_time,uint32 exposure_gain );
// this function activates the capture command on all connected cameras
// the parameter passes the number of images to be captured
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment