fixed some bugs in CtVideo

parent 2d6a83ae
......@@ -230,7 +230,12 @@ endif
ifneq ($(COMPILE_PROSILICA),0)
PROSILICA_LDFLAGS := -L. -L../camera/prosilica/sdk/bin/x64 -L../camera/prosilica/sdk/bin/x86
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
endif
PROSILICA_LDLIBS := -lPvAPI
name := prosilica
......
prosilica @ 316efa5c
Subproject commit a213fd205f439b506de74721f2949ff73b0df274
Subproject commit 316efa5c4317d6e724f2283313c055e4c2284dbb
......@@ -2,6 +2,7 @@
#define VIDEOUTILS_H
#include <cstdlib>
#include <iostream>
#include "Constants.h"
......@@ -34,11 +35,7 @@ namespace lima
inline void alloc(int size)
{
if(!buffer || double(size) > this->size())
{
double allocSize = this->size();
size = int(allocSize + 0.5);
buffer = (char*)realloc(buffer,size);
}
buffer = (char*)realloc(buffer,size);
}
inline void setParams(int fNumber,int w,int h,VideoMode m)
{
......@@ -85,7 +82,7 @@ namespace lima
}
}
inline double depth() const
inline double depth() const
{
return mode_depth(mode);
}
......@@ -95,5 +92,43 @@ namespace lima
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
......@@ -139,7 +139,6 @@ void lima::data2Image(Data &aData,VideoImage &anImage)
{
if(!aData.empty())
{
VideoMode mode;
switch(aData.type)
{
case Data::UINT8:
......@@ -161,7 +160,6 @@ void lima::data2Image(Data &aData,VideoImage &anImage)
}
anImage.alloc(aData.size());
memcpy(anImage.buffer,aData.data(),aData.size());
anImage.mode = mode;
anImage.width = aData.dimensions[0];
anImage.height = aData.dimensions[1];
anImage.frameNumber = aData.frameNumber;
......
......@@ -14,6 +14,9 @@ namespace lima
DEB_CLASS_NAMESPC(DebModControl,"Control","Control");
friend class CtControl;
class _Data2ImageTask;
friend class _Data2ImageTask;
public:
CtVideo(CtControl&);
~CtVideo();
......@@ -36,16 +39,21 @@ namespace lima
class Image
{
friend class CtVideo;
friend class _Data2ImageTask;
friend std::ostream& operator<<(std::ostream &os,CtVideo::Image& im);
public:
Image();
~Image();
Image(const Image&);
Image& operator=(const Image&);
const unsigned char* buffer() const;
int width() const;
int height() const;
VideoMode mode() const;
const char* buffer() const;
int width() const;
int height() const;
VideoMode mode() const;
int size() const;
int frameNumber() const;
private:
Image(const CtVideo*,VideoImage*);
......@@ -98,8 +106,6 @@ namespace lima
// --- video mode
void getSupportedVideoMode(std::list<VideoMode> &modeList);
private:
class _Data2ImageTask;
friend class _Data2ImageTask;
class _Data2ImageCBK;
friend class _Data2ImageCBK;
class _InternalImageCBK;
......@@ -134,5 +140,16 @@ namespace lima
Bin m_hw_bin;
bool m_stopping_live; ///< variable to avoid deadlock when stopping live
};
inline std::ostream& operator<<(std::ostream &os,
CtVideo::Image& im)
{
if(im.m_image)
os << *(im.m_image);
else
os << "<No image>";
return os;
}
}
#endif
......@@ -50,10 +50,25 @@ using namespace lima;
~Image();
Image(const CtVideo::Image&);
const unsigned char* buffer() const;
SIP_PYOBJECT buffer() const;
%MethodCode
Py_BEGIN_ALLOW_THREADS
const char* buffer = sipCpp->buffer();
Py_ssize_t size = sipCpp->size();
sipRes = PyByteArray_FromStringAndSize(buffer ? buffer : "",size);
Py_END_ALLOW_THREADS
%End
int width() const;
int height() const;
VideoMode mode() const;
int size() const;
int frameNumber() const;
const char* __repr__();
%MethodCode
std::ostringstream str;
str << *sipCpp;
sipRes = str.str().c_str();
%End
};
class ImageCallback
......
......@@ -716,6 +716,7 @@ bool CtControl::_checkOverrun(Data &aData) const
DEB_ERROR() << DEB_VAR1(m_status);
}
DEB_PARAM() << DEB_VAR1(overrunFlag);
return overrunFlag;
}
// ----------------------------------------------------------------------------
......
......@@ -211,6 +211,35 @@ CtVideo::Image::Image(const CtVideo *video,VideoImage *image) :
++(m_image->inused);
}
const char* CtVideo::Image::buffer() const
{
return m_image ? m_image->buffer : NULL;
}
int CtVideo::Image::width() const
{
return m_image ? m_image->width : -1;
}
int CtVideo::Image::height() const
{
return m_image ? m_image->height : -1;
}
VideoMode CtVideo::Image::mode() const
{
return m_image ? m_image->mode : Y8;
}
int CtVideo::Image::size() const
{
return m_image ? int(m_image->size() + 0.5) : 0;
}
int CtVideo::Image::frameNumber() const
{
return m_image ? m_image->frameNumber : -1;
}
// --- CtVideo class
CtVideo::CtVideo(CtControl &ct) :
m_pars_modify_mask(0),
......
......@@ -280,7 +280,9 @@ class SoftBufferCtrlMgr : public HwBufferCtrlObj
SoftBufferCtrlMgr() :
HwBufferCtrlObj(),
m_buffer_cb_mgr(m_buffer_alloc_mgr),
m_mgr(m_buffer_cb_mgr) {}
m_mgr(m_buffer_cb_mgr),
m_acq_frame_nb(-1)
{}
virtual void setFrameDim(const FrameDim& frame_dim) {m_mgr.setFrameDim(frame_dim);}
virtual void getFrameDim(FrameDim& frame_dim) {m_mgr.getFrameDim(frame_dim);}
......@@ -311,7 +313,7 @@ class SoftBufferCtrlMgr : public HwBufferCtrlObj
StdBufferCbMgr& getBuffer() {return m_buffer_cb_mgr;}
int getNbAcquiredFrames() {return m_acq_frame_nb;}
int getNbAcquiredFrames() {return m_acq_frame_nb + 1;}
protected:
SoftBufferAllocMgr m_buffer_alloc_mgr;
StdBufferCbMgr m_buffer_cb_mgr;
......
......@@ -362,6 +362,7 @@ bool StdBufferCbMgr::newFrameReady(HwFrameInfoType& frame_info)
if (!frame_info.frame_ptr) {
frame_info.frame_ptr = ptr;
} else if (frame_info.frame_ptr != ptr) {
DEB_ERROR() << "Invalid " << DEB_VAR1(frame_info.frame_ptr);
THROW_HW_ERROR(InvalidValue) << "Invalid "
<< DEB_VAR1(frame_info.frame_ptr);
}
......
......@@ -100,6 +100,8 @@ endif
.PHONY: install
PROCESSOR_TYPE := $(shell uname -i)
install:
mkdir -p $(INSTALL_LIMA_DIR)
cp python/__init__.py $(INSTALL_LIMA_DIR)
......@@ -154,7 +156,6 @@ ifneq ($(COMPILE_PILATUS), 0)
cp camera/pilatus/python/__init__.py $(INSTALL_PILATUS_DIR)
cp camera/pilatus/python/*.py $(INSTALL_PILATUS_VDIR)
endif
ifneq ($(COMPILE_BASLER), 0)
mkdir -p $(INSTALL_BASLER_VDIR)
cp camera/basler/python/__init__.py $(INSTALL_BASLER_DIR)
......@@ -163,7 +164,6 @@ ifneq ($(COMPILE_BASLER), 0)
cp -d build/liblimabasler.so.$(BASLER_MAJ_VERSION) $(INSTALL_LIB_DIR)
cp sip/basler/limabasler.so $(INSTALL_BASLER_VDIR)
endif
ifneq ($(COMPILE_PROSILICA), 0)
mkdir -p $(INSTALL_PROSILICA_VDIR)
cp camera/prosilica/python/__init__.py $(INSTALL_PROSILICA_DIR)
......@@ -171,6 +171,10 @@ ifneq ($(COMPILE_PROSILICA), 0)
rm -rf $(INSTALL_LIB_DIR)/libPvAPI.so
cp build/liblimaprosilica.so.$(PROSILICA_FULL_VERSION) $(INSTALL_LIB_DIR)
cp -d build/liblimaprosilica.so.$(PROSILICA_MAJ_VERSION) $(INSTALL_LIB_DIR)
ifeq ($(PROCESSOR_TYPE),i386)
cp camera/prosilica/sdk/bin/x86/libPvAPI.so $(INSTALL_LIB_DIR)
else
cp camera/prosilica/sdk/bin/x64/libPvAPI.so $(INSTALL_LIB_DIR)
endif
cp sip/prosilica/limaprosilica.so $(INSTALL_PROSILICA_VDIR)
endif
Processlib @ 1ed649d5
Subproject commit 824ef3ec8c25a0372606ce5c4b206f8c7c44a06c
Subproject commit 1ed649d563a18a2222ba3e1868ffa08625b8603b
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