I just started learning OpenCV with "Learning OpenCV Computer Vision with the OpenCV Library".
In the first example which demonstrates how to display a picture, it has a line
IplImage* img = cvLoadImage("name.type")
Although the book explains it, I still do not fully know what exactly IplImage* img
does.
Does cvLoadImage loads the image to img which IplImage is pointing to? Can anyone explain this to me please? Thank you
img
is the name of the variable, might as well be blahblahblah
;
IplImage
is the type of the variable, it's just a struct
that contains the image data itself plus some info (size, color depth, etc.) on the image;
typedef struct _IplImage {
int nSize;
int ID;
int nChannels;
int alphaChannel;
int depth;
char colorModel[4];
char channelSeq[4];
int dataOrder;
int origin;
int align;
int width;
int height;
struct _IplROI* roi;
struct _IplImage* maskROI;
void* imageId;
struct _IplTileInfo* tileInfo;
int imageSize;
char* imageData;
int widthStep;
int BorderMode[4];
int BorderConst[4];
char* imageDataOrigin;
} IplImage;
For more info on IplImage
: Other question about IplImage
cvLoadImage
provides a pointer to an IplImage
, which means it creates an IplImage when it loads it and returns you it's emplacement.Do not forget to do cvReleaseImage(&img)
when you are finished with it, if you do not want to have memory leaks.