diff --git a/include/LambdaCamera.h b/include/LambdaCamera.h index 95053ba..8b5e314 100755 --- a/include/LambdaCamera.h +++ b/include/LambdaCamera.h @@ -90,6 +90,12 @@ class LIBLAMBDA_API Camera void getChargeSumming(bool &is_charge_summing); void setChargeSumming(int is_charge_summing); + // Frame summing + void checkDependency(double exposure_i); + + void setExposureAccuTime(double exposure_i); + void setAccumulationMode(bool accumulationMode); + private: class CameraThread: public CmdThread { @@ -142,7 +148,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; }; } } diff --git a/src/LambdaCamera.cpp b/src/LambdaCamera.cpp index dd82ea5..4504f78 100755 --- a/src/LambdaCamera.cpp +++ b/src/LambdaCamera.cpp @@ -134,11 +134,19 @@ void Camera::CameraThread::execStartAcq() void *ptr = buffer_mgr.getFrameBufferPtr(acq_frame_nb); - if(m_nDataType == 1) // short (12 bits) - 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 . - + if (m_cam->receiver->summedFrames() > 1) + { + // En mode accumulation image en 32 bits + memcpy((int32_t*)ptr, frame->data(), frame->size()); + } + else + { + + if(m_nDataType == 1) // short (12 bits) + 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 . + } m_cam->receiver->release(frame); } @@ -228,6 +236,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(); } @@ -740,4 +760,87 @@ void Camera::setChargeSumming(int is_charge_summing) { detector->setChargeSumming(xsp::lambda::ChargeSumming::OFF); } -} \ No newline at end of file +} + +//--------------------------------------------------------------------------------------- +//! 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; +}