转自: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() );}
}

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

转载于:https://www.cnblogs.com/liushaobo/p/4373733.html

Using OpenCV Java with Eclipse相关推荐

  1. java配置opencv_在Windows中使用OpenCV Java与Eclipse

    自2.4.4版本以来,OpenCV支持Java.在本教程中,我将介绍如何设置在Windows中使用OpenCV Java与Eclipse的开发环境,以便您可以享受垃圾回收,非常可重构(重命名变量,提取 ...

  2. 在Eclipse中使用OpenCV Java

    在Eclipse中使用OpenCV Java 在Eclipse中使用OpenCV Java 配置Eclipse 测试新Java项目上的配置 运行具有OpenCV和MKL依赖关系的Java代码 在Ecl ...

  3. opencv 裁剪 java_如何在opencv java中裁剪检测到的面部图像

    我在 java中使用opencv 2.4.10检测到图像中的面部 我把我的面部检测代码. import org.opencv.core.Core; import org.opencv.core.Mat ...

  4. opencv java 摄像头_使用OpenCV Java创建Windows摄像头扫码程序

    OpenCV提供了一些基本的Webcam控制接口.用OpenCV C/C++或者Python,可以在任意平台快速创建一个摄像头预览应用.然而使用Java,情况就复杂的多,因为OpenCV Java并没 ...

  5. opencv java ubuntu_Ubuntu 16.04配置OpenCV 3.1.0 for Java

    我们都知道,OpenCV是基于C++的开源计算机视觉库,但是从2.4.4版本开始提供了Java绑定,也就是说,我们也可以使用Java来开发基于OpenCV的计算机视觉应用.目前,最新的版本是3.1.0 ...

  6. OpenCV Java入门五 结合摄像头识脸和拍照

    随着我们对环境.Mat基本使用越来越熟练.Java Swing也逐步熟悉了起来.今天我们开始进入OpenCV驱动摄像头的几个使用场景. 环境准备 准备好一个USB外接摄像头,我这边使用的有两种,一种是 ...

  7. OpenCV Java入门一 在MAC系统上安装OpenCV

    OpenCV网上讲的一个都不对,要么卡死电脑,要么训练模型写死,要么都只是显示显示人脸就说入门了.没有一个从安装.使用.驱动摄像头.训练模型.辩别人脸的全过程.最夸张的是连怎么安装个OpenCV的资料 ...

  8. OpenCV Java入门三 Mat的基本操作

    环境好了,我们就可以进入正文了. 在之前入门一.二中分别已经有画图的两个例子了.但没有细节展开我们的代码和OpenCV到底在干什么. 使用OpenCV时你需要补充的知识 你需要熟练使用Java Swi ...

  9. OpenCV Java入门二 在Windows10系统上安装OpenCV

    准备好痛苦了没有? 痛苦之后是欢乐.因为必竟大多人还是用的WINDOWS来开发的居多.因此如果OpenCV无法在Win10下安装,一样不能起到普及作用. 而Windows下的编译安装OpenCV也是最 ...

最新文章

  1. 上下位机通讯协议_上位机与下位机的区别通讯
  2. MML命令_华为TD-LTE后台常用MML命令操作
  3. ubuntu swift mysql_使用 Swift 3.0 操作 MySQL 数据库
  4. NSString 字符串 操作 常用
  5. 销毁AWS资源:Cloud-Nuke还是AWS-Nuke?
  6. [Jmeter] 基本使用的总结
  7. python watchdog的使用_python watchdog监控文件修改
  8. 双十一淘宝、京东服务器瘫痪大揭秘 感悟
  9. java 包装类缺点_Java 自动拆箱和自动装箱学习笔记
  10. 2022年ps应该选择哪个版本
  11. Flutter 与 RN对比
  12. Netty的深入浅出--79.Netty官方Reference Counted Objects文档说明
  13. java敌人发射子弹
  14. 浅谈学习编程语言的心得与体会
  15. IE 10 SCRIPT5022: InvalidCharacterError错误解决办法
  16. Intent Service 和Service的区别
  17. 电脑重装详细步骤(win10)
  18. 神经网络的前向和反向传播
  19. EMV规范(八)——持卡人验证(CVM)二
  20. IM即时通讯-从0到1的实践(一)

热门文章

  1. 2. 线性表的顺序结构
  2. [leetcode]62. 不同路径
  3. PHP注入漏洞(附代码,具体步骤)
  4. bzoj 3611: [Heoi2014]大工程(虚树+树形DP)
  5. 51nod-1350:斐波那契表示
  6. 组素数 蓝桥填空题2013省赛
  7. Python实现对于文件的分类
  8. python基本定制之__new__, __init__
  9. 2017-10-湖南套题1
  10. 20145202马超《网络对抗》Exp8 Web基础