OpenCV 3.0.0 JAR 中缺少 HighGUI

2022-09-01 04:02:41

我正在编译支持Java的OpenCV 3.0.0。我的脚本是:

mkdir /opt/opencv /opt/opencv/opencv-build
cd /opt/opencv
git clone https://github.com/Itseez/opencv.git 
cd /opt/opencv/opencv-build
export OPENCV_INSTALL_PATH=/opt/opencv
export FFMPEG_PATH=/opt/ffmpeg/ffmpeg_build/lib
export LD_LIBRARY_PATH=$OPENCV_INSTALL_PATH/lib:$FFMPEG_PATH:/opt/opencv/opencv/3rdparty/lib:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=/opt/ffmpeg/ffmpeg_build/lib/pkgconfig
cmake28 -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX="/opt/opencv" \
        -D OPENCV_EXTRA_C_FLAGS="-DHAVE_CAMV4L -DHAVE_CAMV4L2" \
        -D WITH_OPENCL=OFF -D BUILD_SHARED_LIBS=OFF ../opencv
make
make install

正如在 http://docs.opencv.org/doc/tutorials/introduction/desktop_java/java_dev_intro.html 中所说。-D BUILD_SHARED_LIBS=OFF

当我想测试安装时,我发现没有Highgui类,也没有路径。这是我的文件夹内容:opencv-300.jarorg.opencv

calib3d
core
features2d
imgcodecs
imgproc
ml
objdetect
photo
utils
video
videoio

我在安装过程中是否遗漏了某些内容?


答案 1

从 OpenCV 2.x 迁移到 3.0.0 (Java)

Highgui.imread(fileName, Highgui.CV_LOAD_IMAGE_GRAYSCALE)
Highgui.imread(fileName)

成为 resp:

Imgcodecs.imread(fileName, Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE)
Imgcodecs.imread(fileName)

此外,绘图功能,例如:

Core.circle(..), Core.line(..), etc..

已移至:

Imgproc.circle(..), Imgproc.line(..)

注意时刻,3.0.0 中缺少 HuMoments。将在 3.1 中看到错误修复


答案 2

简短的回答:Java中不再有3.0的模块了。HighGUI

长一:中的功能已拆分为两个附加模块:HighGUI

  1. videoio (VideoCapture, VideoWriter).
  2. imgcodecs (imread/imwrite and friends).

由于没有向Java公开的GUI功能,因此不再需要在Java中使用HighGUI模块。


推荐