Skip to content
15 changes: 14 additions & 1 deletion include/LambdaCamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ class LIBLAMBDA_API Camera
void getChargeSumming(bool &is_charge_summing);
void setChargeSumming(int is_charge_summing);

// Acquisition mode
void setAcquisitionMode(int acq_mode);
void getAcquisitionMode(int &acq_mode);

// Frame summing
void checkDependency(double exposure_i);

void setExposureAccuTime(double exposure_i);
void setAccumulationMode(bool accumulationMode);

private:
class CameraThread: public CmdThread
{
Expand Down Expand Up @@ -142,7 +152,10 @@ class LIBLAMBDA_API Camera
/* main acquisition thread*/
CameraThread m_thread;
int m_acq_frame_nb;


// Frame summing
double m_exposure_i;
bool is_frame_summing;
};
}
}
Expand Down
152 changes: 149 additions & 3 deletions src/LambdaCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ void Camera::CameraThread::execStartAcq()
m_nDataType = 1; //short
else if(nDepth == 24)
m_nDataType = 2; //int
else if (nDepth == 6 || nDepth == 1)
m_nDataType = 3; //uint8_t

//- get the Frame
frame = m_cam->receiver->frame(1500);
Expand All @@ -138,6 +140,8 @@ void Camera::CameraThread::execStartAcq()
memcpy((short*)ptr, frame->data(), frame->size()); //we need a nb of BYTES .
else if(m_nDataType == 2) // int (24 bits)
memcpy((int*)ptr, frame->data(), frame->size()); //we need a nb of BYTES .
else if(m_nDataType == 3) // 1 byte (6 bits ou 1 bit)
memcpy((uint8_t*)ptr, frame->data(), frame->size()); //we need a nb of BYTES .

m_cam->receiver->release(frame);
}
Expand Down Expand Up @@ -228,6 +232,18 @@ Camera::Camera(std::string& config_file):
}

m_size = Size(receiver->frameWidth(),receiver->frameHeight());

int N = receiver->summedFrames();
if (N > 1)
{
m_exposure_i = m_exposure / (double)N;
is_frame_summing = true;
}
else
{
is_frame_summing = false;
m_exposure_i = m_exposure;
}

m_thread.start();
}
Expand Down Expand Up @@ -532,7 +548,11 @@ void Camera::setImageType(ImageType type)
DEB_TRACE() << "Camera::setImageType - " << DEB_VAR1(type);

xsp::lambda::BitDepth depth;
if(type == Bpp12)
if(type == Bpp1)
depth = xsp::lambda::BitDepth::DEPTH_1;
else if(type == Bpp6)
depth = xsp::lambda::BitDepth::DEPTH_6;
else if(type == Bpp12)
depth = xsp::lambda::BitDepth::DEPTH_12;
else if(type == Bpp24)
depth = xsp::lambda::BitDepth::DEPTH_24;
Expand All @@ -550,7 +570,11 @@ void Camera::getImageType(ImageType& type)
xsp::lambda::BitDepth depth;
depth = detector->bitDepth();

if(depth == xsp::lambda::BitDepth::DEPTH_12)
if(depth == xsp::lambda::BitDepth::DEPTH_1)
type = Bpp1;
else if(depth == xsp::lambda::BitDepth::DEPTH_6)
type = Bpp6;
else if(depth == xsp::lambda::BitDepth::DEPTH_12)
type = Bpp12;
else if(depth == xsp::lambda::BitDepth::DEPTH_24)
type = Bpp24;
Expand Down Expand Up @@ -740,4 +764,126 @@ void Camera::setChargeSumming(int is_charge_summing)
{
detector->setChargeSumming(xsp::lambda::ChargeSumming::OFF);
}
}
}

// Acquisition mode
void Camera::setAcquisitionMode(int acq_mode)
{
DEB_MEMBER_FUNCT();
DEB_TRACE() << "Camera::setAcquisitionMode - " << DEB_VAR1(acq_mode);

if (acq_mode != 1 && acq_mode != 6 && acq_mode != 12 && acq_mode != 24)
throw LIMA_HW_EXC(InvalidValue, "Acquisition mode should be 1, 6, 12 or 24 bits");

//if ((acq_mode == 1 || acq_mode == 6) && !hasFeature(xsp::lambda::Feature::FEAT_1_6_BIT))
// throw LIMA_HW_EXC(Error, "The device does not support 1 and 6 bits");

switch(acq_mode)
{
case 1: detector->setBitDepth(xsp::lambda::BitDepth::DEPTH_1); break;
case 6: detector->setBitDepth(xsp::lambda::BitDepth::DEPTH_6); break;
case 12: detector->setBitDepth(xsp::lambda::BitDepth::DEPTH_12); break;
case 24: detector->setBitDepth(xsp::lambda::BitDepth::DEPTH_24); break;
default: break;
}
//m_acquisition_mode = acq_mode;
}

