Java之opencv人脸识别
2017-10-17 21:00
633 查看
OpenCV是一个基于BSD许可(开源)发行的跨平台计算机视觉库,可以运行在Linux、Windows、Android和Mac OS操作系统上。它轻量级而且高效——由一系列 C 函数和少量 C++ 类构成,同时提供了Python、Ruby、MATLAB等语言的接口,实现了图像处理和计算机视觉方面的很多通用算法。
OpenCV用C++语言编写,它的主要接口也是C++语言,但是依然保留了大量的C语言接口。该库也有大量的Python, Java and MATLAB/OCTAVE (版本2.5)的接口。这些语言的API接口函数可以通过在线文档获得。如今也提供对于C#,Ch,
Ruby的支持。
1.加载dll资源库
2.获取图片人脸范围
3.获取人脸范围并在图片人脸处画矩形框
OpenCV用C++语言编写,它的主要接口也是C++语言,但是依然保留了大量的C语言接口。该库也有大量的Python, Java and MATLAB/OCTAVE (版本2.5)的接口。这些语言的API接口函数可以通过在线文档获得。如今也提供对于C#,Ch,
Ruby的支持。
1.加载dll资源库
static { System.loadLibrary("libs/x64/opencv_java246"); }
2.获取图片人脸范围
/** * 获取人脸范围 * @param fileName * @return */ public static MatOfRect detectFace(String fileName) { CascadeClassifier faceDetector = new CascadeClassifier("libs/lbpcascade_frontalface.xml"); Mat image = Highgui.imread(fileName); MatOfRect faceDetections = new MatOfRect(); // 指定人脸识别的最大和最小像素范围 Size minSize = new Size(120, 120); Size maxSize = new Size(250, 250); // 参数设置为scaleFactor=1.1f, minNeighbors=4, flags=0 以此来增加识别人脸的正确率 faceDetector.detectMultiScale(image, faceDetections, 1.1f, 4, 0, minSize, maxSize); return faceDetections; }
3.获取人脸范围并在图片人脸处画矩形框
/** * Detects faces in an image, draws boxes around them, and writes the results * @param fileName * @param destName */ public static void drawRect(String fileName, String destName){ Mat image = Highgui.imread(fileName); // Create a face detector from the cascade file in the resources // directory. CascadeClassifier faceDetector = new CascadeClassifier("libs/lbpcascade_frontalface.xml"); // Detect faces in the image. // MatOfRect is a special container class for Rect. MatOfRect faceDetections = new MatOfRect(); faceDetector.detectMultiScale(image, faceDetections); // Draw a bounding box around each face. for (Rect rect : faceDetections.toArray()) { Core.rectangle(image, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height), new Scalar(0, 255, 0)); } Highgui.imwrite(destName, image); }
同理:身份证号提取也是先判断人脸处,然后判断身份证号位置,再利用tess4j提取图片中的身份证号
具体代码请移步github https://github.com/followwwind/javautils[/code]
相关文章推荐
- openCV java(JFrame) 实现人脸识别,人脸自动检测,自动保存裁剪后人脸
- OPENCV+JAVA 人脸识别
- 利用Java调用OpenCV进行人脸识别
- [译] 第十二天: OpenCV - Java开发者的人脸识别
- OpenCV学习笔记[3]Java Demo人脸识别
- Eclipse+Java+OpenCV246人脸识别
- Java使用OpenCV进行人脸识别
- Java使用OpenCV进行人脸识别
- Java调用OpenCV人脸识别
- 利用Java调用OpenCV进行人脸识别
- java+opencv+intellij idea实现人脸识别
- opencv 人脸识别 环境搭建---java版-----1
- Java使用OpenCV实现人脸识别/人眼检测/图片截取/合成/添加水印
- Eclipse+Java+OpenCV246人脸识别
- opencv 人脸识别 java版------2
- android jni中将大数据回调到java层的时候用法,比如视频流,音频流等,图片流等 比如我用ffmpeg解码好视频流,想送到java层使用opengGL进行显示,opencv进行人脸识别等等
- Java之Opencv人脸识别-yellowcong
- opencv使用,人脸识别,java使用opencv
- 【opencv】Java实现opencv 调用本地摄像头,实现人脸识别、人形识别、人眼识别
- 利用OpenCV进行人脸识别