• 如何配置OpenCV


    一、所需软件

    开发工具VS2010

    opencv-2.4.9(安装路径为:D/opencv/...)

    二、配置环境变量

        路径:“计算机->属性->高级系统设置->环境变量->用户变量”,path变量后面添加如下内容:

    ";D:opencvuildx64vc10in;"

    注意:分号不要忘记添加;添加完新变量后,重启一下电脑。

    确定保存。

    三、新建一个工程项目

    1、新建一个Visual C++/Win32 控制台应用程序myOpenCV

    Win32 应用程序向导最后一步中,附加选项"空项目"勾选上,完成。

    2、在"解决方案资源管理器"中,右键工程名myOpenCV/属性,打开属性页窗体。左侧选择"配置属性/VC++目录",在右侧的包含目录、库目录中编辑,具体内容如下:

    包含目录:

    D:opencvuildinclude

    D:opencvuildincludeopencv;D:opencvuildincludeopencv2

    库目录:

    D:opencvuild x64vc10

    D:opencvuild x64vc10in

    D:opencvuild x64vc10lib

        同时,要把右上方的"平台"更改为"活动(x64)"。

    3、还是在属性页窗体中,左侧选择"配置属性/链接器/输入",在右侧的附加依赖项中编辑,添加如下内容:(249代表版本2.4.9)

    配置Debug:

    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_ml249d.lib

    opencv_objdetect249d.lib

    opencv_ts249d.lib

    opencv_video249d.lib
    配置Release:

    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

    opencv_objdetect249.lib

    opencv_ts249.lib

    opencv_video249.lib

    注:所粘贴内容即为D:opencvuildx86vc10lib下库文件名字;241表明为opencv版本号OpenCV-2.4.1,若为231即为opencv版本号OpenCV-2.3.1;Debug文件库名有d结尾,Release没有,如 opencv_ts241d.lib和 opencv_ts241.lib

        配置完成后,确定,退出属性页。

    4、在"解决方案资源管理器/源文件"中,右键新建一个C++文件mainForm.cpp。将一个名称为"10.jpg"的图片文件放到工程目录下面。在mainForm.cpp中添加如下代码,运行即可看到图片显示成功!

    代码如下:

    #include <opencv2opencv.hpp>
    #include <iostream>
    #include <string>
    using namespace cv;
    using namespace std;
    int main()
    {
        Mat img = imread("10.jpg");
        if(img.empty())
        {
            cout<<"error";
            return -1;
        }
        imshow("第一张照片",img);
        waitKey();
    
        return 0;
    }
  • 相关阅读:
    严重: Parse error in application web.xml file at jndi:/localhost/ipws/WEBINF/web.xml java.lang.NoSuchMethodException: org.apache.catalina.deploy.WebXml
    Failed to install .apk on device 'emulator5554': timeout解决方法
    java.lang.NoClassDefFoundError:org.jsoup.Jsoup
    Conversion to Dalvik format failed: Unable to execute dex:解决方法
    apache Digest: generating secret for digest authentication ...
    Description Resource Path Location Type Project has no default.properties file! Edit the project properties to set one.
    android service随机自启动
    MVC3 安装部署
    EF 4.3 CodeBased 数据迁移演练
    SQL Server 2008开启sa账户
  • 原文地址:https://www.cnblogs.com/3sxiaofu/p/4066558.html
Copyright © 2020-2023  润新知