zoukankan      html  css  js  c++  java
  • OpenCV 学习笔记(1)WIN10+ VS2013 配置Opencv2413 64位

    VS2013 配置Opencv2413  64位

    系统变量 Path:  F:2biancheng_toolOpencv2413opencvuildx64vc12in

    用户变量:添加opencv变量,值: F:2biancheng_toolOpencv2413opencvuild

    工程目录的配置(Debug)

    找到属性管理器,如果找不到,请安装下图方法找到。双击Debug |X64打开如下窗口,

     

    设置如下:(下图红框项为设置项)

    0 可执行目录

    F:2biancheng_toolOpencv2413opencvuildx64vc12in

    1、包含目录:(VC++目录)

    F:2biancheng_toolOpencv2413opencvuildinclude

    F:2biancheng_toolOpencv2413opencvuildincludeopencv

    F:2biancheng_toolOpencv2413opencvuildincludeopencv2

    2、库目录:(VC++目录)

    F:2biancheng_toolOpencv2413opencvuildx64vc12lib

    可选配置 VS SDK(如果报错缺少kernel32.lib)

    C:Program Files (x86)Microsoft SDKsWindowsv7.1ALibx64

     额外声明:如果添加了还是提示缺少文件,那可能是VS没安装好导致环境windos sdk 环境配置出现问题,重新用微软官网资源安装一遍,不要随便乱用VS2013安装源。

    3、连接器->输入->附加依赖项:

    opencv_ml2413d.lib
    opencv_calib3d2413d.lib
    opencv_contrib2413d.lib
    opencv_core2413d.lib
    opencv_features2d2413d.lib
    opencv_flann2413d.lib
    opencv_gpu2413d.lib
    opencv_highgui2413d.lib
    opencv_imgproc2413d.lib
    opencv_legacy2413d.lib
    opencv_objdetect2413d.lib
    opencv_ts2413d.lib
    opencv_video2413d.lib
    opencv_nonfree2413d.lib
    opencv_ocl2413d.lib
    opencv_photo2413d.lib
    opencv_stitching2413d.lib
    opencv_superres2413d.lib
    opencv_videostab2413d.lib

    其实以上都是D:Program Filesopencvuildx86vc12lib下所有的lib文件,你会发现,有的后面带上d,有的没有d,这是因为Debug的就有d,Release则没有d。

    工程目录的配置(Release)

    其他与Debug一样,只是连接器->输入->附加依赖项不一样,设置如下:

    opencv_objdetect2413.lib
    opencv_ts2413.lib
    opencv_video2413.lib
    opencv_nonfree2413.lib
    opencv_ocl2413.lib
    opencv_photo2413.lib
    opencv_stitching2413.lib
    opencv_superres2413.lib
    opencv_videostab2413.lib
    opencv_calib3d2413.lib
    opencv_contrib2413.lib
    opencv_core2413.lib
    opencv_features2d2413.lib
    opencv_flann2413.lib
    opencv_gpu2413.lib
    opencv_highgui2413.lib
    opencv_imgproc2413.lib
    opencv_legacy2413.lib
    opencv_ml2413.lib

     

    测试代码一 读取图片

    #include <iostream>
    #include<core/core.hpp>
    #include<highgui/highgui.hpp>
    
    using namespace cv;
    using namespace std;
    
    int main()
    {
    	//读入图片,注意图片路径
    	//Mat image = imread("D:\Picture\lena.jpg");
    	Mat image = imread("timg.jpg");
    	
    
    	//图片读入成功与否判定
    	if (!image.data)
    	{
    		cout << "you idiot!where did you hide lena!" << endl;
    
    		//等待按键
    		system("pause");
    		return -1;
    	}
    
    	//创建一个名字为“Lena”的图像显示窗口,(不提前声明也可以)
    	namedWindow("Lena", 1);
    
    	//显示图像
    	imshow("Lena", image);
    
    	//等待按键
    	waitKey();
    	return 0;
    }
    

      

     测试二 读取视频

    #include <iostream>
    #include <opencv2/opencv.hpp>
    #include <opencv2/core/core.hpp>
    #include <opencv2/highgui/highgui.hpp>
    #include <opencv2/imgproc/imgproc.hpp>
    using namespace cv;
    
    int main()
    {
    	VideoCapture capture("C:\Desktop\1.avi");//读入视频文件
    
    	while (1)//循环显示每一帧
    	{
    		Mat frame;
    		capture >> frame;
    		namedWindow("未处理视频");
    		imshow("未处理视频", frame);
    		waitKey(30);
    
    		Mat edges;
    		cvtColor(frame, edges, CV_BGR2GRAY);//边缘化处理视频
    		blur(edges, edges, Size(7, 7));
    		Canny(edges, edges, 0, 30, 3);
    		namedWindow("处理后视频");
    		imshow("处理后视频", edges);
    		waitKey(30);
    	}
    	return 0;
    }
    

      

    测试三 1 读取实时视频

    #include <iostream>
    #include <opencv2/opencv.hpp>
    #include <opencv2/core/core.hpp>
    #include <opencv2/highgui/highgui.hpp>
    #include <opencv2/imgproc/imgproc.hpp>
    using namespace cv;
    
    int main()
    {
    
    	VideoCapture capture(0);//从摄像头读入图像
    	Mat edges;
    	while (1)
    	{
    		Mat frame;
    		capture >> frame;
    		namedWindow("未处理图像");
    		imshow("未处理图像", frame);
    
    				if (waitKey(30) >= 0)
    			break;
    	}
    	return 0;
    }
    

    测试三 2 读取实时视频  边缘检测

    #include <iostream>
    #include <opencv2/opencv.hpp>
    #include <opencv2/core/core.hpp>
    #include <opencv2/highgui/highgui.hpp>
    #include <opencv2/imgproc/imgproc.hpp>
    using namespace cv;
    
    int main()
    {
    
    	VideoCapture capture(0);//从摄像头读入图像
    	Mat edges;
    	while (1)
    	{
    		Mat frame;
    		capture >> frame;
    		namedWindow("未处理图像");
    		imshow("未处理图像", frame);
    
    		cvtColor(frame, edges, CV_BGR2GRAY);//将摄像头读入的图像转换成灰度图像输出
    		blur(edges, edges, Size(7, 7));
    		Canny(edges, edges, 0, 30, 3);
    		imshow("处理后图像", edges);
    		if (waitKey(30) >= 0)
    			break;
    	}
    	return 0;
    }
    

      

  • 相关阅读:
    Struts2中Date日期转换的问题
    IE SEESION共享的问题
    ORA-12518,TNS:listener could not hand off client connection
    TypeError: validator.settings[("on" + event.type)].call is not a function
    org.apache.ibatis.reflection.ReflectionException
    java.lang.IllegalArgumentException
    那些年,我追过的绘图工具
    spring使用rssfeed
    RSS Feeds with Spring Boot
    highcharts 动态生成x轴和折线图
  • 原文地址:https://www.cnblogs.com/kekeoutlook/p/7495568.html
Copyright © 2011-2022 走看看