7 #ifndef _LIBALVISION_ALVISION_ALIMAGE_H_ 
    8 #define _LIBALVISION_ALVISION_ALIMAGE_H_ 
   15 #include <boost/shared_ptr.hpp> 
   32     ROI(
int left, 
int top, 
int width, 
int height);
 
   33     ROI(
int left, 
int top, 
int width, 
int height,
 
   61   ALImage(
int pWidth, 
int pHeight, 
int pColorSpace, 
bool pDataAreExternal = 
false,
 
   62           float pLeftAngle = 0.f, 
float pTopAngle = 0.f,
 
   63           float pRightAngle = 0.f, 
float pBottomAngle = 0.f);
 
   76   ALImage(
int pResolution, 
int pColorSpace, 
bool pDataAreExternal = 
false,
 
   77           float pLeftAngle = 0.f, 
float pTopAngle = 0.f,
 
   78           float pRightAngle = 0.f, 
float pBottomAngle = 0.f);
 
  127   inline void setWidth( 
const int width )   { fWidth = width; }
 
  128   inline void setHeight( 
const int height ) { fHeight = height; }
 
  129   inline void setLeftAngle( 
const float leftAngle )     { fFOV.leftAngle = leftAngle; }
 
  130   inline void setTopAngle( 
const float topAngle )       { fFOV.topAngle = topAngle; }
 
  131   inline void setRightAngle( 
const float rightAngle )   { fFOV.rightAngle = rightAngle; }
 
  132   inline void setBottomAngle( 
const float bottomAngle ) { fFOV.bottomAngle = bottomAngle; }
 
  133   inline void setAngles( 
const float leftAngle,  
const float topAngle,
 
  134                          const float rightAngle, 
const float bottomAngle )
 
  135   { fFOV.leftAngle = leftAngle;   fFOV.topAngle = topAngle;
 
  136     fFOV.rightAngle = rightAngle; fFOV.bottomAngle = bottomAngle; }
 
  163   { std::cout << 
"getFrame() is deprecated. Please replace by getData()." << std::endl;
 
  171   inline const unsigned char* 
getData()
 const { 
return rawData(); }
 
  180   { std::cout << 
"getFrame() is deprecated. Please replace by getData()." << std::endl;
 
  188   inline unsigned char* 
getData() { 
return rawData(); }
 
  196   inline void setData(
unsigned char* pData) { fData = externalData(pData); }
 
  205     if( (pTimeStamp.tv_usec < 0) || (pTimeStamp.tv_sec < 0) )
 
  210     setTimeStamp(static_cast<int>(pTimeStamp.tv_sec), static_cast<int>(pTimeStamp.tv_usec));
 
  218   inline void setTimeStamp(
long long pTimeStamp) { fTimeStamp = pTimeStamp; }
 
  228     fTimeStamp = (
long long)pSeconds*1000000LL + (
long long)pMicroSeconds;
 
  237   inline void setCameraId(
char pCameraId) { fCameraId = pCameraId; }
 
  244   inline unsigned int getSize()
 const { 
return fWidth*fHeight*fNbLayers; }
 
  249   inline int getWidth( 
void )
  const { 
return fWidth; }
 
  264   inline void getAngles( 
float& leftAngle, 
float& topAngle, 
float& rightAngle, 
float& bottomAngle )
 
  265   const { leftAngle = fFOV.leftAngle; topAngle = fFOV.topAngle;
 
  266     rightAngle = fFOV.rightAngle; bottomAngle = fFOV.bottomAngle; }
 
  278     return &(fROIs[index]);
 
  282     fROIs.push_back(rect);
 
  290     fROIEnabled = enable;
 
  298   int writeFile(
const char* _fileNameAndPath);
 
  299   int readFile(
const char* _fileNameAndPath);
 
  300   int savePPM(
const char* _fileNameAndPath);
 
  330     deleter(
bool external) : external(external) {}
 
  331     void operator()(
unsigned char* p)
 
  333       if (!external && p != NULL)
 
  340   bool reallocateDataSize(
const int resolution, 
const int nbLayers);
 
  341   inline unsigned char* rawData()
 const { assert( fData ); 
return fData.get(); }
 
  352     assert( boost::get_deleter<ALImage::deleter>(fData) != NULL );
 
  353     return *boost::get_deleter<ALImage::deleter>(fData);
 
  355   static boost::shared_ptr<unsigned char[]> internalDataUninitialized(
size_t size);
 
  356   static boost::shared_ptr<unsigned char[]> internalDataZeroInitialized(
size_t size);
 
  357   static boost::shared_ptr<unsigned char[]> externalData(
unsigned char[]);
 
  358   static boost::shared_ptr<unsigned char[]> emptyData(
bool external);
 
  376   long long fTimeStamp;
 
  379   boost::shared_ptr<unsigned char[]> fData;
 
  391   int fMaxNumberOfLayers;
 
  402   std::vector<ROI> fROIs;
 
  409 void computeRgbFromYuv( 
unsigned char * pYR, 
unsigned char * pUG, 
unsigned char * pVB );
 
  412 #endif  // _LIBALVISION_ALVISION_ALIMAGE_H_ 
void computeRgbFromYuv(unsigned char *pYR, unsigned char *pUG, unsigned char *pVB)
 
void setData(unsigned char *pData)
set the image data pointer to point to the specified buffer. 
 
bool computeYYYUUUVVVimageFromYUV422(const unsigned char *_dest)
 
bool setResolution(int pResolution)
set the Resolution of the image without changing the allocation size. 
 
unsigned int getSize() const 
 
bool setColorSpace(int pColorSpace)
set the ColorSpace of the image without changing the allocation size. 
 
void setTimeStamp(int pSeconds, int pMicroSeconds)
set the image timestamp 
 
ROI(int left, int top, int width, int height)
 
ALImage deepCopy()
data-ownership copy creation 
 
void setBottomAngle(const float bottomAngle)
 
int getResolutionFromSize(const int width, const int height)
Utility function that takes width and height as inputs and returns the corresponding resolution index...
 
float getRightAngle(void) const 
 
int getMaxResolution(void) const 
 
void setCameraId(char pCameraId)
set the ID of the camera that shot the picture 
 
bool setSize(int pResolution)
set the Resolution of the image without changing the allocation size. 
 
bool computeYYYYUUVVimageFromYUV422(const unsigned char *_dest)
 
void setAngles(const float leftAngle, const float topAngle, const float rightAngle, const float bottomAngle)
 
void setTopAngle(const float topAngle)
 
void setTimeStamp(const qi::os::timeval pTimeStamp)
set the image timestamp. 
 
const unsigned char * getData() const 
return the reference to the image data. 
 
int readFile(const char *_fileNameAndPath)
 
void setWidth(const int width)
 
int writeFile(const char *_fileNameAndPath)
 
void getAngles(float &leftAngle, float &topAngle, float &rightAngle, float &bottomAngle) const 
 
int getNbOfLayersMax(void) const 
 
const ROI * getROI(int index) const 
 
float getLeftAngle(void) const 
 
float getBottomAngle(void) const 
 
ALValue toALValue()
return an ALValue containing image structure 
 
void setHeight(const int height)
 
int savePPM(const char *_fileNameAndPath)
 
void setRightAngle(const float rightAngle)
 
int getResolution(void) const 
 
bool computeYUV422imageFromBGR(int height, int width, char *data)
 
bool areDataExternal(void) const 
 
int getHeight(void) const 
 
std::string toString(void) const 
 
void setTimeStamp(long long pTimeStamp)
set the image timestamp 
 
int getColorSpace(void) const 
 
bool isROIEnabled() const 
 
ALImage(int pWidth, int pHeight, int pColorSpace, bool pDataAreExternal=false, float pLeftAngle=0.f, float pTopAngle=0.f, float pRightAngle=0.f, float pBottomAngle=0.f)
constructor 
 
void setLeftAngle(const float leftAngle)
 
static ALImage * fromALValue(const ALValue &image)
Allocate an ALImage and return a pointer on it using an ALValue to fill it. 
 
unsigned char * getData()
return the pointer to the image data. 
 
float getTopAngle(void) const 
 
const unsigned char * getFrame() const 
return the reference to the image data. 
 
int getAllocatedSize() const 
 
bool computeBGRimageFromYUV422(const unsigned char *_dest)
 
int getNbLayers(void) const 
 
long long getTimeStamp(void) const 
 
unsigned char * getFrame()
return the pointer to the image data. 
 
void setEnableROIs(bool enable)
 
void addROI(const ROI &rect)