之前看了opencv载入图像,在这里总结一下。
#include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <cv.h>
#include <highgui.h>
int main(int argc, char *argv[])
{
IplImage* img = 0;
int height,width,step,channels;
uchar *data;
int i,j,k;
// 载入图像
img=cvLoadImage("E:\\生物识别\\原图像\\IMG_0008.jpg");
if(!img)
{
printf("Could not load image file: %s/n",argv[1]);
exit(0);
}
// 获取图像信息
height = img->height;
width = img->width;
step = img->widthStep;
channels = img->nChannels;
data = (uchar *)img->imageData;
// 创建窗口
cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE);
cvMoveWindow("mainWin", 100, 100);
// 显示图像
cvShowImage("mainWin", img );
cvWaitKey(0);
cvReleaseImage(&img );
return 0;
}