这里分类和汇总了欣宸的全部原创(含配套源码):https://github.com/zq2599/blog_demos
sudo apt-get install -y unzip build-essential curl cmake cmake-gui git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_311
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
export ANT_HOME=/usr/local/apache-ant-1.9.16
export PATH=$ANT_HOME/bin:$PATH
will@hp:~$ java -version
java version "1.8.0_311"
Java(TM) SE Runtime Environment (build 1.8.0_311-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.311-b11, mixed mode)
will@hp:~$ ant -version
Apache Ant(TM) version 1.9.16 compiled on July 10 2021
curl -fL -o opencv-4.1.1.zip https://codeload.github.com/opencv/opencv/zip/4.1.1; \
unzip opencv-4.1.1.zip; \
rm -rf opencv-4.1.1.zip; \
mkdir opencv-4.1.1/build; \
mkdir opencv-4.1.1/build/install
cmake -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=OFF -D CMAKE_INSTALL_PREFIX=./install ..
-- Python (for build): /usr/bin/python2.7
--
-- Java:
-- ant: /usr/local/apache-ant-1.9.16/bin/ant (ver 1.9.16)
-- JNI: /usr/lib/jvm/jdk1.8.0_311/include /usr/lib/jvm/jdk1.8.0_311/include/linux /usr/lib/jvm/jdk1.8.0_311/include
-- Java wrappers: YES
-- Java tests: YES
--
-- Install to: /home/will/temp/202110/30/003/opencv-4.1.1/build/install
-- -----------------------------------------------------------------
--
-- Configuring done
-- Generating done
-- Build files have been written to: /home/will/temp/202110/30/003/opencv-4.1.1/build
make -j6
bin include lib share
opencv4/
├── libopencv_java411.so
└── opencv-411.jar
package com.company;
import org.opencv.core.Core;
import org.opencv.core.Mat;
import static org.opencv.highgui.HighGui.*;
import static org.opencv.imgcodecs.Imgcodecs.imread;
public class Main {
public static void main(String[] args) {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
Mat mat = imread("/home/will/temp/202110/30/pics/111.png");
if(mat.empty()) {
System.out.println("Image not exists!");
return;
}
namedWindow("src", WINDOW_AUTOSIZE);
imshow("src", mat);
waitKey(0);
// 这一句很重要,否则按下任意键后看不到窗口关闭的效果
System.exit(0);
}
}
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://blog.csdn.net/boling_cavalry/article/details/121069372
内容来源于网络,如有侵权,请联系作者删除!