在OpenCV中最常包含的静态库为opencv.hpp,cxcore.h,highgui.h
OpenCV中IplImage结构体最重要的参数为width,height,imagedata,nchannels
1、读取图像函数cvLoadImage(””)
2、新建图像函数cvCreateImage (size,depth,channels)
3、创建窗口函数cvNamedWindow
4、在指定窗口中显示图像 cvShowImage
5、将彩色图像转化为黑白图像cvCvtColor
5、等待按键事件 cvWaitKey
这几个函数的应用:
#include"stdafx.h"
#include<opencv.hpp>
#include<cxcore.h>
#include<highgui.h>
#include<stdio.h>
int main()
{
#if 0
cv::Mat image=cv::imread("lena.jpg");//读入一张图片
cv::imshow("Test for Opencv2.4.9",image);//显示一张图片
cv::waitKey();
#else
IplImage *ImageInfo = cvLoadImage("1.jpg");
unsignedshort mWide = ImageInfo->width;
unsignedshort mHeight = ImageInfo->height;
unsignedchar *ImageData = (unsignedchar*)ImageInfo->imageData;
unsignedchar nChannel = ImageInfo->nChannels;
IplImage *GrayImage = cvCreateImage(cvSize(mWide,mHeight),8,1);
cvCvtColor(ImageInfo,GrayImage,CV_RGB2GRAY);
printf("mWide = %d\r\n mHeight = %d\r\n nChannel = %d\r\n",mWide,mHeight,nChannel);
cvNamedWindow("the Image of show:");
cvShowImage("the Image of show:",ImageInfo);
cvNamedWindow("the GrayImage of show:");
cvShowImage("the GrayImage of show:",GrayImage);
cvWaitKey(-2);
#endif
return 0;
}