转自:http://docs.opencv.org/trunk/doc/tutorials/introduction/java_eclipse/java_eclipse.html
Using OpenCV Java with Eclipse
Since version 2.4.4 OpenCV supports Java. In this tutorial I will explain how to setup development environment for using OpenCV Java with Eclipse inWindows, so you can enjoy the benefits of garbage collected, very refactorable (rename variable, extract method and whatnot) modern language that enables you to write code with less effort and make less mistakes. Here we go.
Configuring Eclipse
First, obtain a fresh release of OpenCV from download page and extract it under a simple location like C:\OpenCV-2.4.6\. I am using version 2.4.6, but the steps are more or less the same for other versions.
Now, we will define OpenCV as a user library in Eclipse, so we can reuse the configuration for any project. Launch Eclipse and selectWindow –> Preferences from the menu.
Navigate under Java –> Build Path –> User Libraries and clickNew....
Enter a name, e.g. OpenCV-2.4.6, for your new library.
Now select your new user library and click Add External JARs....
Browse through C:\OpenCV-2.4.6\build\java\ and selectopencv-246.jar. After adding the jar, extend theopencv-246.jar and select Native library location and pressEdit....
Select External Folder... and browse to select the folderC:\OpenCV-2.4.6\build\java\x64. If you have a 32-bit system you need to select thex86 folder instead of x64.
Your user library configuration should look like this:
Testing the configuration on a new Java project
Now start creating a new Java project.
On the Java Settings step, under Libraries tab, select Add Library... and select OpenCV-2.4.6, then click Finish.
Libraries should look like this:
Now you have created and configured a new Java project it is time to test it. Create a new java file. Here is a starter code for your convenience:
- import org.opencv.core.Core;
- import org.opencv.core.CvType;
- import org.opencv.core.Mat;
- public class Hello
- {
- public static void main( String[] args )
- {
- System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
- Mat mat = Mat.eye( 3, 3, CvType.CV_8UC1 );
- System.out.println( "mat = " + mat.dump() );
- }
- }
import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat; public class Hello
{
public static void main( String[] args )
{
System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
Mat mat = Mat.eye( 3, 3, CvType.CV_8UC1 );
System.out.println( "mat = " + mat.dump() );
}
}
When you run the code you should see 3x3 identity matrix as output.
That is it, whenever you start a new project just add the OpenCV user library that you have defined to your project and you are good to go. Enjoy your powerful, less painful development environment :)
Help and Feedback
You did not find what you were looking for?
- Ask a question on the Q&A forum.
- If you think something is missing or wrong in the documentation, please file abug report.
转自:http://docs.opencv.org/trunk/doc/tutorials/introduction/java_eclipse/java_eclipse.html
Using OpenCV Java with Eclipse(转)的更多相关文章
-
利用Eclipse使用Java OpenCV(Using OpenCV Java with Eclipse)
最近在上计算机视觉这门课程用到了OpenCV,于是找到了"Using OpenCV Java with Eclipse"这篇博文,是英文的,我将它翻译如下与大家分享 正文: 从2. ...
-
Using OpenCV Java with Eclipse
转自:http://docs.opencv.org/trunk/doc/tutorials/introduction/java_eclipse/java_eclipse.html Using Open ...
-
How to decompile class file in Java and Eclipse - Javap command example(转)
Ability to decompile a Java class file is quite helpful for any Java developer who wants to look int ...
-
ubuntu下安装java和eclipse
java安装 1 下载jdk http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html 2 ...
-
Java基础-Eclipse第三方安装包管理工具之Maven
Java基础-Eclipse第三方安装包管理工具之Maven 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 玩过Linux的小伙伴应该都知道yum吧,我们只要把搭建好的yum仓库配 ...
-
java基础-Eclipse开发工具介绍
java基础-Eclipse开发工具介绍 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 所谓工欲善其事必先利其器,即将身为一名Java开发工程师怎么能没有一款好使的IDE呢?今天就 ...
-
java web eclipse中项目的加载过程
java web eclipse中项目的加载过程: Tomcat默认从WEB-INF/目录下加载资源,Eclipse在发布程序的时候,并没有把User Libraries的相关资源拷贝到WEB-INF ...
-
Android学习八---OpenCV JAVA API
OpenCV java API的文档说明在OpenCV-2.4.10-android-sdk/sdk/java/javadoc/index.html的文件夹下. 想用java API的方式进行Open ...
-
WIN7系统JavaEE(java+tomcat7+Eclipse)环境配置
https://jingyan.baidu.com/article/3a2f7c2e62d25e26afd611fa.html WIN7系统JavaEE(java+tomcat7+Eclipse)环境 ...
随机推荐
-
Mac 自带 apache
1.启动服务器 sudo apachectl start http://localhost 能访问就ok sudo apachectl stop sudo apachectl restart ht ...
-
C++-函数模板特化如何避免重复定义
我正在用一个基于模板的库源代码,该库包含一些针对特定类型的模板函数特化.类模板,函数模板和模板函数特化都在头文件中.我在我的.cpp文件中 #include 头文件并编译链接工程.但是为了在整个工程 ...
-
Mysql中将查询出来的多列的值用逗号拼接
select group_concat(字段名) from 表名
-
关于mysql下hibernate实体类字段与数据库关键字冲突的问题
好久没写了,都忘记博客了,趁着现在还在公司,写的东西是经过验证的,不是在家凭记忆力写的,正确率有保障,就说说最近遇到的一件事情吧. 以前一直用的oracle数据库,这次项目我负责的模块所在的系统是用的 ...
-
hdu_2844_Coins(多重背包)
题目连接:hdu_2844_Coins 题意:给你n个硬币的价值和对应的数量,问你从1到m有那些数能组合出来 题解:如果我们将硬币的价值看成一个物品的容量和价值,那么对应1-m,如果dp[i]==i, ...
-
asp.net中listview下嵌套gridview
最近在上软件工程实践课程,想做一个类似于QQ空间或者朋友圈一样的效果.即显示所有好友发送的动态以及动态下回复的信息. 自己YY了一种方法,一开始以为不能达到效果,研究了2个小时终于实现了,感觉效果还是 ...
-
又趟一个坑,IO卡信号DI和DO的信号类型
工控IO卡可以感应到各种电信号,传感器的状态变化. DI信号包括数字开关信号(ture,false\0,1),光信号的变化(上升沿,下降沿). DO信号包括脉宽和数字开关信号(ture,false\0 ...
-
(第十二周)final预发布视频
项目名:食物链教学工具 组名:奋斗吧兄弟 组长:黄兴 组员:李俞寰.杜桥.栾骄阳.王东涵 Final阶段视频发布 平台:优酷 链接:http://v.youku.com/v_show/id_XMTg0 ...
-
VS2017编译boost库
1.http://www.boost.org/ 下载boost库. 2.解压到 D:\ProgramFiles\boost 3.环境配变量配置 VS2017更加注重跨平台性,安装文件较 ...
-
Ubuntu Docker安装
docker容器改变apt-get源 记得先:apt-get update 进入容器 cd /etc/apt echo "">sources.list echo " ...