转自: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:

  1. import org.opencv.core.Core;
  2. import org.opencv.core.CvType;
  3. import org.opencv.core.Mat;
  4. public class Hello
  5. {
  6. public static void main( String[] args )
  7. {
  8. System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
  9. Mat mat = Mat.eye( 3, 3, CvType.CV_8UC1 );
  10. System.out.println( "mat = " + mat.dump() );
  11. }
  12. }
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(转)的更多相关文章

  1. 利用Eclipse使用Java OpenCV(Using OpenCV Java with Eclipse)

    最近在上计算机视觉这门课程用到了OpenCV,于是找到了"Using OpenCV Java with Eclipse"这篇博文,是英文的,我将它翻译如下与大家分享 正文: 从2. ...

  2. Using OpenCV Java with Eclipse

    转自:http://docs.opencv.org/trunk/doc/tutorials/introduction/java_eclipse/java_eclipse.html Using Open ...

  3. 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 ...

  4. ubuntu下安装java和eclipse

    java安装 1 下载jdk http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html 2 ...

  5. Java基础-Eclipse第三方安装包管理工具之Maven

    Java基础-Eclipse第三方安装包管理工具之Maven 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 玩过Linux的小伙伴应该都知道yum吧,我们只要把搭建好的yum仓库配 ...

  6. java基础-Eclipse开发工具介绍

    java基础-Eclipse开发工具介绍 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 所谓工欲善其事必先利其器,即将身为一名Java开发工程师怎么能没有一款好使的IDE呢?今天就 ...

  7. java web eclipse中项目的加载过程

    java web eclipse中项目的加载过程: Tomcat默认从WEB-INF/目录下加载资源,Eclipse在发布程序的时候,并没有把User Libraries的相关资源拷贝到WEB-INF ...

  8. Android学习八---OpenCV JAVA API

    OpenCV java API的文档说明在OpenCV-2.4.10-android-sdk/sdk/java/javadoc/index.html的文件夹下. 想用java API的方式进行Open ...

  9. WIN7系统JavaEE(java+tomcat7+Eclipse)环境配置

    https://jingyan.baidu.com/article/3a2f7c2e62d25e26afd611fa.html WIN7系统JavaEE(java+tomcat7+Eclipse)环境 ...

随机推荐

  1. JVM内存管理 (转)

    一.物理内存与虚拟内存1.物理内存                (1)RAM        所谓物理内存就是我们通常所说的RAM(随机存储器).        (2)寄存器        在计算机中 ...

  2. HUNNU11342:Chemistry(模拟)

    http://acm.hunnu.edu.cn/online/?action=problem&type=show&id=11342 Problem description The ch ...

  3. Qt调用Delphi编写的COM组件

    这个问题捣鼓了两天,现在终于解决了,做个笔记分享给大家,以免走弯路 起初,我的想法是在DLL中写一个interface并从函数中导出这个interface,像这样的代码 ICom1 = interfa ...

  4. Mac OS X将CSV格式转换为Excel文档格式,Excel转CSV中文乱码问题

    一:在Mac上假设你使用Excel打开windows导出的CSV格式文档.你会发现表格中全部的的内容都显示在A列. 那么,怎样恢复正常呢,你能够将CSV格式的文档导入到Excel文档中,这样就正常显示 ...

  5. xcode6 cocos2dx开玩笑git和github学习记录

    1. git Xcode4开始,它一直Git作为一个内置的源代码控制(Source Control)工具,所以对于新项目的用途git要管理非常方便.在新建项目向导.可以直接选择Git作为源控制工具.项 ...

  6. arch Failed to load module "intel"

    arch启动x的时候出现问题困扰我一天了,终于解决掉了. 错误如下: [ 61.086] (II) LoadModule: "intel" [ 61.087] (WW) Warni ...

  7. WPF入门介绍

    Windows Vista已经于2007年1月30正式发行零售版本,安装Vista的计算机将会大量出现.在Vista时代,身为编程员,就一定要具备Vista桌面应用开发的能力.而开发Vista桌面应用 ...

  8. Windows调试工具入门—1

    NetRoc http://www.DbgTech.net 引子 Debugging Tools for Windows是微软发布的一套用于软件调试的工具包(后面如果没有指明,那么我会使用WinDbg ...

  9. Linux程序设计学习笔记----多线程编程线程同步机制之相互排斥量(锁)与读写锁

    相互排斥锁通信机制 基本原理 相互排斥锁以排他方式防止共享数据被并发訪问,相互排斥锁是一个二元变量,状态为开(0)和关(1),将某个共享资源与某个相互排斥锁逻辑上绑定之后,对该资源的訪问操作例如以下: ...

  10. Cocos2dx 3.0 过渡篇(三十)灰机还是3D好(Sprite3D)

    如今都非常少发3.0过渡篇这一系列的博文了,原因是多方面的,一个是游戏开发进度,尽管上面并没给我什么压力,但我自己一直在赶.还有一方面是个人私生活这块.五月份确实是多事之秋,有时候真的没办法全心思去研 ...