opencv 编译 -- 菜鸟学习记录,高手请绕道。

来源:互联网 发布:心动网络 手游 编辑:程序博客网 时间:2024/05/05 20:04

     初次接触一种东西,总是会遇到很多意想不到的问题,尤其是技术性的问题,细节多,规则也多,一步一个陷阱,能够尽快的理出思路,找到头绪,则是快速解决问题的关键。

     最近开始基础openCV,希望了解一点里面的算法,用于自己的产品中,然而,初次接触,再加上,是在之前很少接触的windows平台上,真是吃尽苦头。

     最近版本的openCV2.0提供的动态链接库,看是活生生的存在于bin目录下,编译链接,运行程序时却总是提示找不到,而VS的提示也让人摸不着头脑,明明是某函数不能加载,却提示成另外一个函数找不到。一气之下,打算重新编译一下opencv。

    由于也是初次使用微软的编译环境,一切都得学习,于是百度+google,然而搜到的内容大多是将如何配置一个使用opencv进行应用开发的配置,很少有文章涉及opencv的编译。想来技术这种事情本来就是,对于过来人,举重若轻,对于菜鸟,真是泰山压顶!

   经历了很长时间的闭门羹后,终于还是在opencv自带的doc目录下,发现了编译的提示:

              http://opencv.willowgarage.com/wiki/InstallGuide

windows和linux的步骤混合在一起。看起来也不轻松, 下面是我整理后的步骤(一共11步):

     <!-- /* Font Definitions */ @font-face{font-family:宋体;panose-1:2 1 6 0 3 1 1 1 1 1;mso-font-alt:SimSun;mso-font-charset:134;mso-generic-font-family:auto;mso-font-pitch:variable;mso-font-signature:3 135135232 16 0 262145 0;}@font-face{font-family:"/@宋体";panose-1:2 1 6 0 3 1 1 1 1 1;mso-font-charset:134;mso-generic-font-family:auto;mso-font-pitch:variable;mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal{mso-style-parent:"";margin:0cm;margin-bottom:.0001pt;text-align:justify;text-justify:inter-ideograph;mso-pagination:none;font-size:10.5pt;mso-bidi-font-size:12.0pt;font-family:"Times New Roman";mso-fareast-font-family:宋体;mso-font-kerning:1.0pt;} /* Page Definitions */ @page{mso-page-border-surround-header:no;mso-page-border-surround-footer:no;}@page Section1{size:612.0pt 792.0pt;margin:72.0pt 90.0pt 72.0pt 90.0pt;mso-header-margin:36.0pt;mso-footer-margin:36.0pt;mso-paper-source:0;}div.Section1{page:Section1;} /* List Definitions */ @list l0{mso-list-id:214780764;mso-list-type:hybrid;mso-list-template-ids:-1823177122 844908758 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}@list l0:level1{mso-level-tab-stop:18.0pt;mso-level-number-position:left;margin-left:18.0pt;text-indent:-18.0pt;}ol{margin-bottom:0cm;}ul{margin-bottom:0cm;}-->

build the openCV step by step:

1.     download the openCV and installit, assuming: D:/Program Files/OpenCV2.0

2.     download the cmake and installit.

3.     download VS studio and installit

4.     create a directory under theopencv directory: D:/Program Files/OpenCV2.0/release

5.     >cd D:/ProgramFiles/OpenCV2.0

6.     execute D:/ProgramFiles/OpenCV2.0 ../

7.     the cmake will generate theproject files for VS under D:/Program Files/OpenCV2.0/release

get thefollowing output:

D:/Program Files/OpenCV2.0/release>cmake-D:CMAKE_BUILD_TYPE=RELEASE ../

-- Building for: Visual Studio 8 2005

-- Check for working C compiler: D:/ProgramFiles/Microsoft Visual Studio/VC98/B

in/CL.EXE

-- Check for working C compiler: D:/ProgramFiles/Microsoft Visual Studio/VC98/B

in/CL.EXE -- works

-- Detecting C compiler ABI info

-- Detecting C compiler ABI info - done

-- Check for working CXX compiler:D:/Program Files/Microsoft Visual Studio/VC98

/Bin/CL.EXE

-- Check for working CXX compiler:D:/Program Files/Microsoft Visual Studio/VC98

/Bin/CL.EXE -- works

-- Detecting CXX compiler ABI info

-- Detecting CXX compiler ABI info - done

-- Could NOT find PythonInterp  (missing: PYTHON_EXECUTABLE)

-- Could NOT find PythonLibs  (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)

-- IPP detected:

-- Parsing 'cvconfig.h.cmake'

CMake Warning (dev) at CMakeLists.txt:689(if):

  givenarguments:

 

   ""

 

  Anargument named "" appears in a conditional statement.  Policy CMP0012 is

  notset: if() recognizes numbers and boolean constants.  Run "cmake

 --help-policy CMP0012" for policy details.  Use the cmake_policy command to

  setthe policy and suppress this warning.

This warning is for projectdevelopers.  Use -Wno-dev to suppress it.

 

CreateProcessError: The system cannot findthe file specified.

 

for command: mkdir -p "D:/ProgramFiles/OpenCV2.0/release/unix-install/"

CreateProcessError: The system cannot findthe file specified.

 

for command: mkdir -p "D:/ProgramFiles/OpenCV2.0/release/win-install/"

--

-- General configuration for opencv 2.0.0=====================================

--

--    Compiler:

--    C++ flags (Release):       /DWIN32 /D_WINDOWS /W4 /Zm1000 /EHsc /GR /D

_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS

 /Wp64 /openmp /Gy  /MD /O2 /Ob2 /D NDEBUG  /Zi

--     C++ flags (Debug):          /DWIN32 /D_WINDOWS /W4 /Zm1000 /EHsc/GR  /D

_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS

 /Wp64 /openmp /Gy  /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1

--    Linker flags (Release):    /STACK:10000000 /machine:I386   /INCREMENTAL

:NO /debug

--    Linker flags (Debug):      /STACK:10000000 /machine:I386   /debug /INCR

EMENTAL:YES

--

--  Interfaces:

--    Old Python:                0

--    Python:                    ON

--    Use IPP:                   NO

--    Build Documentation        0

--

--    Install path:             D:/Program Files/OpenCV2.0/release

--

--    cvconfig.h is in:         D:/Program Files/OpenCV2.0/release

-------------------------------------------------------------------

--

-- Configuring done

-- Generating done

-- Build files have been written to:D:/Program Files/OpenCV2.0/release

 

8.     get into directory release andopen the VS, compile all

9.     after complete the compile, theThere are several directories will be created under the D:/ProgramFiles/OpenCV2.0/release:

     D:/ProgramFiles/OpenCV2.0/release/lib/debug – the leading description of the opencv dlls

     D:/ProgramFiles/OpenCV2.0/release/bin/debug – the dll directory, adding it to the PATHenvironment variable.

    

10.  start to use the openCV forbuild one’s own application, create a VS project,

“配置属性”---“连接器”---“常规”的“附件库目录”:

D:/ProgramFiles/OpenCV2.0/release/lib/debug

Add followinglibs to “配置属性”---“连接器”---“输入”的“附加依赖项”

 "cv200d.lib "

"cvaux200d.lib"

"cvhaartraining.lib"

"cxcore200d.lib"

"cxts200d.lib"

"highgui200d.lib"

"ml200d.lib"

"opencv_ffmpeg200d.lib"

"libml200.dll.a"

11.  environment is ok now, you getthe ball.

原创粉丝点击