0 下载与安装 (Windows下) https://opencv.org/:
选择喜欢的版本安装,opencv3.4以后支持深度学习API
![【OpenCV Java】opencv官方java例程演示(Windows下)_第1张图片](http://img.e-com-net.com/image/info8/e737fb13ccd847cf8982fbc295dea3e3.jpg)
![【OpenCV Java】opencv官方java例程演示(Windows下)_第2张图片](http://img.e-com-net.com/image/info8/d0360530a2344a3f9ac3cdb05746e7b4.jpg)
![](http://img.e-com-net.com/image/info8/4deb42320182473583cb67cc1658abad.png)
![【OpenCV Java】opencv官方java例程演示(Windows下)_第3张图片](http://img.e-com-net.com/image/info8/5c84ea12817e4a318908c9093ef07b50.jpg)
1 环境搭建 OpenCV Java with Eclipse:https://docs.opencv.org/trunk/d1/d0a/tutorial_java_eclipse.html
问题1:搭建opencv4.0环境失败:
Exception in thread "main" java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_eye(III)J
at org.opencv.core.Mat.n_eye(Native Method)
at org.opencv.core.Mat.eye(Mat.java:507)
at zeng.hello_opencv.main(hello_opencv.java:10)
解决方案:将opencv4.0.0 换成opencv3.4.2(本文使用),不报错
opencv java 官方文档与API位置 https://docs.opencv.org/3.4.4/
![【OpenCV Java】opencv官方java例程演示(Windows下)_第4张图片](http://img.e-com-net.com/image/info8/7e1148658d6f4afe93fa9efb3d4a21c3.jpg)
2 JAVA示例代码 (Windows下)
【代码位置】……opencv3.4.4/sources/samples/java/tutorial_code/
![【OpenCV Java】opencv官方java例程演示(Windows下)_第5张图片](http://img.e-com-net.com/image/info8/f4e61ac536ab4b80b022e2d81ded8a48.jpg)
【代码中示例图片位置】……opencv3.4.4/sources/data/
![【OpenCV Java】opencv官方java例程演示(Windows下)_第6张图片](http://img.e-com-net.com/image/info8/97d0cb8cce1e44d285ff014df3f50ac4.jpg)
【运行代码 AddingImages.java】 samples\java\tutorial_code\core\AddingImages
[
【运行例子会报错,图片路径不对】
![](http://img.e-com-net.com/image/info8/04e5cc30129a4a8684978c87f49ec569.png)
![](http://img.e-com-net.com/image/info8/490e895dfc384e97b435c510f804a9a6.jpg)
【问题】使用自己图片,大小不一样,报错,
CvException [org.opencv.core.CvException: cv::Exception: OpenCV(3.4.4) C:\build\3_4_winpack-bindings-win64-vc14-static\opencv\modules\core\src\arithm.cpp:663: error: (-209:Sizes of input arguments do not match) The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array' in function 'cv::arithm_op'
【解决方案】导入两张 一样大小 的图片,混合比为0.6
效果(图片自己下载)
![【OpenCV Java】opencv官方java例程演示(Windows下)_第8张图片](http://img.e-com-net.com/image/info8/f9b559048a47435f8087db9750c1c9ff.jpg)
![【OpenCV Java】opencv官方java例程演示(Windows下)_第9张图片](http://img.e-com-net.com/image/info8/54ab500ecdea41eabceb777f1a9be1a2.jpg)
【参考原理】https://blog.csdn.net/poem_qianmo/article/details/20911629
![](http://img.e-com-net.com/image/info8/ddd9c670248142cda6c63271cfb526e2.png)
![](http://img.e-com-net.com/image/info8/0dc0a9f4423948599936589963644896.jpg)
【程序:core.mat_operations.java】:仅做演示作用,不能运行
( /* Snippet code for Operations with images tutorial (not intended to be run) */)
【程序,features2D:akaze_matching.java】
【问题】无法导入 org.opencv.xfeatures2d.SURF
【解决方法】SURF and SIFT algorithms doesn't work in OpenCV 3.0 Java
【程序 轨迹条与图片加权的混合】AddingImagesTrackbar.java
Eclipse中输入系统变量和运行参数
![【OpenCV Java】opencv官方java例程演示(Windows下)_第10张图片](http://img.e-com-net.com/image/info8/f2dd2b34f98d49b6a32ecf850b7e41ed.jpg)
【程序 Histograms_Matching.histogram_calculation 】
![【OpenCV Java】opencv官方java例程演示(Windows下)_第11张图片](http://img.e-com-net.com/image/info8/21ba8d47d1f04449a992509c7dd6f2df.jpg)
【程序 灰度均衡化】histogram_equalization.java(图片是自己的)
【程序 画基本的几何图形】ImgProc.BasicGeometricDrawing.java
![【OpenCV Java】opencv官方java例程演示(Windows下)_第12张图片](http://img.e-com-net.com/image/info8/144201ca90a14d498d3db692532a5cc0.jpg)
【程序 调整对比度与亮度】ImgProc.changing_contrast_brightness_image.java
"D:\\opencv-344\\opencv\\sources\\samples\\data\\lena.jpg"
![【OpenCV Java】opencv官方java例程演示(Windows下)_第13张图片](http://img.e-com-net.com/image/info8/5abc3519eb5c4b27a0917f618d98af3d.jpg)
【程序 阈值模板】ImgProc.threshold
![【OpenCV Java】opencv官方java例程演示(Windows下)_第14张图片](http://img.e-com-net.com/image/info8/5721450fcf0c4071902b9451dfdc6324.jpg)
【程序 candy边缘检测】ImgTrans.canny_detector.java
![【OpenCV Java】opencv官方java例程演示(Windows下)_第15张图片](http://img.e-com-net.com/image/info8/7d339dcbec344a979b595db3a44c21fd.jpg)
![【OpenCV Java】opencv官方java例程演示(Windows下)_第16张图片](http://img.e-com-net.com/image/info8/3df9f2c4b23b45919ca9bb6aaaacc04a.jpg)
![【OpenCV Java】opencv官方java例程演示(Windows下)_第17张图片](http://img.e-com-net.com/image/info8/406dfb2d4c4d4f30992af904c019b836.jpg)
【程序 图像分割】Sample code showing how to segment overlapping objects using Laplacian filtering, in addition to Watershed and Distance Transformation
![【OpenCV Java】opencv官方java例程演示(Windows下)_第18张图片](http://img.e-com-net.com/image/info8/ff9a58d95603402f934444d5ac583ca9.jpg)
【程序 直线检测】ImgTrans.HoughLines.java. This program demonstrates line finding with the Hough transform
![【OpenCV Java】opencv官方java例程演示(Windows下)_第19张图片](http://img.e-com-net.com/image/info8/383d03e8a71244669312d7d27c6ef538.jpg)
![【OpenCV Java】opencv官方java例程演示(Windows下)_第20张图片](http://img.e-com-net.com/image/info8/4c2003c75b144dfe96bd80dacb667d2c.jpg)
![【OpenCV Java】opencv官方java例程演示(Windows下)_第21张图片](http://img.e-com-net.com/image/info8/d1885e0094f64041a449ef9d4ac33cf9.png)
[程序 ml.introduction_to_pca.java】 This program demonstrates how to use OpenCV PCA to extract the orientation of an object. PCA提取物体的方向
![【OpenCV Java】opencv官方java例程演示(Windows下)_第22张图片](http://img.e-com-net.com/image/info8/4a2b42b9ba7146279855a37fd4e11342.jpg)
【程序 video/BackgroundSubtractionDemo.java】这个可提取出运动目标
![【OpenCV Java】opencv官方java例程演示(Windows下)_第23张图片](http://img.e-com-net.com/image/info8/014cb7c59a144b129f4666490adbe1b9.jpg)
【补充:opencv.js】https://docs.opencv.org/3.4.1/d5/d10/tutorial_js_root.html