JavaCV开发环境的配置
一.安装opencv2.4.4、测试
http://www.opencv.org.cn/index.php/Download#Version_2.4.4
运行OpenCV-2.4.4.exe,就是解压,把它解压到一个你喜欢的地方 ——
1.1 路径最好不要太深,点啊点的最讨厌了
2. 添加 ***\OpenCV2.4.4\build\x64\vc11\bin; 到环境变量的PATH后面 ——
2.1 ***是你放OpenCV2.4.4的地方
2.2 x64还是x86的问题;32位系统只能选择x86,64位系统可以考虑把两条路径都放到环境变量里
2.3 很欣慰的是,OpencCV2.4.4的build里面终于有vc11的编译结果了,vc11对应的就是vs2012
2.4 bin里是动态链接库,放到环境变量里系统才能找到
3. 新建一个vs2012 visual c++的工程
4. 在工程属性里面,vc++directories中修改include 和 library directories,路径分别为
***\OpenCV2.4.4\build\include;
***\OpenCV2.4.4\build\include\opencv;
***\OpenCV2.4.4\build\include\opencv2;
$(IncludePath)
以及
***\OpenCV2.4.4\build\x64\vc11\lib;
$(LibraryPath)
这里lib路径中关于x64和vc11的选择和上面是一样的
图1:
以上Debug和Release一样
不一样的是:
Debug下,修改linker->input里面的附加依赖项为:
opencv_calib3d244d.lib
opencv_contrib244d.lib
opencv_core244d.lib
opencv_features2d244d.lib
opencv_flann244d.lib
opencv_gpu244d.lib
opencv_haartraining_engined.lib
opencv_highgui244d.lib
opencv_imgproc244d.lib
opencv_legacy244d.lib
opencv_ml244d.lib
opencv_nonfree244d.lib
opencv_objdetect244d.lib
opencv_photo244d.lib
opencv_stitching244d.lib
opencv_ts244d.lib
opencv_video244d.lib
opencv_videostab244d.lib
Release下,修改linker->input里面的附加依赖项为:
opencv_calib3d244.lib
opencv_contrib244.lib
opencv_core244.lib
opencv_features2d244.lib
opencv_flann244.lib
opencv_gpu244.lib
opencv_highgui244.lib
opencv_imgproc244.lib
opencv_legacy244.lib
opencv_ml244.lib
opencv_nonfree244.lib
opencv_objdetect244.lib
opencv_photo244.lib
opencv_stitching244.lib
opencv_ts244.lib
opencv_video244.lib
opencv_videostab244.lib
图2:
5. 编写个OpenCV界的Hello world,召唤lena女神出来show一下吧
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
using namespace cv;
int main()
{
IplImage* img;
img = cvLoadImage("lena.bmp");
cvShowImage("Show", img);
cvWaitKey(0);
return 0;
}
图3:
附:
0. 如果弹出提示说系统找不到 ********244d.dll之类的,可能是环境变量路径的问题
1. 如果系统说未解析的外部符号 __cvLoadImage 之类的,查查是不是工程在release模式下但是没配置,或者工程平台在win32下但是配置文件是64位的路径
二.使用JavaCV (前提步骤一测试成功)
下载,并解压。。。很多jar包
https://code.google.com/p/javacv/downloads/detail?name=javacv-0.4-bin.zip
用eclipse新建一个java程序
对着
项目右键- 〉构建路径-〉配置构建路径-〉库-〉导入外部JAR 选择刚刚解压出来的几个jar包
代码:
public class Smoonther { public static void main(String[]args) { IplImage image=cvLoadImage("d:\\lena.jpg"); cvShowImage("show",image); cvWaitKey(0); return ; } }
还有另外一种设置方法:http://blog.csdn.net/haoba1987/article/details/8175390
祝你成功