7 #ifndef _LIBALVISION_ALVISION_ALIMAGE_H_
8 #define _LIBALVISION_ALVISION_ALIMAGE_H_
22 typedef struct _IplImage IplImage;
32 ROI(
int left,
int top,
int width,
int height);
33 ROI(
int left,
int top,
int width,
int height,
34 float leftAngle,
float topAngle,
35 float rightAngle,
float bottomAngle);
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);
100 static ALImage* fromALValue(
const ALValue& image);
102 inline void setWidth(
const int width ) { fWidth = width; }
103 inline void setHeight(
const int height ) { fHeight = height; }
104 inline void setLeftAngle(
const float leftAngle ) { fFOV.leftAngle = leftAngle; }
105 inline void setTopAngle(
const float topAngle ) { fFOV.topAngle = topAngle; }
106 inline void setRightAngle(
const float rightAngle ) { fFOV.rightAngle = rightAngle; }
107 inline void setBottomAngle(
const float bottomAngle ) { fFOV.bottomAngle = bottomAngle; }
108 inline void setAngles(
const float leftAngle,
const float topAngle,
109 const float rightAngle,
const float bottomAngle )
110 { fFOV.leftAngle = leftAngle; fFOV.topAngle = topAngle;
111 fFOV.rightAngle = rightAngle; fFOV.bottomAngle = bottomAngle; }
140 { assert( fData != 0);
141 std::cout <<
"getFrame() is deprecated. Please replace by getData()." << std::endl;
149 inline const unsigned char*
getData()
const { assert( fData != 0);
return fData; }
158 { assert( fData != 0);
159 std::cout <<
"getFrame() is deprecated. Please replace by getData()." << std::endl;
167 inline unsigned char*
getData() { assert( fData != 0);
return fData; }
174 inline void setData(
unsigned char* pData) { fData = pData; }
183 if( (pTimeStamp.tv_usec < 0) || (pTimeStamp.tv_sec < 0) )
195 inline void setTimeStamp(
long long pTimeStamp) { fTimeStamp = pTimeStamp; }
205 fTimeStamp = (
long long)pSeconds*1000000LL + (
long long)pMicroSeconds;
214 inline void setCameraId(
char pCameraId) { fCameraId = pCameraId; }
221 inline unsigned int getSize()
const {
return fWidth*fHeight*fNbLayers; }
226 inline int getWidth(
void )
const {
return fWidth; }
227 inline int getHeight(
void )
const {
return fHeight; }
228 inline int getResolution(
void )
const {
return (fWidth==640) ? kVGA : (fWidth==320)?kQVGA:kQQVGA; }
229 inline int getColorSpace(
void )
const {
return fColorSpace; }
230 inline int getNbLayers(
void )
const {
return fNbLayers; }
231 inline long long getTimeStamp(
void )
const {
return fTimeStamp; }
232 inline char getCameraId()
const {
return fCameraId; }
233 inline int getMaxResolution(
void )
const {
return fMaxResolution; }
234 inline int getNbOfLayersMax(
void )
const {
return fMaxNumberOfLayers; }
235 inline bool areDataExternal(
void )
const {
return fDataAreExternal; }
236 int getAllocatedSize()
const {
return fAllocatedSize; }
237 inline float getLeftAngle(
void )
const {
return fFOV.leftAngle; }
238 inline float getTopAngle(
void )
const {
return fFOV.topAngle; }
239 inline float getRightAngle(
void )
const {
return fFOV.rightAngle; }
240 inline float getBottomAngle(
void )
const {
return fFOV.bottomAngle; }
241 inline void getAngles(
float& leftAngle,
float& topAngle,
float& rightAngle,
float& bottomAngle )
242 { leftAngle = fFOV.leftAngle; topAngle = fFOV.topAngle;
243 rightAngle = fFOV.rightAngle; bottomAngle = fFOV.bottomAngle; }
248 std::string toString(
void )
const;
250 int getNumOfROIs()
const {
return (
int)fROIs.size(); }
252 const ROI* getROI(
int index)
const {
253 if (index < 0 || index >= getNumOfROIs())
255 return &(fROIs[index]);
258 void addROI(
const ROI& rect) {
259 fROIs.push_back(rect);
266 void setEnableROIs(
bool enable) {
267 fROIEnabled = enable;
270 bool isROIEnabled()
const {
275 int writeFile(
const char* _fileNameAndPath);
276 int readFile(
const char* _fileNameAndPath);
277 int savePPM(
const char* _fileNameAndPath);
280 bool computeYUV422imageFromBGR(IplImage* _src);
281 bool computeYUV422imageFromBGR(
int height,
int width,
char *data);
282 bool computeBGRimageFromYUV422(
const unsigned char* _dest);
283 bool computeYYYUUUVVVimageFromYUV422(
const unsigned char* _dest);
284 bool computeYYYYUUVVimageFromYUV422(
const unsigned char* _dest);
286 bool reallocateDataSize(
const int resolution,
const int nbLayers);
304 long long fTimeStamp;
307 unsigned char* fData;
319 int fMaxNumberOfLayers;
323 bool fDataAreExternal;
334 std::vector<ROI> fROIs;
341 void computeRgbFromYuv(
unsigned char * pYR,
unsigned char * pUG,
unsigned char * pVB );
344 #endif // _LIBALVISION_ALVISION_ALIMAGE_H_