Commit c1c0121a authored by Florent Langlois's avatar Florent Langlois

merge soleil-esrf

parent 0679b050
sip*.cpp
*.o
*.P
*.d
......
......@@ -40,6 +40,9 @@
[submodule "third-party/yat"]
path = third-party/yat
url = git://git.epn-campus.eu/repositories/yat
[submodule "camera/prosilica"]
path = camera/prosilica
url = git://git.epn-campus.eu/repositories/LimaCameraProsilica
[submodule "camera/xpad"]
path = camera/xpad
url = git://git.epn-campus.eu/repositories/LimaCameraXpad
tango @ 3b64999e
Subproject commit bc01c4c2c8a33228bf0c7bd968870429650999ea
Subproject commit 3b64999e921f994665f9d9cef2f2ae563ef8c886
......@@ -201,19 +201,17 @@ endif
ifneq ($(COMPILE_BASLER),0)
BASLER_LDFLAGS := -L. -L/opt/pylon/lib64
BASLER_LDLIBS := -lpylonbase
BASLER_LDFLAGS := -L. -L/opt/pylon/lib -L/opt/pylon/lib64
BASLER_LDLIBS := -lpylongigesupp
name := basler
basler-objs := ../camera/basler/src/Basler.o
version-file := ../camera/basler/VERSION
basler-flags := $(BASLER_LDFLAGS)
basler-deps := $(BASLER_LDLIBS)
basler-base := liblima$(name).so
full-version := $(shell cat $(version-file))
maj-version := $(shell echo $(full-version) | cut -f1 -d.)
basler-base := liblima$(name).so
basler-full := $(basler-base).$(full-version)
basler-maj := $(basler-base).$(maj-version)
basler-flags += -fPIC -Wl,-soname,$(basler-maj)
......@@ -224,7 +222,40 @@ $(basler-full): $(basler-objs)
rm -f $(basler-base); ln -s $(basler-maj) $(basler-base)
build_targets += $(basler-full)
endif
############################
# LIMA - PROSILICA
############################
ifneq ($(COMPILE_PROSILICA),0)
PROCESSOR_TYPE := $(shell uname -i)
ifeq ($(PROCESSOR_TYPE),i386)
PROSILICA_LDFLAGS := -L. -L../camera/prosilica/sdk/bin/x86
else
PROSILICA_LDFLAGS := -L. -L../camera/prosilica/sdk/bin/x64 -L../camera/prosilica/sdk/bin/x86
endif
PROSILICA_LDLIBS := -lPvAPI
name := prosilica
prosilica-objs := ../camera/prosilica/src/Prosilica.o
version-file := ../camera/prosilica/VERSION
prosilica-flags := $(PROSILICA_LDFLAGS)
prosilica-deps := $(PROSILICA_LDLIBS)
full-version := $(shell cat $(version-file))
maj-version := $(shell echo $(full-version) | cut -f1 -d.)
prosilica-base := liblima$(name).so
prosilica-full := $(prosilica-base).$(full-version)
prosilica-maj := $(prosilica-base).$(maj-version)
prosilica-flags += -fPIC -Wl,-soname,$(prosilica-maj)
$(prosilica-full): $(prosilica-objs)
$(CXX) -shared -o $@ $(prosilica-flags) $+ $(prosilica-deps)
rm -f $(prosilica-maj); ln -s $(prosilica-full) $(prosilica-maj)
rm -f $(prosilica-base); ln -s $(prosilica-maj) $(prosilica-base)
build_targets += $(prosilica-full)
endif
src: $(build_targets)
......
......@@ -45,8 +45,15 @@ endif
ifneq ($(COMPILE_BASLER),0)
sub-dirs += basler
CXXFLAGS+=-DLESSDEPENDENCY
export CXXFLAGS
endif
ifndef COMPILE_PROSILICA
COMPILE_PROSILICA = 0
endif
ifneq ($(COMPILE_PROSILICA),0)
sub-dirs += prosilica
endif
include ../global.inc
basler @ 5c5feab1
Subproject commit 0c36e88a8a286d9e820fd7605e1f02ef9eafc1c8
Subproject commit 5c5feab1fdfe4e8d733f607d3d706840b9f27a57
espia @ 99baba49
Subproject commit f8511f746a5121e2a816c6f2511d94ec8533603a
Subproject commit 99baba493125630c2b64980e9cd525dc7d68ab75
frelon @ fa1d0f4b
Subproject commit f73d750455859eb304c3a90dc36cb4c9778d86de
Subproject commit fa1d0f4b23e0c3906fa3c1442faeed74f453581d
maxipix @ d17bc3af
Subproject commit bb494b56142407b7bc01c29667b0acded53be0da
Subproject commit d17bc3afaaaef36f3ae5f0ac12b8059d73d54d50
pilatus @ 08a9681f
Subproject commit 69186d855101b42a21a28854ab6b7bfb83bb7663
Subproject commit 08a9681fb60432464c496b7744c3143533c68519
prosilica @ edc47152
Subproject commit edc471521f43957cdb448c587c850713280b40ae
......@@ -115,7 +115,7 @@ class LIBSIMULATOR_API SimuBufferCtrlObj : public HwBufferCtrlObj
class LIBSIMULATOR_API SimuSyncCtrlObj : public HwSyncCtrlObj
{
public:
SimuSyncCtrlObj(Simulator& simu, HwBufferCtrlObj& buffer_ctrl);
SimuSyncCtrlObj(Simulator& simu);
virtual ~SimuSyncCtrlObj();
virtual bool checkTrigMode(TrigMode trig_mode);
......
......@@ -88,7 +88,7 @@ class SimuSyncCtrlObj : HwSyncCtrlObj
%End
public:
SimuSyncCtrlObj(Simulator& simu, HwBufferCtrlObj& buffer_ctrl);
SimuSyncCtrlObj(Simulator& simu);
virtual ~SimuSyncCtrlObj();
virtual bool checkTrigMode(TrigMode trig_mode);
......
......@@ -189,8 +189,8 @@ void SimuBufferCtrlObj::unregisterFrameCallback(HwFrameCallback& frame_cb)
* \brief SimuSyncCtrlObj constructor
*******************************************************************/
SimuSyncCtrlObj::SimuSyncCtrlObj(Simulator& simu, HwBufferCtrlObj& buffer_ctrl)
: HwSyncCtrlObj(buffer_ctrl), m_simu(simu)
SimuSyncCtrlObj::SimuSyncCtrlObj(Simulator& simu)
: HwSyncCtrlObj(), m_simu(simu)
{
}
......@@ -290,7 +290,7 @@ void SimuBinCtrlObj::checkBin(Bin& bin)
SimuHwInterface::SimuHwInterface(Simulator& simu)
: m_simu(simu), m_det_info(simu), m_buffer(simu),
m_sync(simu, m_buffer), m_bin(simu)
m_sync(simu), m_bin(simu)
{
HwDetInfoCtrlObj *det_info = &m_det_info;
m_cap_list.push_back(HwCap(det_info));
......
......@@ -55,6 +55,7 @@ enum TrigMode {
IntTrig,IntTrigMult,
ExtTrigSingle, ExtTrigMult,
ExtGate, ExtStartStop,
Live,
};
LIMACORE_API std::ostream& operator <<(std::ostream& os, TrigMode trig_mode);
......@@ -96,6 +97,13 @@ LIMACORE_API DetStatus& operator |=(DetStatus& s1, DetStatus s2);
LIMACORE_API std::ostream& operator <<(std::ostream& os, DetStatus det_status);
enum VideoMode {Y8,Y16,Y32,Y64,
RGB555,RGB565,
RGB24,RGB32,
BGR24,BGR32,
BAYER_RG8,BAYER_RG16,
I420,YUV411,YUV422,YUV444};
} // namespace lima
#endif // CONSTANTS_H
......@@ -106,13 +106,15 @@ class LIMACORE_API Thread
virtual void start();
virtual void abort();
void join();
bool hasStarted();
bool hasFinished();
protected:
virtual void threadFunction() = 0;
pthread_attr_t m_thread_attr;
private:
static void *staticThreadFunction(void *data);
......
#ifndef VIDEOUTILS_H
#define VIDEOUTILS_H
#include <cstdlib>
#include <iostream>
#include "Constants.h"
#include "Data.h"
namespace lima
{
struct VideoImage
{
VideoImage() :
frameNumber(-1),
height(-1),
width(-1),
inused(0),
mode(Y8),
buffer(NULL)
{}
~VideoImage()
{
if(buffer)
free(buffer);
}
long long frameNumber;
int height;
int width;
int inused;
VideoMode mode;
char* buffer;
inline void alloc(int size)
{
if(!buffer || double(size) > this->size())
buffer = (char*)realloc(buffer,size);
}
inline void setParams(int fNumber,int w,int h,VideoMode m)
{
double oldSize = size();
frameNumber = fNumber;
width = w;
height = h;
mode = m;
double newSize = height * width * depth();
if(!buffer || newSize > oldSize)
{
int size = int(newSize + 0.5);
buffer = (char*)realloc(buffer,size);
}
}
inline double size() const {return buffer ? height * width * depth() : 0;}
static inline double mode_depth(VideoMode m)
{
switch(m)
{
case YUV411:
return 1.5;
case BAYER_RG8:
case Y8:
return 1.;
case RGB555:
case RGB565:
case BAYER_RG16:
case I420:
case Y16:
case YUV422:
return 2.;
case RGB32:
case BGR32:
case Y32:
return 4.;
case RGB24:
case BGR24:
case YUV444:
return 3.;
default:
return -1; /* ERROR */
}
}
inline double depth() const
{
return mode_depth(mode);
}
};
void data2Image(Data &aData,VideoImage &anImage);
void image2YUV(const unsigned char *srcPt,int width,int height,VideoMode mode,
unsigned char *dst);
inline std::ostream& operator<<(std::ostream &os,
const VideoImage &anImage)
{
const char *stringMode;
switch(anImage.mode)
{
case Y8: stringMode = "Y8";break;
case Y16: stringMode = "Y16";break;
case Y32: stringMode = "Y32";break;
case Y64: stringMode = "Y64";break;
case RGB555: stringMode = "RGB555";break;
case RGB565: stringMode = "RGB565";break;
case RGB24: stringMode = "RGB24";break;
case RGB32: stringMode = "RGB32";break;
case BGR24: stringMode = "BGR24";break;
case BGR32: stringMode = "BGR32";break;
case BAYER_RG8: stringMode = "BAYER_RG8";break;
case BAYER_RG16: stringMode = "BAYER_RG16";break;
case I420: stringMode = "I420";break;
case YUV411: stringMode = "YUV411";break;
case YUV422: stringMode = "YUV422";break;
case YUV444: stringMode = "YUV444";break;
default:
stringMode = "Unknowed";
break;
}
os << "<"
<< "frameNumber=" << anImage.frameNumber << ", "
<< "height=" << anImage.height << ", "
<< "width=" << anImage.width << ", "
<< "inused=" << anImage.inused << ", "
<< "mode=" << stringMode << ", "
<< "buffer=" << (void*)anImage.buffer
<< ">";
return os;
}
}
#endif
......@@ -104,3 +104,53 @@ enum DetStatus {
DetLatency = 0x80,
};
enum VideoMode {Y8,Y16,Y32,Y64,
RGB555,RGB565,
RGB24,RGB32,
BGR24,BGR32,
BAYER_RG8,BAYER_RG16,
I420,YUV411,YUV422,YUV444};
%MappedType std::list<VideoMode>
{
%TypeHeaderCode
#include <list>
%End
%ConvertToTypeCode
if(sipIsErr == NULL)
{
bool aReturnFlag = PySequence_Check(sipPy);
for(int i = 0;aReturnFlag && i < PySequence_Size(sipPy);++i)
aReturnFlag = sipCanConvertToEnum(PySequence_Fast_GET_ITEM(sipPy,i),
sipType_VideoMode);
return aReturnFlag;
}
std::list<VideoMode> *modeListPt = new std::list<VideoMode>();
for(int i = 0;i < PySequence_Size(sipPy);++i)
modeListPt->push_back(static_cast<VideoMode>(SIPLong_AsLong(PySequence_Fast_GET_ITEM(sipPy,i))));
*sipCppPtr = modeListPt;
return sipGetState(sipTransferObj);
%End
%ConvertFromTypeCode
PyObject *l;
if(!(l = PyList_New(sipCpp->size())))
return NULL;
int listPos = 0;
for(std::list<VideoMode>::iterator i = sipCpp->begin();
i != sipCpp->end();++i,++listPos)
{
PyObject *tobj = sipConvertFromEnum(*i, sipType_VideoMode);
if(!tobj)
{
Py_DECREF(l);
return NULL;
}
PyList_SET_ITEM(l, listPos, tobj);
}
return l;
%End
};
......@@ -20,11 +20,11 @@
# along with this program; if not, see <http://www.gnu.org/licenses/>.
############################################################################
common-objs := Constants.o SizeUtils.o Timestamp.o ThreadUtils.o Exceptions.o \
MemUtils.o RegExUtils.o AcqState.o Debug.o
MemUtils.o RegExUtils.o AcqState.o Debug.o VideoUtils.o
SRCS = $(common-objs:.o=.cpp)
CXXFLAGS += -I../include -I../../hardware/include -Wall -pthread -fPIC -g
CXXFLAGS += -I../include -I../../hardware/include -I../../third-party/Processlib/core/include -Wall -pthread -fPIC -g
all: Common.o
......
......@@ -219,6 +219,7 @@ void Cond::broadcast()
Thread::Thread()
{
m_started = m_finished = false;
pthread_attr_init(&m_thread_attr);
}
Thread::~Thread()
......@@ -227,6 +228,7 @@ Thread::~Thread()
abort();
pthread_join(m_thread, NULL);
}
pthread_attr_destroy(&m_thread_attr);
}
void Thread::start()
......@@ -234,12 +236,17 @@ void Thread::start()
if (m_started)
throw LIMA_COM_EXC(Error, "Thread already started");
if (pthread_create(&m_thread, NULL, staticThreadFunction, this) != 0)
if (pthread_create(&m_thread, &m_thread_attr, staticThreadFunction, this) != 0)
throw LIMA_HW_EXC(Error, "Error creating thread");
m_started = true;
}
void Thread::join()
{
pthread_join(m_thread,NULL);
}
void Thread::abort()
{
if (!m_started)
......
#include "Exceptions.h"
#include "VideoUtils.h"
using namespace lima;
/** func tool to convert from color 2 yuv
*/
inline void _rgb555_2_yuv(const unsigned char *data,unsigned char *luma,
int column,int row)
{
for(int aSize = column * row;aSize;--aSize,data += 2,++luma)
{
unsigned char red = (data[0] & 0x7c) >> 2;
unsigned char green = ((data[0] & 0x03) << 3) + ((data[1] & 0xe0) >> 5);
unsigned char blue = data[1] & 0x1f;
*luma = ((66 * red + 129 * green + 25 * blue) + 128) >> 8;
}
}
inline void _rgb565_2_yuv(const unsigned char *data,unsigned char *luma,
int column,int row)
{
for(int aSize = column * row;aSize;--aSize,data += 2,++luma)
{
unsigned char red = (data[0] & 0xf8) >> 3;
unsigned char green = ((data[0] & 0x07) << 3) + ((data[1] & 0xe0) >> 5);
unsigned char blue = data[1] & 0x1f;
*luma = ((66 * red + 129 * green + 25 * blue) + 128) >> 8;
}
}
inline void _rgb_2_yuv(const unsigned char *data,unsigned char *luma,
int column,int row,int bandes)
{
for(int aSize = column * row;aSize;--aSize,data += bandes,++luma)
*luma = ((66 * data[0] + 129 * data[1] + 25 * data[2]) + 128) >> 8;
}
inline void _bgr_2_yuv(const unsigned char *data,unsigned char *luma,
int column,int row,int bandes)
{
for(int aSize = column * row;aSize;--aSize,data += bandes,++luma)
*luma = ((25 * data[0] + 129 * data[1] + 66 * data[2]) + 128) >> 8;
}
template<class IN>
inline void _bayer_rg_2_yuv(const IN* bayer0,IN* luma,
int column,int row)
{
int blue = 1;
int start_with_green = 0;
int luma_step = column * sizeof(IN);
int bayer_step = column;
IN *luma0 = (IN*)luma;
memset( luma0, 0, luma_step);
memset( luma0 + (row - 1)*bayer_step, 0, luma_step);
luma0 += column + 1;
row -= 2;
column -= 2;
for( ; row > 0;--row,bayer0 += bayer_step, luma0 += bayer_step )
{
int t0, t1;
const IN* bayer = bayer0;
IN* dst = luma0;
const IN* bayer_end = bayer + column;
dst[-1] = 0;
if(column <= 0 )
continue;
if( start_with_green )
{
t0 = (bayer[1] + bayer[bayer_step*2+1] + 1) >> 1;
t1 = (bayer[bayer_step] + bayer[bayer_step+2] + 1) >> 1;
if(blue < -1)
*dst = (bayer[bayer_step+1] * 150 + t0 * 29 + t1 * 76) >> 8;
else
*dst = (bayer[bayer_step+1] * 150 + t1 * 29 + t0 * 76) >> 8;
++bayer;
++dst;
}
if( blue > 0 )
{
for( ; bayer <= bayer_end - 2; bayer += 2)
{
t0 = (bayer[0] + bayer[2] + bayer[bayer_step*2] +
bayer[bayer_step*2+2] + 2) >> 2;
t1 = (bayer[1] + bayer[bayer_step] +
bayer[bayer_step+2] + bayer[bayer_step*2+1]+2) >> 2;
*dst = (t0 * 76 + t1 * 150 + bayer[bayer_step+1] * 29) >> 8;
++dst;
t0 = (bayer[2] + bayer[bayer_step*2+2] + 1) >> 1;
t1 = (bayer[bayer_step+1] + bayer[bayer_step+3] + 1) >> 1;
*dst = (t0 * 76 + bayer[bayer_step+2] * 150 + t1 * 29) >> 8;
++dst;
}
}
else
{
for( ; bayer <= bayer_end - 2; bayer += 2)
{
t0 = (bayer[0] + bayer[2] + bayer[bayer_step*2] +
bayer[bayer_step*2+2] + 2) >> 2;
t1 = (bayer[1] + bayer[bayer_step] +
bayer[bayer_step+2] + bayer[bayer_step*2+1]+2) >> 2;
*dst = (t0 * 29 + t1 * 150 + bayer[bayer_step+1] * 76) >> 8;
++dst;
t0 = (bayer[2] + bayer[bayer_step*2+2] + 1) >> 1;
t1 = (bayer[bayer_step+1] + bayer[bayer_step+3] + 1) >> 1;
*dst = (t0 * 29 + bayer[bayer_step+2] * 150 + t1 * 76) >> 8;
++dst;
}
}
if( bayer < bayer_end )
{
t0 = (bayer[0] + bayer[2] + bayer[bayer_step*2] +
bayer[bayer_step*2+2] + 2) >> 2;
t1 = (bayer[1] + bayer[bayer_step] +
bayer[bayer_step+2] + bayer[bayer_step*2+1]+2) >> 2;
if(blue > 0)
*dst = (t0 * 76 + t1 * 150 + bayer[bayer_step+1] * 29) >> 8;
else
*dst = (t0 * 29 + t1 * 150 + bayer[bayer_step+1] * 76) >> 8;
++bayer;
++dst;
}
blue = -blue;
start_with_green = !start_with_green;
}
}
void lima::data2Image(Data &aData,VideoImage &anImage)
{
if(!aData.empty())
{
switch(aData.type)
{
case Data::UINT8:
case Data::INT8:
anImage.mode = Y8;break;
case Data::UINT16:
case Data::INT16:
anImage.mode = Y16;break;
case Data::UINT32:
case Data::INT32:
anImage.mode = Y32;break;
case Data::UINT64:
case Data::INT64:
anImage.mode = Y64;break;
case Data::FLOAT:
case Data::DOUBLE:
default:
throw LIMA_COM_EXC(Error, "Data type is not yet used for VideoImage");
}
anImage.alloc(aData.size());
memcpy(anImage.buffer,aData.data(),aData.size());
anImage.width = aData.dimensions[0];
anImage.height = aData.dimensions[1];
anImage.frameNumber = aData.frameNumber;
}
}
void lima::image2YUV(const unsigned char *srcPt,int width,int height,VideoMode mode,
unsigned char *dst)
{
switch(mode)
{
case Y8:
case Y16:
case Y32:
case Y64:
{
int size = int((width * height * VideoImage::mode_depth(mode)) + .5);
memcpy(dst,srcPt,size);
break;
}
case I420:
case YUV411:
case YUV422:
case YUV444:
memcpy(dst,srcPt,width * height);
break;