Mac上搭建OpenCV(Java版)环境 发表于 2019-02-18 | 分类于 编程 , java 一、安装 MacPorts 1234567891011# 安装 Xcode 和 Xcode Command Line Tools # 同意 Xcode License sudo xcodebuild -license # 下载并安装 MacPorts for macOS Mojave v10.14 # 安装的过程需要断网, 安装完成后会自动配置好环境变量 https://www.macports.org/install.php # 更新 Ports Tree 和 MacPorts 版本 sudo port -v selfupdate 二、安装 OpenCV+Java 123456789101112# 安装 db48 sudo port selfupdate sudo port install db48 # 安装 opencv +java sudo port install opencv +java # 安装确认 port contents opencv | grep java # 出现以下结果表示安装完成 /opt/local/share/OpenCV/java/libopencv_java343.dylib /opt/local/share/OpenCV/java/opencv-343.jar 三、IDEA 中使用 添加依赖 12# File > Project Structure > Libraries > + /opt/local/share/OpenCV/java/ 配置 VM options 12# Run > Edit Configurations > VM options -Djava.library.path=/opt/local/share/OpenCV/java 测试 1234567891011import org.opencv.core.Core; public class OpenCV_Demo { static { System.loadLibrary(Core.NATIVE_LIBRARY_NAME); } public static void main(String[] args) { System.out.println("OpenCV version: " + Core.VERSION); } } 参考文章 Mac+OpenCV+IntelliJ+JAVA环境搭建 Mac+Java+openCV 配置详解 Mac中MacPorts安装和使用 The MacPorts Project