0 下载与安装 (Windows下) https://opencv.org/

选择喜欢的版本安装,opencv3.4以后支持深度学习API

 


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/


2 JAVA示例代码  (Windows下)

【代码位置】……opencv3.4.4/sources/samples/java/tutorial_code/

【代码中示例图片位置】……opencv3.4.4/sources/data/


 

【运行代码  AddingImages.java】 samples\java\tutorial_code\core\AddingImages

[

【运行例子会报错,图片路径不对】

 

【问题】使用自己图片,大小不一样,报错,

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

效果(图片自己下载)

【参考原理】https://blog.csdn.net/poem_qianmo/article/details/20911629


【程序: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中输入系统变量和运行参数


【程序 Histograms_Matching.histogram_calculation 】


【程序 灰度均衡化】histogram_equalization.java(图片是自己的)


【程序 画基本的几何图形】ImgProc.BasicGeometricDrawing.java


【程序 调整对比度与亮度】ImgProc.changing_contrast_brightness_image.java

"D:\\opencv-344\\opencv\\sources\\samples\\data\\lena.jpg"


【程序 阈值模板】ImgProc.threshold


【程序 candy边缘检测】ImgTrans.canny_detector.java


【程序 图像分割】Sample code showing how to segment overlapping objects using Laplacian filtering, in addition to Watershed  and Distance Transformation


 【程序 直线检测】ImgTrans.HoughLines.java. This program demonstrates line finding with the Hough transform


[程序  ml.introduction_to_pca.java】  This program demonstrates how to use OpenCV PCA to extract the orientation of an object. PCA提取物体的方向


【程序 video/BackgroundSubtractionDemo.java】这个可提取出运动目标

 


【补充:opencv.js】https://docs.opencv.org/3.4.1/d5/d10/tutorial_js_root.html 

 

 

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