2.1安装Opencv2.4.9,见文件夹\下载
2.2 添加环境变量
2.3Vs2013配置Opencv2.4.9
VS2013新建空白工程
2.3Vs2013配置Opencv2.4.9
VS2013新建空白工程
VC++目录
包含目录
库目录
附加依赖库
freeglut.lib
glew32.lib
glew32s.lib
opencv_ml249d.lib
opencv_calib3d249d.lib
opencv_contrib249d.lib
opencv_core249d.lib
opencv_features2d249d.lib
opencv_flann249d.lib
opencv_gpu249d.lib
opencv_highgui249d.lib
opencv_imgproc249d.lib
opencv_legacy249d.lib
opencv_objdetect249d.lib
opencv_ts249d.lib
opencv_video249d.lib
opencv_nonfree249d.lib
opencv_ocl249d.lib
opencv_photo249d.lib
opencv_stitching249d.lib
opencv_superres249d.lib
opencv_videostab249d.lib
opencv_objdetect249.lib
opencv_ts249.lib
opencv_video249.lib
opencv_nonfree249.lib
opencv_ocl249.lib
opencv_photo249.lib
opencv_stitching249.lib
opencv_superres249.lib
opencv_videostab249.lib
opencv_calib3d249.lib
opencv_contrib249.lib
opencv_core249.lib
opencv_features2d249.lib
opencv_flann249.lib
opencv_gpu249.lib
opencv_highgui249.lib
opencv_imgproc249.lib
opencv_legacy249.lib
opencv_ml249.lib
3、测试代码及结果显示:
Opencv
#include"stdafx.h"
#include
#include
#include
using namespace cv;
int main()
{
// 读入一张图片(demo)
Mat img = imread("lean.jpg");
// 创建一个名为 "demo"窗口
cvNamedWindow("demo");
// 在窗口中显示demo
imshow("demo", img);
// 等待6000 ms后窗口自动关闭
waitKey(0);
}
OPenGL:
#include "stdafx.h"
#include
#include
#include
//#include
#include
#include
#include
#include
//画图 -白色正方形
void display(void){
glClear(GL_COLOR_BUFFER_BIT);//清除。GL_COLOR_BUFFER_BIT表示清除颜色
glColor3f(1.0, 1.0, 1.0);//白色//设置颜色,类型是float型的,参数值的范围是[0.0,1.0]
glBegin(GL_POLYGON);//glBegin()与glEnd()函数之间多次连续调用颜色函数,那么,只会显示出最后一次的颜色// GL_POLYGON 绘制了一个凸多边形。顶点1到n定义了这个多边形
glVertex3f(0.25, 0.25, 0.0);// 指定顶点的值,3代表三维坐标
glVertex3f(0.75, 0.25, 0.0);
glVertex3f(0.75, 0.75, 0.0);
glVertex3f(0.25, 0.75, 0.0);
glEnd();
glFlush();//刷新,将缓冲区数据输出
}
void init(void){
glClearColor(0.0, 0.0, 0.0, 0.0);//黑色背景
glMatrixMode(GL_PROJECTION);//将当前矩阵指定为投影矩阵,GL_PROJECTION 投影, GL_MODELVIEW 模型视图, GL_TEXTURE 纹理.//使用透视(3D).那么先要设置透视投影
glLoadIdentity();//矩阵设为单位矩阵
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);//glOrtho是创建一个正交平行的视景体
//glOrtho(left, right, bottom, top, near, far), left表示视景体左面的坐标,right表示右面的坐标,bottom表示下面的,top表示上面的。
}
int main(int argc, char** argv){
glutInit(&argc, argv);//对GLUT进行初始化
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);//设置显示方式,其中GLUT_RGB表示使用RGB颜色,与之对应的还有GLUT_INDEX(表示使用索引颜色)。GLUT_SINGLE表示使用单缓冲,与之对应的还有GLUT_DOUBLE(使用双缓冲)
glutInitWindowPosition(100, 100);//窗口位置
glutInitWindowSize(250, 250);//窗口大小
//glutInitWindowSize(500, 500);//窗口大小
glutCreateWindow("OpenGL");//窗口命名
init();
glutDisplayFunc(display);//设置一个函数,当需要进行画图时,这个函数就会被调用
glutMainLoop();//进行一个消息循环,显示窗口,并且等待窗口关闭后才会返回
return 0;
}
4、Ending