Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Instrument Control
NomadSpecialModules
Commits
2aa1a358
Commit
2aa1a358
authored
Feb 21, 2020
by
Abdelali Elaazzouzi
Browse files
extand drivers for basler cam
parent
84242f07
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/drivers/gigecam/photonics/CameraHandler.cpp
View file @
2aa1a358
...
...
@@ -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
);
}
...
...
src/drivers/gigecam/photonics/CameraHandler.h
View file @
2aa1a358
...
...
@@ -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_
;
...
...
src/drivers/gigecam/photonics/RealPhotonicsDriver.cpp
View file @
2aa1a358
...
...
@@ -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
);
}
}
...
...
src/drivers/gigecam/photonics/RealPhotonicsDriver.h
View file @
2aa1a358
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment