Commit d93c78e5 authored by Laurent Claustre's avatar Laurent Claustre Committed by Sebastien Petitdemange

Added a reconstruction task for an optional destriding correction of the image

parent e3e10f86
1.0.0
\ No newline at end of file
1.0.0
......@@ -46,9 +46,12 @@ namespace lima
* \class Camera
* \brief object controlling the andor3 camera via andor3 SDK driver
*******************************************************************/
class Camera
class Camera : public HwMaxImageSizeCallbackGen
{
friend class Interface;
DEB_CLASS_NAMESPC(DebModCamera, "Camera", "Andor3");
public:
enum Status { Ready, Exposure, Readout, Latency, Fault };
......@@ -193,10 +196,14 @@ namespace lima
void getMaxFrameRateTransfer(double &o_max_transfer_rate) const;
void getReadoutTime(double &o_time) const;
void getSerialNumber(std::string &o_sn) const;
int getPixelStride() const;
protected:
virtual void setMaxImageSizeCallbackActive(bool cb_active);
private:
int getHwBitDepth(int *bit_depth);
void setDestrideActive(bool active);
// -- some internals :
// Stopping an acquisition, iForce : without waiting the end of frame buffer retrieval by m_acq_thread
......@@ -243,7 +250,6 @@ namespace lima
int sendCommand(const AT_WC* Feature);
private:
class _AcqThread;
friend class _AcqThread;
......@@ -289,6 +295,9 @@ namespace lima
std::map<int, std::string> m_andor3_error_maps;
static bool sAndorSDK3Initted;
bool m_destride_active;
bool m_maximage_size_cb_active;
};
// Some inline utility functions; used all-over in Andor3 plugin :
......
......@@ -43,7 +43,6 @@ namespace lima
class DetInfoCtrlObj : public HwDetInfoCtrlObj
{
DEB_CLASS_NAMESPC(DebModCamera, "DetInfoCtrlObj", "Andor3");
public:
DetInfoCtrlObj(Camera& cam, Interface *interface);
virtual ~DetInfoCtrlObj();
......@@ -61,10 +60,10 @@ namespace lima
virtual void registerMaxImageSizeCallback(HwMaxImageSizeCallback& cb);
virtual void unregisterMaxImageSizeCallback(HwMaxImageSizeCallback& cb);
private:
Camera& m_cam;
Interface *m_interface;
Interface *m_interface;
};
} // namespace Andor3
......
......@@ -32,6 +32,7 @@
#include "Andor3SyncCtrlObj.h"
#include "Andor3RoiCtrlObj.h"
#include "Andor3BinCtrlObj.h"
#include "Andor3ReconstructionCtrlObj.h"
namespace lima
{
......@@ -50,7 +51,7 @@ namespace lima
DEB_CLASS_NAMESPC(DebModCamera, "Andor3Interface", "Andor3");
public:
Interface(Camera& cam);
Interface(Camera& cam, bool destride_active = true);
virtual ~Interface();
//- From HwInterface
......@@ -61,7 +62,7 @@ namespace lima
virtual void stopAcq();
virtual void getStatus(StatusType& status);
virtual int getNbHwAcquiredFrames();
// Making the CtAcquisition object to update its cached range for expo. and lat. times
virtual void updateValidRanges();
......@@ -85,6 +86,9 @@ namespace lima
virtual void setSyncTriggering(bool i_sync);
virtual void getSyncTriggering(bool &o_sync) const;
void setDestrideActive(bool active);
void getDestrideActive(bool& active);
#warning Later should also have overlap and synctriggering ?
// Giving the possibility to get directly the camera object :
......@@ -99,6 +103,7 @@ namespace lima
SyncCtrlObj *m_sync;
RoiCtrlObj *m_roi;
BinCtrlObj *m_bin;
ReconstructionCtrlObj *m_reconstruction;
};
......
//###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2014
// European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//###########################################################################
#ifndef ANDOR3RECONSTRUCTIONCTRLOBJ_H
#define ANDOR3RECONSTRUCTIONCTRLOBJ_H
#include "HwReconstructionCtrlObj.h"
namespace Tasks
{
class SoftRoi;
}
namespace lima
{
namespace Andor3
{
class Camera;
class ReconstructionCtrlObj: public HwReconstructionCtrlObj
{
DEB_CLASS_NAMESPC(DebModCamera, "Andor3ReconstructionCtrlObj", "Andor3");
public:
ReconstructionCtrlObj(Camera& cam, bool active);
~ReconstructionCtrlObj();
virtual LinkTask* getReconstructionTask();
void setActive(bool active);
void getActive(bool& active) const;
void prepareAcq();
private:
Camera& m_cam;
bool m_active;
Tasks::SoftRoi* m_task;
};
}
}
#endif
# andor3 plugin python interface
# Copyright (C) 2013 IPANEMA USR3461, CNRS/MCC.
# Written by Serge Cohen <serge.cohen@synchrotron-soleil.fr>
############################################################################
# This file is part of LImA, a Library for Image Acquisition
#
# This file is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3 of
# the License, or (at your option) any later version.
# Copyright (C) : 2009-2011
# European Synchrotron Radiation Facility
# BP 220, Grenoble 38043
# FRANCE
#
# This file is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# This is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# You should have received a copy of the GNU General Public
# License along with this file. If not, see <http://www.gnu.org/licenses/>.
import os, sys, imp, glob, DLFCN
root_name = __path__[0]
mod_name = os.path.basename(root_name)
def version_code(s):
return map(int, s.strip('v').split('.'))
def version_cmp(x, y):
return cmp(version_code(x), version_code(y))
env_var_name = 'LIMA_%s_VERSION' % mod_name.upper()
try:
version = os.environ[env_var_name]
except KeyError:
version = 'LAST'
req_version = version
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
############################################################################
from Lima import module_helper
if version.upper() == 'LAST':
version_dirs = [x for x in os.listdir(root_name) if x.startswith('v')]
version_dirs.sort(version_cmp)
version = version_dirs[-1]
else:
if version[0] != 'v':
version = 'v' + version
mod_path = __path__
depends_on = 'Core'
has_dependent = False
mod_path = os.path.join(root_name, version)
if not (os.path.isdir(mod_path) or os.path.islink(mod_path)):
raise ImportError('Invalid %s: %s' % (env_var_name, req_version))
cleanup_data = module_helper.load_prepare(mod_path, depends_on, has_dependent)
__path__.append(mod_path)
from Lima import Core
ld_open_flags = sys.getdlopenflags()
sys.setdlopenflags(ld_open_flags | DLFCN.RTLD_GLOBAL)
cleanup_data = module_helper.load_dep_cleanup(cleanup_data)
from Lima.Andor3.limaandor3 import Andor3 as _A
globals().update(_A.__dict__)
sys.setdlopenflags(ld_open_flags)
module_helper.load_cleanup(cleanup_data)
del root_name, mod_name, mod_path, x, env_var_name
del version, req_version, version_dirs, version_code, version_cmp
del os, sys, imp, glob, DLFCN
del mod_path, depends_on, has_dependent, cleanup_data
del module_helper
......@@ -145,6 +145,7 @@ namespace Andor3
void getMaxFrameRateTransfer(double &o_max_transfer_rate /Out/ ) const;
void getReadoutTime(double &o_time /Out/ ) const;
void getSerialNumber(std::string &o_sn /Out/ ) const;
int getPixelStride() const;
};
};
......
......@@ -29,7 +29,7 @@ namespace Andor3
protected:
public:
Interface(Andor3::Camera& cam /In,KeepReference/);
Interface(Andor3::Camera& cam /In,KeepReference/, bool destride_active = true );
virtual ~Interface();
......@@ -66,5 +66,9 @@ namespace Andor3
virtual void getOverlap(bool &o_overlap /Out/ ) const;
virtual void setSyncTriggering(bool i_sync /In/ );
virtual void getSyncTriggering(bool &o_sync /Out/ ) const;
void setDestrideActive(bool active /In/);
void getDestrideActive(bool& active /Out/);
};
};
......@@ -160,7 +160,9 @@ m_electronic_shutter_mode(Rolling),
m_bit_depth(b16),
m_trig_mode(Internal),
m_cooler(true),
m_temperature_sp(5.0)
m_temperature_sp(5.0),
m_destride_active(true),
m_maximage_size_cb_active(false)
{
DEB_CONSTRUCTOR();
// Initing the maps that serves for error string generation :
......@@ -630,7 +632,10 @@ void
lima::Andor3::Camera::getDetectorImageSize(Size& size)
{
DEB_MEMBER_FUNCT();
size = m_detector_size;
if (m_destride_active)
size = m_detector_size;
else
size = Size(getPixelStride(), m_detector_size.getHeight());
}
// -- Buffer control object
......@@ -854,7 +859,10 @@ lima::Andor3::Camera::checkRoi(const Roi& set_roi, Roi& hw_roi)
// the_phys_set_roi = Roi(set_roi.getTopLeft()*the_bin_nb, set_roi.getSize()*the_bin_nb);
the_phys_set_roi = set_roi.getUnbinned(Bin(the_bin_nb, the_bin_nb));
the_phys_test_roi = Roi(Point(0, 0), m_detector_size);
Point phy_ori = the_phys_set_roi.getTopLeft();
phy_ori += 1;
the_phys_set_roi = Roi(phy_ori,the_phys_set_roi.getSize());
the_phys_test_roi = Roi(Point(1, 1), m_detector_size);
DEB_TRACE() << "Requested ROI is : " << set_roi << ", corresponding to " << the_phys_set_roi << " in term of physical pixel";
// First : check that we are smaller than the maximum AOI for the current binning
......@@ -936,6 +944,13 @@ lima::Andor3::Camera::checkRoi(const Roi& set_roi, Roi& hw_roi)
}
hw_roi = the_phys_hw_roi.getBinned(Bin(the_bin_nb, the_bin_nb));
// Lima Roi starts at <0,0> Andor3 starts at <1,1>, so -1 for topleft
Point topleft = hw_roi.getTopLeft();
Size size = hw_roi.getSize();
topleft -=1;
hw_roi = Roi(topleft, size);
// hw_roi = Roi(the_left, the_top, the_width, the_height);
}
......@@ -957,10 +972,11 @@ lima::Andor3::Camera::setRoi(const Roi& set_roi)
// Performing the settings in the order prescribed by the SDK's documentation:
// Binning, width, left, heigh, top :
setBin(the_binning);
// Lima Roi starts at <0,0> Andor3 starts at <1,1>
setInt(andor3::AOIWidth, the_width);
setInt(andor3::AOILeft, the_left);
setInt(andor3::AOILeft, the_left+1);
setInt(andor3::AOIHeight, the_height);
setInt(andor3::AOITop, the_top);
setInt(andor3::AOITop, the_top+1);
}
void
......@@ -974,7 +990,8 @@ lima::Andor3::Camera::getRoi(Roi& hw_roi)
getInt(andor3::AOIHeight, &the_height);
getInt(andor3::AOITop, &the_top);
hw_roi = Roi(static_cast<int>(the_left), static_cast<int>(the_top), static_cast<int>(the_width), static_cast<int>(the_height));
// Lima Roi starts at <0,0> Andor3 starts at <1,1>
hw_roi = Roi(static_cast<int>(the_left-1), static_cast<int>(the_top-1), static_cast<int>(the_width), static_cast<int>(the_height));
}
bool
......@@ -2466,6 +2483,42 @@ int lima::Andor3::Camera::getHwBitDepth(int *bit_depth)
return AT_SUCCESS;
}
void lima::Andor3::Camera::setDestrideActive(bool active)
{
DEB_MEMBER_FUNCT();
m_destride_active = active;
if (m_maximage_size_cb_active) {
// only if the callaback is active
// inform lima about the size change
ImageType image_type;
Size image_size;
getImageType(image_type);
getDetectorImageSize(image_size);
maxImageSizeChanged(image_size, image_type);
}
}
int lima::Andor3::Camera::getPixelStride() const
{
DEB_MEMBER_FUNCT();
AT_64 the_stride;
double the_byte_p_px;
getInt(andor3::AOIStride, &the_stride);
getFloat(andor3::BytesPerPixel, &the_byte_p_px);
return int(the_stride / the_byte_p_px);
}
void lima::Andor3::Camera::setMaxImageSizeCallbackActive(bool cb_active)
{
DEB_MEMBER_FUNCT();
m_maximage_size_cb_active = cb_active;
}
//-----------------------------------------------------
// Taking care of the imptrlementation of the acquisition thread (_AcqThread / m_acq_thread)
//-----------------------------------------------------
......
......@@ -115,18 +115,17 @@ void
lima::Andor3::DetInfoCtrlObj::registerMaxImageSizeCallback(HwMaxImageSizeCallback& cb)
{
DEB_MEMBER_FUNCT();
// Do nothing ... So far I on't know exactly what it is suppose to do
m_cam.registerMaxImageSizeCallback(cb);
}
void
lima::Andor3::DetInfoCtrlObj::unregisterMaxImageSizeCallback(HwMaxImageSizeCallback& cb)
{
DEB_MEMBER_FUNCT();
// Do nothing ... So far I on't know exactly what it is suppose to do
m_cam.unregisterMaxImageSizeCallback(cb);
}
/*
Local Variables:
c-file-style: "gnu"
......
......@@ -38,7 +38,7 @@
//---------------------------
//- @brief constructor
//---------------------------
lima::Andor3::Interface::Interface(lima::Andor3::Camera& cam) :
lima::Andor3::Interface::Interface(lima::Andor3::Camera& cam, bool destride_active) :
m_cam(cam),
m_cap_list() // ,
//m_det_info(cam),
......@@ -52,13 +52,15 @@ m_cap_list() // ,
m_sync = new SyncCtrlObj(m_cam);
m_roi = new RoiCtrlObj(m_cam, this);
m_bin = new BinCtrlObj(m_cam, this);
m_reconstruction = new ReconstructionCtrlObj(m_cam, destride_active);
// Taking care of the content of the CapList, once for all :
m_cap_list.push_back(HwCap(m_det_info));
m_cap_list.push_back(m_cam.getBufferCtrlObj());
m_cap_list.push_back(m_sync);
m_cap_list.push_back(HwCap(m_roi));
m_cap_list.push_back(HwCap(m_bin));
m_cap_list.push_back(HwCap(m_reconstruction));
}
......@@ -73,6 +75,7 @@ lima::Andor3::Interface::~Interface()
delete m_sync;
delete m_roi;
delete m_bin;
delete m_reconstruction;
}
void
......@@ -100,6 +103,7 @@ lima::Andor3::Interface::prepareAcq()
{
DEB_MEMBER_FUNCT();
m_cam.prepareAcq();
m_reconstruction->prepareAcq();
}
void
......@@ -287,6 +291,21 @@ lima::Andor3::Interface::getSyncTriggering(bool &o_sync) const
m_cam.getSyncTriggering(o_sync);
}
void lima::Andor3::Interface::setDestrideActive(bool active)
{
DEB_MEMBER_FUNCT();
m_reconstruction->setActive(active);
m_cam.setDestrideActive(active);
}
void lima::Andor3::Interface::getDestrideActive(bool& active)
{
DEB_MEMBER_FUNCT();
m_reconstruction->getActive(active);
}
/*
Local Variables:
c-file-style: "gnu"
......
//###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2013
// European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//###########################################################################
#include "Andor3ReconstructionCtrlObj.h"
#include "Andor3Camera.h"
#include "SoftRoi.h"
using namespace lima;
using namespace lima::Andor3;
//-----------------------------------------------------
// @brief Ctor
//-----------------------------------------------------
ReconstructionCtrlObj::ReconstructionCtrlObj(Camera& cam, bool active):
m_cam(cam), m_active(active)
{
DEB_CONSTRUCTOR();
m_task = new Tasks::SoftRoi();
m_task->setProcessingInPlace(true);
}
//-----------------------------------------------------
// @brief Dtor
//-----------------------------------------------------
ReconstructionCtrlObj::~ReconstructionCtrlObj()
{
DEB_DESTRUCTOR();
delete m_task;
}
void ReconstructionCtrlObj::prepareAcq()
{
DEB_MEMBER_FUNCT();
Roi roi;
if (m_active) {
m_cam.getRoi(roi);
DEB_TRACE() << DEB_VAR1(roi);
if (m_cam.getPixelStride() != roi.getSize().getWidth()) {
const Point& topLeft = roi.getTopLeft();
const Point& bottomRight = roi.getBottomRight();
m_task->setRoi(topLeft.x, bottomRight.x, topLeft.y, bottomRight.y);
reconstructionChange(m_task);
} else {
reconstructionChange(NULL);
}
}
}
//-----------------------------------------------------
// @brief return the task if active otherwise return NULL
//-----------------------------------------------------
LinkTask* ReconstructionCtrlObj::getReconstructionTask()
{
DEB_MEMBER_FUNCT();
if (m_active) return m_task;
else return NULL;
}
void ReconstructionCtrlObj::setActive(bool active)
{
DEB_MEMBER_FUNCT();
m_active = active;
if (!active) reconstructionChange(NULL);
}
void ReconstructionCtrlObj::getActive(bool& active) const
{
DEB_MEMBER_FUNCT();
active = m_active;
}
......@@ -17,12 +17,12 @@
andor3-objs = Andor3Camera.o Andor3Interface.o Andor3DetInfoCtrlObj.o Andor3SyncCtrlObj.o Andor3RoiCtrlObj.o Andor3BinCtrlObj.o
andor3-objs = Andor3Camera.o Andor3Interface.o Andor3DetInfoCtrlObj.o Andor3SyncCtrlObj.o Andor3RoiCtrlObj.o Andor3BinCtrlObj.o Andor3ReconstructionCtrlObj.o
SRCS = $(andor3-objs:.o=.cpp)
CXXFLAGS += -I../include -I../../../hardware/include -I../../../common/include \
-I/usr/local/include \
-I/usr/local/include -I../../../third-party/Processlib/core/include -I../../../third-party/Processlib/tasks/include \
-Wall -pthread -fPIC -g
all: Andor3.o
......@@ -41,3 +41,8 @@ clean:
rm -f $*.d
-include $(SRCS:.cpp=.P)
.PHONY: check-syntax
check-syntax:
$(CXX) -Wall -Wextra -fsyntax-only $(CXXFLAGS) $(CHK_SOURCES)
Markdown is supported
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