From ce45f0a9b60a5db7b34b38fbf020cb03c033580f Mon Sep 17 00:00:00 2001 From: emfoumoune Date: Thu, 28 Mar 2024 15:43:54 +0100 Subject: [PATCH 1/6] see #ICATHALES-582 : Sommation d'images par accumulation --- include/LambdaCamera.h | 10 ++++- src/LambdaCamera.cpp | 88 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 96 insertions(+), 2 deletions(-) diff --git a/include/LambdaCamera.h b/include/LambdaCamera.h index 95053ba..0f14edb 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(int nb_frames, double exposure); + void setExposures(double exposure, double exposure_i); + void setNbFrameAndExposureByImage(int nb_frames, double exposure_i); + void setNbFrameAndExposure(int nb_frames, double exposure); + private: class CameraThread: public CmdThread { @@ -142,7 +148,9 @@ class LIBLAMBDA_API Camera /* main acquisition thread*/ CameraThread m_thread; int m_acq_frame_nb; - + + // Frame summing + bool is_frame_summing; }; } } diff --git a/src/LambdaCamera.cpp b/src/LambdaCamera.cpp index dd82ea5..1cdf65d 100755 --- a/src/LambdaCamera.cpp +++ b/src/LambdaCamera.cpp @@ -228,6 +228,7 @@ Camera::Camera(std::string& config_file): } m_size = Size(receiver->frameWidth(),receiver->frameHeight()); + is_frame_summing = m_nb_frames > 1; m_thread.start(); } @@ -740,4 +741,89 @@ void Camera::setChargeSumming(int is_charge_summing) { detector->setChargeSumming(xsp::lambda::ChargeSumming::OFF); } -} \ No newline at end of file +} + +// Frame summing +//--------------------------------------------------------------------------------------- +//! Camera Frame summing setting params +//! globalExposure = exposure_i * N +//--------------------------------------------------------------------------------------- +void Camera::checkDependency(int nb_frames, double exposure) +{ + // Check image bits + double exposure_i = exposure / nb_frames; + 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 (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); + } +} + +void Camera::setExposures(double exposure, double exposure_i) +{ + DEB_MEMBER_FUNCT(); + DEB_TRACE() << "Camera::setExposures - " << DEB_VAR2(exposure, exposure_i); + + double xx_exposure = exposure; + int nb_frames = exposure / exposure_i; + // corretion exposure + if ((exposure - (exposure_i * nb_frames)) == 0.0) + xx_exposure = exposure; + else + xx_exposure = exposure_i * nb_frames; + + checkDependency(nb_frames, xx_exposure); + + setExpTime(xx_exposure); + setNbFrames(nb_frames); + is_frame_summing = m_nb_frames > 1; +} + +void Camera::setNbFrameAndExposureByImage(int nb_frames, double exposure_i) +{ + DEB_MEMBER_FUNCT(); + DEB_TRACE() << "Camera::setNbFrameAndExposureByImage - " << DEB_VAR2(nb_frames, exposure_i); + + + double xx_exposure = nb_frames * exposure_i; + checkDependency(nb_frames, xx_exposure); + + setExpTime(xx_exposure); + setNbFrames(nb_frames); + is_frame_summing = m_nb_frames > 1; +} + +void Camera::setNbFrameAndExposure(int nb_frames, double exposure) +{ + DEB_MEMBER_FUNCT(); + DEB_TRACE() << "Camera::setNbFrameAndExposure - " << DEB_VAR2(nb_frames, exposure); + + checkDependency(nb_frames, exposure); + + setExpTime(exposure); + setNbFrames(nb_frames); + is_frame_summing = m_nb_frames > 1; +} From 4d19761a6c1236862b91dda8e0a930708e02e4fb Mon Sep 17 00:00:00 2001 From: emfoumoune Date: Fri, 29 Mar 2024 12:08:51 +0100 Subject: [PATCH 2/6] see #ICATHALES-582 : Frame summing - add comments --- src/LambdaCamera.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/LambdaCamera.cpp b/src/LambdaCamera.cpp index 1cdf65d..6ebb0ec 100755 --- a/src/LambdaCamera.cpp +++ b/src/LambdaCamera.cpp @@ -743,8 +743,8 @@ void Camera::setChargeSumming(int is_charge_summing) } } -// Frame summing //--------------------------------------------------------------------------------------- +//! ICATHALES-582 - Frame summing by accumulation //! Camera Frame summing setting params //! globalExposure = exposure_i * N //--------------------------------------------------------------------------------------- @@ -782,6 +782,7 @@ void Camera::checkDependency(int nb_frames, double exposure) } } +// ICATHALES-582 : Use case 1 void Camera::setExposures(double exposure, double exposure_i) { DEB_MEMBER_FUNCT(); @@ -802,12 +803,12 @@ void Camera::setExposures(double exposure, double exposure_i) is_frame_summing = m_nb_frames > 1; } +// ICATHALES-582 : Use case 2 void Camera::setNbFrameAndExposureByImage(int nb_frames, double exposure_i) { DEB_MEMBER_FUNCT(); DEB_TRACE() << "Camera::setNbFrameAndExposureByImage - " << DEB_VAR2(nb_frames, exposure_i); - double xx_exposure = nb_frames * exposure_i; checkDependency(nb_frames, xx_exposure); @@ -816,6 +817,7 @@ void Camera::setNbFrameAndExposureByImage(int nb_frames, double exposure_i) is_frame_summing = m_nb_frames > 1; } +// ICATHALES-582 : Use case 3 void Camera::setNbFrameAndExposure(int nb_frames, double exposure) { DEB_MEMBER_FUNCT(); From bb4321cd87e756337d659d44de13a38bc4e709fc Mon Sep 17 00:00:00 2001 From: emfoumoune Date: Wed, 3 Apr 2024 16:42:46 +0200 Subject: [PATCH 3/6] see #ICATHALES-582 : Sommation d'images par accumulation - exposure_i --- include/LambdaCamera.h | 9 +++--- src/LambdaCamera.cpp | 69 ++++++++++++++++++++---------------------- 2 files changed, 37 insertions(+), 41 deletions(-) diff --git a/include/LambdaCamera.h b/include/LambdaCamera.h index 0f14edb..8b5e314 100755 --- a/include/LambdaCamera.h +++ b/include/LambdaCamera.h @@ -91,10 +91,10 @@ class LIBLAMBDA_API Camera void setChargeSumming(int is_charge_summing); // Frame summing - void checkDependency(int nb_frames, double exposure); - void setExposures(double exposure, double exposure_i); - void setNbFrameAndExposureByImage(int nb_frames, double exposure_i); - void setNbFrameAndExposure(int nb_frames, double exposure); + void checkDependency(double exposure_i); + + void setExposureAccuTime(double exposure_i); + void setAccumulationMode(bool accumulationMode); private: class CameraThread: public CmdThread @@ -150,6 +150,7 @@ class LIBLAMBDA_API Camera 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 6ebb0ec..cfd51f5 100755 --- a/src/LambdaCamera.cpp +++ b/src/LambdaCamera.cpp @@ -228,7 +228,8 @@ Camera::Camera(std::string& config_file): } m_size = Size(receiver->frameWidth(),receiver->frameHeight()); - is_frame_summing = m_nb_frames > 1; + is_frame_summing = false; + m_exposure_i = 0.0; m_thread.start(); } @@ -748,10 +749,9 @@ void Camera::setChargeSumming(int is_charge_summing) //! Camera Frame summing setting params //! globalExposure = exposure_i * N //--------------------------------------------------------------------------------------- -void Camera::checkDependency(int nb_frames, double exposure) +void Camera::checkDependency(double exposure_i) { // Check image bits - double exposure_i = exposure / nb_frames; xsp::lambda::OperationMode om = detector->operationMode(); if (exposure_i > 1) { @@ -774,58 +774,53 @@ void Camera::checkDependency(int nb_frames, double exposure) //detector->setOperationMode(OperationMode(xsp::lambda::BitDepth::DEPTH_6)); //detector->setBitDepth(xsp::lambda::BitDepth::DEPTH_6); } - else { + 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 !"); } -// ICATHALES-582 : Use case 1 -void Camera::setExposures(double exposure, double exposure_i) +void Camera::setExposureAccuTime(double exposureAccuTime) { DEB_MEMBER_FUNCT(); - DEB_TRACE() << "Camera::setExposures - " << DEB_VAR2(exposure, exposure_i); + DEB_TRACE() << "Camera::setExposureAccuTime - " << DEB_VAR1(exposureAccuTime); - double xx_exposure = exposure; - int nb_frames = exposure / exposure_i; - // corretion exposure - if ((exposure - (exposure_i * nb_frames)) == 0.0) - xx_exposure = exposure; - else - xx_exposure = exposure_i * nb_frames; + double exposureByFrame = exposureAccuTime / 1E3; + if (exposureByFrame < 1 || exposureByFrame > m_exposure) + LIMA_HW_EXC(InvalidValue, "Exposure by frame should be positive, greather than zero, in milliseconds and less than global exposure."); - checkDependency(nb_frames, xx_exposure); - setExpTime(xx_exposure); - setNbFrames(nb_frames); - is_frame_summing = m_nb_frames > 1; -} + // Check if exposure_i is adapted to device + //checkDependency(exposureAccuTime); -// ICATHALES-582 : Use case 2 -void Camera::setNbFrameAndExposureByImage(int nb_frames, double exposure_i) -{ - DEB_MEMBER_FUNCT(); - DEB_TRACE() << "Camera::setNbFrameAndExposureByImage - " << DEB_VAR2(nb_frames, exposure_i); + m_exposure_i = exposureByFrame; - double xx_exposure = nb_frames * exposure_i; - checkDependency(nb_frames, xx_exposure); + // Nb frames to sum by image + int N = m_exposure / m_exposure_i; + receiver->setSummedFrames(N); - setExpTime(xx_exposure); - setNbFrames(nb_frames); - is_frame_summing = m_nb_frames > 1; + is_frame_summing |= N > 1; } -// ICATHALES-582 : Use case 3 -void Camera::setNbFrameAndExposure(int nb_frames, double exposure) +void Camera::setAccumulationMode(bool accumulationMode) { DEB_MEMBER_FUNCT(); - DEB_TRACE() << "Camera::setNbFrameAndExposure - " << DEB_VAR2(nb_frames, exposure); + DEB_TRACE() << "Camera::setAccumulationMode - " << DEB_VAR1(accumulationMode); - checkDependency(nb_frames, exposure); - - setExpTime(exposure); - setNbFrames(nb_frames); - is_frame_summing = m_nb_frames > 1; + // 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"); + + int N = m_exposure / m_exposure_i; + receiver->setSummedFrames(N); + } + else { + receiver->setSummedFrames(1); + } + is_frame_summing = accumulationMode; } From 8783d4e83ef2d7e40136760293abd0e0a5144156 Mon Sep 17 00:00:00 2001 From: emfoumoune Date: Thu, 4 Apr 2024 14:27:55 +0200 Subject: [PATCH 4/6] see #ICATHALES-586 : Lambda - ajout mode d'acquisition d'images --- include/LambdaCamera.h | 4 ++++ src/LambdaCamera.cpp | 43 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/include/LambdaCamera.h b/include/LambdaCamera.h index 95053ba..21778db 100755 --- a/include/LambdaCamera.h +++ b/include/LambdaCamera.h @@ -90,6 +90,10 @@ 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); + private: class CameraThread: public CmdThread { diff --git a/src/LambdaCamera.cpp b/src/LambdaCamera.cpp index dd82ea5..55bc46a 100755 --- a/src/LambdaCamera.cpp +++ b/src/LambdaCamera.cpp @@ -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); @@ -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); } @@ -740,4 +744,41 @@ void Camera::setChargeSumming(int is_charge_summing) { detector->setChargeSumming(xsp::lambda::ChargeSumming::OFF); } -} \ No newline at end of file +} + +// 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); +} From a235c1d875134db620c10a0589cdcada3431d432 Mon Sep 17 00:00:00 2001 From: emfoumoune Date: Fri, 5 Apr 2024 12:08:08 +0200 Subject: [PATCH 5/6] see #ICATHALES-586 : Lambda - ajout mode d'acquisition d'images - corrections --- src/LambdaCamera.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/LambdaCamera.cpp b/src/LambdaCamera.cpp index 55bc46a..3a06764 100755 --- a/src/LambdaCamera.cpp +++ b/src/LambdaCamera.cpp @@ -536,7 +536,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; @@ -554,7 +558,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; @@ -755,10 +763,11 @@ void Camera::setAcquisitionMode(int 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"); + //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) { + 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; @@ -773,7 +782,8 @@ void Camera::getAcquisitionMode(int &acq_mode) DEB_MEMBER_FUNCT(); //acq_mode = m_acquisition_mode; xsp::lambda::BitDepth bitDepth = detector->bitDepth(); - switch(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; From c8044ed0d4433d281767d8ac510d6dd0f37a1c8a Mon Sep 17 00:00:00 2001 From: emfoumoune Date: Fri, 5 Apr 2024 17:36:54 +0200 Subject: [PATCH 6/6] see #ICATHALES-582 : Lambda - sommation de frames - corrections --- src/LambdaCamera.cpp | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/LambdaCamera.cpp b/src/LambdaCamera.cpp index cfd51f5..cb1e2c1 100755 --- a/src/LambdaCamera.cpp +++ b/src/LambdaCamera.cpp @@ -228,8 +228,18 @@ Camera::Camera(std::string& config_file): } m_size = Size(receiver->frameWidth(),receiver->frameHeight()); - is_frame_summing = false; - m_exposure_i = 0.0; + + 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(); } @@ -790,20 +800,19 @@ void Camera::setExposureAccuTime(double exposureAccuTime) DEB_TRACE() << "Camera::setExposureAccuTime - " << DEB_VAR1(exposureAccuTime); double exposureByFrame = exposureAccuTime / 1E3; - if (exposureByFrame < 1 || exposureByFrame > m_exposure) + 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."); - - // Check if exposure_i is adapted to device - //checkDependency(exposureAccuTime); - m_exposure_i = exposureByFrame; - // Nb frames to sum by image - int N = m_exposure / m_exposure_i; - receiver->setSummedFrames(N); + 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; + is_frame_summing = N > 1; + } } void Camera::setAccumulationMode(bool accumulationMode) @@ -812,14 +821,17 @@ void Camera::setAccumulationMode(bool accumulationMode) DEB_TRACE() << "Camera::setAccumulationMode - " << DEB_VAR1(accumulationMode); // Le hardware se met en mode summing automatiquement quand N > 1 - if (accumulationMode) { + 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;