Mac上安装openCV(Java版本)
详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt410
Install and use OpenCV 3.0 on Mac OS X with Eclipse (Java)
A final year student is currently working on a Java project in Eclipse using OpenCV . As this is something that other students have asked me, this is a summary of what we have done by putting together a few tutorials available online:
Prerequisites: Mac OS X 10.10 and XCode 6. Before starting the installation, make sure you have:
Apache Ant installed. You can install Ant using Homebrew. If you don’t have Homebrew, install it using the following command:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Then, update brew with brew update and finally install Ant with brew install ant
Make sure you have CMake installed. You can download a binary file for Mac here: http://www.cmake.org/download/ After extracting the .dmg file, copy it to the /Applications/ folder.
If you have Ant and CMake installed, download OpenCV 3.0 for Mac from this link: http://opencv.org/downloads.html. Extract the file and this will create a new directory called
opencv-3.0.0/ (or something similar if you use a more recent version). Open a terminal and navigate to this directory. You can now start the compilation process:
Run cmake with the following command:
/Applications/CMake.app/Contents/bin/cmake CMakeLists.txt. It shouldn’t take long. Check the output and make sure that java is listed as one of the modules to be installed.Type make and go for a cup of tea, the compilation process will require a few minutes…
If everything goes well you should be able to compile everything and you can now start Eclipse. I’m using Eclipse Luna but I guess the process is very similar for other versions. Following the instructions available at http://docs.opencv.org/doc/tutorials/introduction/java_eclipse/java_eclipse.html, let’s create a user library and add it to a project that will make use of OpenCV:
In Eclipse, open the menu Eclipse -> Preferences -> Java -> Build Path -> User Libraries. Click “New” and enter a name, I’m using opencv-3.0.0.

Click on the name of the library so that it becomes blue, then click on the right on “Add external JARs”. Browse to the directory where you have compiled OpenCV, open the bin/ directory and select “opencv-300.jar”. The screen should look more or less like this:

Now click on Native library location (None) so that it becomes blue, then click on Edit and you should get something similar to this:

Click on “External Folder…”, and again select the directory where you have compiled OpenCV and click on the lib/ directory. Confirm and press OK (3 times).
If you want to use the OpenCV Java API you need to create an Eclipse (Java) project and add the library created above:
Select File -> New -> Java Project. You can use any name you want, say opencv-test.
Right-click on the newly created project, select properties, then Library -> Add Library… -> User Library. Tick “opencv-3.0.0″, press finish and then OK.
You are now ready to test that everything went well. You can start with the following simple code taken from http://docs.opencv.org/doc/tutorials/introduction/java_eclipse/java_eclipse.html:
import org.opencv.core.Core;import org.opencv.core.CvType;import org.opencv.core.Mat; public class Hello{
|
If this code works it should print a simple matrix. If you want to try something slightly more interesting, you could try to detect a face with the following code, taken from https://blog.openshift.com/day-12-opencv-face-detection-for-java-developers/ and adapted for OpenCV 3 (make sure to change the string constants in the source code below!)
import org.opencv.core.Core;import org.opencv.core.Mat;import org.opencv.core.MatOfRect;import org.opencv.core.Point;import org.opencv.core.Rect;import org.opencv.core.Scalar;import org.opencv.imgcodecs.Imgcodecs;import org.opencv.imgproc.Imgproc;import org.opencv.objdetect.CascadeClassifier; public class FaceDetector { public void run() { System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
|
Mac上安装openCV(Java版本)的更多相关文章
- Mac上如何降级Java版本
升级到了Java9,有些工具就不工作了.因此要降级到Java8.方法: /Library/Java/JavaVirtualMachines/下的高版本SDK即可
- MAC OSX安装多个版本的JAVA(jdk jre通用)
MAC自带的jdk1.6是苹果公司自己修改的jdk版本,被广泛应用于各种mac软件,具有不可替代性:同时,java1.7和1.8有时也需要用到.因此,在mac上安装.使用多个版本的java具有重要意义 ...
- JDK简介和mac下安装和查看版本命令
1.什么是JDK? JDK:Java Development Kit,是 Java 语言的软件开发工具包(SDK).没有JDK的话,无法编译Java程序(指java源码.java文件). SE(Jav ...
- window下在同一台机器上安装多个版本jdk,修改环境变量不生效问题处理办法
window下在同一台机器上安装多个版本jdk,修改环境变量不生效问题处理办法 本机已经安装了jdk1.7,而比较早期的项目需要依赖jdk1.6,于是同时在本机安装了jdk1.6和jdk1.7. 安装 ...
- 在Mac上安装IntelliJ IDEA
这篇文章旨在介绍如何在Mac系统上安装IntelliJ IDEA,至于IntelliJ IDEA的介绍和使用方法,大家另行查阅,本篇的文章不再详细阐述. 简短解说,IntelliJ IDEA是可以用来 ...
- Mac上安装brew
用过ubuntu系统的都知道,上面有一个命令apt-get 很方便可以快速的安装很多软件 特别lamp环境 都是一键安装. 在mac上也有类似的命令 brew brew用法可以访问官网地址 http ...
- Mac上安装Charles进行抓包全流程设置
安装 -- 官网下载最新版的Charles版本,按照提示安装即可 破解 -- https://blog.csdn.net/qq_25821067/article/details/79848589. M ...
- Mac上安装PHP、Apache、MySQL
Mac自带php5.6版本,要升级到php7.3 步骤如下 1,brew 安装php ,如果没有安装,访问https://brew.sh/index_zh-cn安装在终端输入以下内容,不用指定安装ph ...
- 002-docker安装-mac上安装docker,17.06在CentOS7 64位机器上安装
一.mac上安装docker 1.下载 通过这个链接下载:https://download.docker.com/mac/stable/Docker.dmg 2.安装 将 Moby 的鲸鱼图标拖拽到 ...
随机推荐
- JavaSE(五)JAVA对象向上转型和向下转型
今天做了一个测试的题目,发现自己还是很多问题没有静下心来做.很多问题是可以自己解决的但是自己一是没有读清题意,二是自己心里太急躁了.所以这个要自己应以为鉴! 对象的转型问题其实并不复杂,我们记住一句话 ...
- python-继承类执行的流程
在读python数据机构与算法, 发现了下面这个例子, 之前没有碰到过, 记录下来 In [17]: class A: def f(self): self.g() def g(self): print ...
- 利用AD采集获取外部温度传感器的值
#include "led.h" #include "delay.h" #include "key.h" #include "sy ...
- [小北De编程手记] Lesson 01 - AutoFramework构建 之 从一个简单的Demo聊起
写在最前面 这个系列的主旨是要跟大家分享一下关于自动化测试框架的构建的一些心得.这几年,做了一些自动化测试框架以及团队的构建的工作.过程中遇到了很多这样的同学,他们在学习了某一门语言和一些自动化测试的 ...
- Exception in thread "main" java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
这个问题当然是找不到mysql的驱动类,可能是环境CLASSPATH有问题或者就是那个人没有加载jdbc的驱动.我在网上下载mysql-connector-java-5.0.8-bin.jar一个这个 ...
- 从Javascript单线程谈Event Loop
假如面试回答js的运行机制时,你可能说出这么一段话:"Javascript的事件分同步任务和异步任务,遇到同步任务就放在执行栈中执行,而碰到异步任务就放到任务队列之中,等到执行栈执行完毕之后 ...
- TensorFlow学习笔记2——数据类型及简单运算
0. 小试牛刀 首先,激活tensorflow环境( source activate tensorflow ),随后在ipython里: import tensorflow as tf sess = ...
- 2017年05月10日记一次微项目投产 | 安卓版微信内置浏览器不能解析gzip压缩过的mp4视频的问题
前言 今天投产了一个小项目,一个很简单的H5,有播放视频功能,使用了videojs插件. 之前也做过数个视频播放,视频的转压都按照既定流程进行,文件放到FTP后,iphone和安卓机测试下来都没有问题 ...
- Java企业微信开发_07_素材管理之上传本地临时素材文件
一.本节要点 1.临时素材有效期 media_id是可复用的,同一个media_id可用于消息的多次发送(3天内有效) 2.上传文件时的http请求里都有啥 具体原理可参看: 为什么上传文件的表单需要 ...
- Redis集群之配置文件详解(待完善)
运维Redis集群的核心任务就是配置文件Redis.conf 命令行将现使用的Redis配置参数导出到 redis.conf.bak文件 .conf > redis.conf.bak 查看文件内 ...