zoukankan      html  css  js  c++  java
  • Visual Studio基于CMake配置opencv1.0.0、opencv2.2

    Visual Studio基于CMake配置opencv1.0.0、opencv2.2

    2019-4-25 17:13:13

    原因

    现在最新opencv已经到4.0.1版了。用opencv1.0原因:

    • 小。源码包只有10M左右。
    • 清晰。他的文档结构清晰,不像OpenCV2时代开始越来越多的东西加进来但是文档也越来越多看不完。。
    • 很少有C++.比如没有Mat。因为希望在自己的项目中用纯C,即便用opencv也是用IplImage读取。

    打开工程

    opencv_100/_make/opencv.sln,用vs2013(vs2015, vs2017均可)打开它,选择升级项目。

    编译cvaux,报错error C2039: 'foreground_regions' : is not a member of 'CvGaussBGModel'

    解决:cvaux.h中,
    第1137行
    CvMemStorage* storage; /storage for 揻oreground_regions?/ /
    CvSeq
    foreground_regions /foreground object contours/

    改为如下形式:

    CvMemStorage* storage; /storage for foreground_regions/ /
    CvSeq* foreground_regions /foreground object contours/

    refs

    https://blog.csdn.net/cheng1988shu/article/details/5783623?locationNum=2&fps=1

    error LNK2026 module unsafe for SAFESEH image

    首先了解了下SAFESEH机制:SAFESEH是Safe Exception Handlers的缩写。/SAVEFEH是visual studio编译器对于x86平台才有的编译选项。

    在 Windows XP sp2 以及之后的版本中,微软引入了 S.E.H 校验机制 SafeSEH。SafeSEH 需要 OS 和 Compiler 的双重支持,二者缺一都会降低保护能力。通过启用 /SafeSEH 链接选项可心使编译好的程序具备 SafeSEH 功能(VS2003 及后续版本默认启用)。该选项会将所有异常处理函数地址提取出来,编入 SEH 表中,并将这张表放到程序的映像里。异常调用时,就与这张预先存好的表中的地址进行校验。

    如果说依赖的库没有开启SAFESEH,那么当前可执行/库也不能开这个选项。

    大概是ffmpeg、zlib等依赖在windows上的预编译包没有这个选项,所以opencv的VS工程中,各个项目都要关掉它(或者重新从源码编译各个依赖项,并确保开启SAFESEH开关):

    右键项目属性->链接器->高级->影响具有安全异常处理程序->改成“否(/SAFESEH:NO)”

    refs

    https://stackoverflow.com/questions/10599940/module-unsafe-for-safeseh-image-c

    https://blog.csdn.net/whatday/article/details/82976677

    https://blog.csdn.net/wujunokay/article/details/47168589

    各个项目编译无错,但是cvsample.exe找不到

    观察到了其实有警告,类似:

    warning MSB8012: TargetName(cvsample) does not match the Linker's OutputFile property value (cvsampled). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).

    原因:因为是从vc6.0项目升级到vs2013的,需要改一下输出文件位置

    具体做法:

    right click the project in solution explorer, select properties, in the pop-up: configuration properties, linker, general. Select Output file on the right, this gives a drop-down, select inherent from parent or project defaults. Click apply. This gives the default linker setting: ((OutDir))(TargetName)$(TargetExt). Re-build the project and the warning should no longer appear.

    refs

    https://stackoverflow.com/questions/4494028/warning-msb8012-make-sure-that-outdir-targetname-and-targetext-prope


    opencv 2.2.0的配置

    build/vs2015.bat:

    @echo off
    
    set BUILD_DIR=vs2015
    if not exist %BUILD_DIR% md %BUILD_DIR%
    
    cd %BUILD_DIR%
    
    cmake -G "Visual Studio 14 2015" ^
        -DBUILD_EXAMPLES=ON ^
        ../..
    
    pause
    

    contrib模块中bind2nd函数找不到,需要包含#头文件

  • 相关阅读:
    IPv6隧道技术——6to4实验分析
    IPV6地址解析与DAD机制实验分析
    交换机的高级特性
    组播IGMP实验分析
    BGP实验分析(二)
    BGP实验分析(一)
    路由策略实验分析(二)
    路由策略实验分析(一)
    一线互联网拼多多、饿了么、蚂蚁金服、哈啰出行、携程、饿了么、2345、百度等一些Java面试题
    Java中的匿名内部类
  • 原文地址:https://www.cnblogs.com/zjutzz/p/10769674.html
Copyright © 2011-2022 走看看