Commit 3f16e6c5 authored by Sebastien Petitdemange's avatar Sebastien Petitdemange
Browse files

-> first working MT accumulation

	* test was only done on Basler camera (slow)
	* need to test on fast camera like Maxipix,Frelon...
parent 548ccd24
basler @ 3b407160
Subproject commit 62626a5559c324003c940479a28da78ca7d4eb15
Subproject commit 3b407160c790a0c9ce1904b88ed714fd78965bd6
......@@ -34,10 +34,12 @@ namespace lima
class LIMACORE_API CtAccumulation
{
DEB_CLASS_NAMESPC(DebModControl,"Accumulation","Control");
class _ImageReady4AccCallback;
public:
friend class CtControl;
friend class CtBuffer;
friend class CtBufferFrameCB;
friend class _ImageReady4AccCallback;
typedef std::list<std::list<long long> > saturatedCounterResult;
......@@ -124,6 +126,14 @@ namespace lima
friend class _CalcSaturatedTask;
class _CalcEndCBK;
friend class _CalcEndCBK;
class _ImageReady4AccCallback : public TaskEventCallback
{
public:
_ImageReady4AccCallback(CtAccumulation &);
virtual void finished(Data &aData);
private:
CtAccumulation &m_acc;
};
Parameters m_pars;
long m_buffers_size;
......@@ -137,10 +147,14 @@ namespace lima
Data m_calc_mask;
mutable Cond m_cond;
ThresholdCallback* m_threshold_cb;
int m_last_acc_frame_nb;
bool m_last_continue_flag;
// --- Methodes for acquisition
void prepare();
bool newFrameReady(Data&);
bool _newFrameReady(Data&);
bool _newBaseFrameReady(Data&);
void getFrame(Data &,int frameNumber);
void _accFrame(Data &src,Data &dst);
......
......@@ -85,6 +85,8 @@ namespace lima {
void reset();
void setup(CtControl *ct);
bool isAccumulationActive() const {return !!m_ct_accumulation;}
static void getDataFromHwFrameInfo(Data&,const HwFrameInfoType&,
int readBlockLen=1);
private:
......
......@@ -60,6 +60,8 @@ using namespace lima;
void reset();
void setup(CtControl *ct);
bool isAccumulationActive() const;
static void getDataFromHwFrameInfo(Data& /Out/,const HwFrameInfoType&,
int readBlockLen=1);
};
......@@ -25,6 +25,17 @@
#include "SinkTask.h"
using namespace lima;
/****************************************************************************
CtAccumulation::_ImageReady4AccCallback
****************************************************************************/
CtAccumulation::_ImageReady4AccCallback::_ImageReady4AccCallback(CtAccumulation &acc) :
TaskEventCallback(),m_acc(acc) {}
void CtAccumulation::_ImageReady4AccCallback::finished(Data &aData)
{
m_acc._newBaseFrameReady(aData);
}
/*********************************************************************************
calculation task
*********************************************************************************/
......@@ -188,7 +199,9 @@ CtAccumulation::CtAccumulation(CtControl &ct) :
m_buffers_size(16),
m_ct(ct),
m_calc_ready(true),
m_threshold_cb(NULL)
m_threshold_cb(NULL),
m_last_acc_frame_nb(-1),
m_last_continue_flag(true)
{
m_calc_end = new _CalcEndCBK(*this);
m_calc_mgr = new _CalcSaturatedTaskMgr();
......@@ -485,10 +498,33 @@ void CtAccumulation::prepare()
if(acc_nframes < 0) acc_nframes = 1;
m_calc_mgr->resizeHistory(m_buffers_size * acc_nframes);
m_last_continue_flag = true;
m_last_acc_frame_nb = -1;
}
/** @brief this is an intergnal call from CtBuffer in case of accumulation
/** @brief this is an internal call from CtBuffer in case of accumulation
*/
bool CtAccumulation::newFrameReady(Data &aData)
bool CtAccumulation::_newFrameReady(Data &aData)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(aData);
TaskMgr *mgr = new TaskMgr();
mgr->setInputData(aData);
int internal_stage = 0;
m_ct.m_op_int->addTo(*mgr,internal_stage);
if(internal_stage)
PoolThreadMgr::get().addProcess(mgr);
else
{
delete mgr;
m_last_continue_flag = m_last_continue_flag && _newBaseFrameReady(aData);
}
return m_last_continue_flag;
}
/** @brief this is an internal call at the end of internal process or from CtBuffer
*/
bool CtAccumulation::_newBaseFrameReady(Data &aData)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(aData);
......@@ -497,6 +533,9 @@ bool CtAccumulation::newFrameReady(Data &aData)
int nb_acc_frame;
acq->getAccNbFrames(nb_acc_frame);
AutoMutex aLock(m_cond.mutex());
while(aData.frameNumber != (m_last_acc_frame_nb + 1))
m_cond.wait();
bool active = m_pars.active;
if(!(aData.frameNumber % nb_acc_frame)) // new Data has to be created
{
......@@ -547,9 +586,13 @@ bool CtAccumulation::newFrameReady(Data &aData)
_accFrame(aData,accFrame);
if(!((aData.frameNumber + 1) % nb_acc_frame))
return m_ct.newFrameReady(accFrame);
else
return true; // Always continue @see if it may have an overun
m_last_continue_flag = m_ct.newFrameReady(accFrame);
aLock.lock();
m_last_acc_frame_nb = aData.frameNumber;
m_cond.broadcast();
return m_last_continue_flag;
}
/** @brief retrived the image from the buffer
@parameters frameNumber == acquisition image id
......
......@@ -32,7 +32,7 @@ bool CtBufferFrameCB::newFrameReady(const HwFrameInfoType& frame_info)
Data fdata;
CtBuffer::getDataFromHwFrameInfo(fdata,frame_info);
if(m_ct_accumulation)
return m_ct_accumulation->newFrameReady(fdata);
return m_ct_accumulation->_newFrameReady(fdata);
else
return m_ct->newFrameReady(fdata);
}
......
......@@ -208,12 +208,15 @@ void CtControl::prepareAcq()
m_hw->prepareAcq();
DEB_TRACE() << "Apply software bin/roi";
m_op_int_active= m_ct_image->applySoft(m_op_int);
if (m_op_int->hasReconstructionTask())
m_op_int_active= true;
m_op_int_active= m_ct_image->applySoft(m_op_int) || m_op_int->hasReconstructionTask();
if(m_op_int_active)
{
_LastBaseImageReadyCallback *aCbkPt = new _LastBaseImageReadyCallback(*this);
TaskEventCallback *aCbkPt;
if(m_ct_buffer->isAccumulationActive())
aCbkPt = new CtAccumulation::_ImageReady4AccCallback(*this->m_ct_accumulation);
else
aCbkPt = new _LastBaseImageReadyCallback(*this);
m_op_int->setEndCallback(aCbkPt);
aCbkPt->unref();
}
......@@ -499,8 +502,9 @@ bool CtControl::newFrameReady(Data& fdata)
TaskMgr *mgr = new TaskMgr();
mgr->setInputData(fdata);
int internal_stage;
m_op_int->addTo(*mgr, internal_stage);
int internal_stage = 0;
if(!m_ct_buffer->isAccumulationActive())
m_op_int->addTo(*mgr, internal_stage);
int last_link,last_sink;
m_op_ext->addTo(*mgr, internal_stage, last_link, last_sink);
......
Supports Markdown
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