http://blog.csdn.net/qiao_198911/article/details/37694081
之所以还是搭建开发环境,是因为javacv0.8 包的组织方式,有了较大的变动,具体变化可以官网:http://bytedeco.org/ 查看
1、In your build files, replace the com.googlecode.javacpp and com.googlecode.javacv groups with org.bytedeco. You may also have to add a couple of additional dependencies based on the new organization of the artifacts for the JavaCPP Presets.
2、Rename import statements based on the following mapping:
com.googlecode.javacpp --> org.bytedeco.javacpp
com.googlecode.javacv.cpp --> org.bytedeco.javacpp
com.googlecode.javacv --> org.bytedeco.javacv
3、For code that uses the C++ API of OpenCV, adjust the object types as follows:
CvMat and IplImage --> Mat
CvRect --> Rect
CvPoint --> Point
CvPoint2D32f --> Point2f
CvPoint3D32f --> Point3f
CvPoint2D64f --> Point2d
CvPoint3D64f --> Point3d
CvSize --> Size
CvSize2D32f --> Size2f
CvBox2D --> RotatedRect
CvScalar --> Scalar
大部分配置是一样的,但是有变化,具体什么变化可以慢慢去发现。
1、下载javacv0.8对应的windows版本:opencv2.4.9.exe。地址:http://opencv.org/downloads.html
2、右键解压该exe文件,将解压后的文件,复制到一个磁盘目录(该磁盘目录不要包含中文字符)
3、新建java工程javacv0.8
4、在eclipse的Window-->Preferences中找到Java ---->Build Path ---->User Library ---->New ;新建一个用户库,命名为javacv0.8min
5、为javacv0.8min添加JARS:Add External JARS。选择你下载的的javacv0.8包中的:javacpp-0.8.jar、javacv-0.8.jar、opencv-2.4.9-0.8.jar、opencv-2.4.9-0.8-windows-x86_64.jar(或者opencv-2.4.9-0.8-windows-x86.jar)
6、配置新建的工程的编译路径Java Build Path 选择Add Library ---->User Library 勾选第四步新建的javacv0.8min;然后,为JRE System Library选择Native Library location的路径;这个路径是opencv库的路径,精确到bin文件夹,例如我的是C:/opencv-2.4.9/opencv/build/x64/vc10/bin
7、环境搭配完毕,测试代码如下:
package com.proces; import org.bytedeco.javacpp.opencv_core.IplImage; import static org.bytedeco.javacpp.opencv_highgui.*; import static org.bytedeco.javacpp.opencv_core.cvReleaseImage; public class ReadImage { public static void main(String[] args) { //读取图像 IplImage srcImg=cvLoadImage("D:\\newxvqing.jpg"); if (srcImg !=null) { //新建窗体,并命名 cvNamedWindow("test0.8"); //展示图像 cvShowImage("test0.8",srcImg); //等待按键,以执行下一步 cvWaitKey(0); //释放图像空间 cvReleaseImage(srcImg); //销毁窗体 cvDestroyWindow("test0.8"); } } }
9、用到jar包下载地址:
http://download.csdn.net/detail/qiao_198911/7621635