void Camera::getAcquisitionMode(int &acq_mode)
{
DEB_MEMBER_FUNCT();
//acq_mode = m_acquisition_mode;
xsp::lambda::BitDepth bitDepth = detector->bitDepth();
switch(bitDepth)
{
case xsp::lambda::BitDepth::DEPTH_1 : acq_mode = 1; break;
case xsp::lambda::BitDepth::DEPTH_6 : acq_mode = 6; break;
case xsp::lambda::BitDepth::DEPTH_12: acq_mode = 12; break;
case xsp::lambda::BitDepth::DEPTH_24: acq_mode = 24; break;
default: break;
}
DEB_RETURN() << DEB_VAR1(acq_mode);
}

//---------------------------------------------------------------------------------------
//! ICATHALES-582 - Frame summing by accumulation
//! Camera Frame summing setting params
//! globalExposure = exposure_i * N
//---------------------------------------------------------------------------------------
void Camera::checkDependency(double exposure_i)
{
// Check image bits
xsp::lambda::OperationMode om = detector->operationMode();
if (exposure_i > 1)
{
if (om.bit_depth != xsp::lambda::BitDepth::DEPTH_24)
throw LIMA_HW_EXC(InvalidValue, "Exposure by frame is not conform with operation mode : 24 bits image required !");
//detector->setOperationMode(OperationMode(xsp::lambda::BitDepth::DEPTH_24));
//detector->setBitDepth(xsp::lambda::BitDepth::DEPTH_24);
}
else if (exposure_i >= 0.5)
{
if (om.bit_depth != xsp::lambda::BitDepth::DEPTH_12)
throw LIMA_HW_EXC(InvalidValue, "Exposure by frame is not conform with operation mode : 12 bits image required !");
//detector->setOperationMode(OperationMode(xsp::lambda::BitDepth::DEPTH_12));
//detector->setBitDepth(xsp::lambda::BitDepth::DEPTH_12);
}
else if (exposure_i >= 0.25)
{
if (om.bit_depth != xsp::lambda::BitDepth::DEPTH_6)
throw LIMA_HW_EXC(InvalidValue, "Exposure by frame is not conform with operation mode : 6 bits image required !");
//detector->setOperationMode(OperationMode(xsp::lambda::BitDepth::DEPTH_6));
//detector->setBitDepth(xsp::lambda::BitDepth::DEPTH_6);
}
else if (exposure_i > 0.0) {
if (om.bit_depth != xsp::lambda::BitDepth::DEPTH_1)
throw LIMA_HW_EXC(InvalidValue, "Exposure by frame is not conform with operation mode : 1 bit image required !");
//detector->setOperationMode(OperationMode(xsp::lambda::BitDepth::DEPTH_1));
//detector->setBitDepth(xsp::lambda::BitDepth::DEPTH_1);
}
else
throw LIMA_HW_EXC(InvalidValue, "Exposure by frame should be positive and not null !");
}

void Camera::setExposureAccuTime(double exposureAccuTime)
{
DEB_MEMBER_FUNCT();
DEB_TRACE() << "Camera::setExposureAccuTime - " << DEB_VAR1(exposureAccuTime);

double exposureByFrame = exposureAccuTime / 1E3;
if (exposureByFrame <= 0.0 || exposureByFrame > m_exposure)
LIMA_HW_EXC(InvalidValue, "Exposure by frame should be positive, greather than zero, in milliseconds and less than global exposure.");

m_exposure_i = exposureByFrame;

if (receiver->summedFrames() > 1)
{
// Update Nb frames to sum by image
int N = m_exposure / m_exposure_i;
receiver->setSummedFrames(N);

is_frame_summing = N > 1;
}
}

void Camera::setAccumulationMode(bool accumulationMode)
{
DEB_MEMBER_FUNCT();
DEB_TRACE() << "Camera::setAccumulationMode - " << DEB_VAR1(accumulationMode);

// Le hardware se met en mode summing automatiquement quand N > 1
if (accumulationMode)
{
if (m_exposure_i == 0.0)
LIMA_HW_EXC(InvalidValue, "Impossible to determine N. Fix before exposureAccuTime");

// Activation summing
int N = m_exposure / m_exposure_i;
receiver->setSummedFrames(N);
}
else {
// Desactivation summing
receiver->setSummedFrames(1);
}
is_frame_summing = accumulationMode;
}