【Rayeager PX2分享】编译源代码安装OpenCV
已有 464 次阅读2015-4-10 17:09
[color=#434343][color=#000000][font=宋体]【更新软件源】[/font][/color][/color]
[color=#434343][color=#000000]sudo apt-get update[/color][/color]
[color=#434343][color=#000000][font=宋体]【安装相关依赖项】[/font][/color][/color]
[color=#434343][color=#000000]sudo apt-get install build-essential[/color][/color]
[color=#434343][color=#000000]sudo apt-get install cmake[/color][/color]
[color=#434343][color=#000000]sudo apt-get install libgtk2.0-dev[/color][/color]
[color=#434343][color=#000000]sudo apt-get install pkg-config[/color][/color]
[color=#434343][color=#000000]sudo apt-get install python-dev python-numpy[/color][/color]
[color=#434343][size=1][font= ][color=#000000]sudo apt[/color][color=#000000]-get install libavco[/color][color=#000000]dec-dev libavformat-dev libswscale-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev[/color][/font][/size][/color]
[color=#434343][size=1][font= ][/font][/size][/color]
[color=#434343][color=#000000][font=宋体]【获取源代码】[/font][/color][/color]
[color=#434343][color=#000000][font=宋体]新建[/font][/color][color=#000000]opencv[/color][color=#000000][font=宋体]目录[/font][/color][/color]
[color=#434343][color=#000000]sudo mkdir opencv[/color][/color]
[color=#434343][color=#000000]cd opencv[/color][/color]
[backcolor=#ffffff][color=#434343][font=color:#000000]sudo wget [url]http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.11/opencv-2.4.11.zip/download[/url][/font][/color][/backcolor][backcolor=#ffffff][color=#434343][font=Arial, 宋体, Verdana, sans-serif][/font][/color][/backcolor][color=#434343]
[/color]
[color=#434343][size=1][font= ][img]http://bbs.ickey.cn/plugins/pubs/kindeditor/attached/image/20150329/20150329192236_42989.png[/img][/font][/size][/color]
[color=#434343][size=1][font= ][size=1][font= ][/font][/size][/font][/size][/color]
[color=#434343][color=#000000][font=宋体]下载下来的文件名为[/font][/color][color=#000000]download,[/color][color=#000000][font=宋体]改名为[/font][/color][color=#000000]opencv-2.4.11.zip[/color][/color]
[color=#434343][color=#000000]sudo mv download opencv-2.4.11.zip [/color]
[/color]
[color=#434343][color=#000000][font=宋体]解压,获得一个名为[/font][/color][color=#000000]opencv-2.4.10[/color][color=#000000][font=宋体]的文件夹[/font][/color][/color]
[color=#434343][color=#000000]sudo unzip opencv-2.4.11.zip[/color]
[/color]
[color=#434343][color=#000000][font=宋体]进入[/font][/color][color=#000000]opencv[/color][color=#000000][font=宋体]源代码目录,在该目录中新建一个名为[/font][/color][color=#000000]release[/color][color=#000000][font=宋体]的文件夹[/font][/color][/color]
[color=#434343][color=#000000]sudo mkdir release[/color][/color]
[color=#434343][color=#000000]cd release[/color][/color]
[color=#434343][color=#000000][font=宋体]在[/font][/color][color=#000000]release[/color][color=#000000][font=宋体]文件夹中,使用[/font][/color][color=#000000]cmake[/color][color=#000000][font=宋体]工具在该文件夹中生成[/font][/color][color=#000000]makefile[/color][color=#000000][font=宋体]文件,指定[/font][/color][color=#000000]opencv[/color][color=#000000][font=宋体]的安装目录为[/font][/color][color=#000000]/usr/local[/color][color=#000000][font=宋体],[/font][/color][color=#000000]opencv[/color][color=#000000][font=宋体]的源代码位于上一层目录[/font][/color][/color]
[backcolor=#ffffff][color=#434343][font=color:#000000]sudo cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..[/font][/color][/backcolor][backcolor=#ffffff][color=#434343][font=Arial, 宋体, Verdana, sans-serif][/font][/color][/backcolor][color=#434343]
[/color]
[color=#434343][size=1][font= ][size=1][font= ][size=1][font= ][/font][/size][/font][/size][img]http://bbs.ickey.cn/plugins/pubs/kindeditor/attached/image/20150329/20150329192401_70211.png[/img][/font][/size][/color]
[color=#434343][size=1][font= ][img]http://bbs.ickey.cn/plugins/pubs/kindeditor/attached/image/20150329/20150329192409_91074.png[/img]
[/font][/size][/color]
[color=#434343][color=#000000][font=宋体]【编译源代码】[/font][/color][/color]
[backcolor=#ffffff][color=#434343][font=color:#000000]sudo make[/font][/color][/backcolor][backcolor=#ffffff][color=#434343][font=Arial, 宋体, Verdana, sans-serif][/font][/color][/backcolor][color=#434343]
[/color]
[color=#434343][size=1][font= ][img]http://bbs.ickey.cn/plugins/pubs/kindeditor/attached/image/20150329/20150329192452_56602.png[/img][/font][/size][/color]
[color=#434343][size=1][font= ][color=#000000][font=宋体]编译完成,时间大概[/font][/color][font=color:#000000]2.5[/font][color=#000000][font=宋体]个小时[/font][/color][color=#000000],记得以前在BeagleBone Black上编译了5个小时[/color][/font][/size][/color]
[color=#434343][size=1][font= ][img]http://bbs.ickey.cn/plugins/pubs/kindeditor/attached/image/20150329/20150329192555_35884.png[/img][/font][/size][/color]
[color=#434343][size=1][font= ]
[/font][/size][/color]
[color=#434343][color=#000000][font=宋体]编译完成后[/font][/color][/color]
[backcolor=#ffffff][color=#434343][font=color:#000000]sudo make install[/font][/color][/backcolor][backcolor=#ffffff][color=#434343][font=Arial, 宋体, Verdana, sans-serif][/font][/color][/backcolor][color=#434343]
[/color]
[color=#434343][size=1][font= ][img]http://bbs.ickey.cn/plugins/pubs/kindeditor/attached/image/20150329/20150329192639_69384.png[/img][/font][/size][/color]
[color=#434343][size=1][font= ]
[/font][/size][/color]
[color=#434343][color=#000000][font=宋体]更新搜索动态链接库[/font][/color][/color]
[backcolor=#ffffff][color=#434343][font=color:#000000]sudo ldconfig[/font][/color][/backcolor][backcolor=#ffffff][color=#434343][font=Arial, 宋体, Verdana, sans-serif][/font][/color][/backcolor][color=#434343]
[/color]
[color=#434343][size=1][font= ][color=#000000]安装完成。[/color][/font][/size][/color]
[color=#434343][size=1][font= ][color=#000000]
[/color][/font][/size][/color]
[font=Arial, 宋体, Verdana, sans-serif]转自Ickey电子工程社区 fjjjnk1234[/font]