openCV人脸识别
2014-05-15 15:43
399 查看
class DetectFaceDemo {
public void run() {
System.out.println("\nRunning DetectFaceDemo");
// Create a face detector from the cascade file in the resources
// directory.
// CascadeClassifier faceDetector = new
// CascadeClassifier(getClass().getResource("./lbpcascade_frontalface.xml").getPath());
CascadeClassifier faceDetector = new CascadeClassifier(
"F:\\opencv\\sources\\data\\lbpcascades\\lbpcascade_frontalface.xml");
// Mat image =
// Highgui.imread(getClass().getResource("/lena.png").getPath());
Mat image = Highgui.imread("F:\\android\\OpenCvTest\\person.jpg");
// Detect faces in the image.
// MatOfRect is a special container class for Rect.
MatOfRect faceDetections = new MatOfRect();
faceDetector.detectMultiScale(image, faceDetections);
System.out.println(String.format("Detected %s faces",
faceDetections.toArray().length));
// 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));
}
// Save the visualized detection.
String filename = "test.png";
System.out.println(String.format("Writing %s", filename));
Highgui.imwrite(filename, image);
}
}
public class HelloOpenCV {
public static void main(String[] args) {
System.out.println("Hello, OpenCV");
// Load the native library.
// System.loadLibrary("opencv");
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
new DetectFaceDemo().run();
}
}
public void run() {
System.out.println("\nRunning DetectFaceDemo");
// Create a face detector from the cascade file in the resources
// directory.
// CascadeClassifier faceDetector = new
// CascadeClassifier(getClass().getResource("./lbpcascade_frontalface.xml").getPath());
CascadeClassifier faceDetector = new CascadeClassifier(
"F:\\opencv\\sources\\data\\lbpcascades\\lbpcascade_frontalface.xml");
// Mat image =
// Highgui.imread(getClass().getResource("/lena.png").getPath());
Mat image = Highgui.imread("F:\\android\\OpenCvTest\\person.jpg");
// Detect faces in the image.
// MatOfRect is a special container class for Rect.
MatOfRect faceDetections = new MatOfRect();
faceDetector.detectMultiScale(image, faceDetections);
System.out.println(String.format("Detected %s faces",
faceDetections.toArray().length));
// 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));
}
// Save the visualized detection.
String filename = "test.png";
System.out.println(String.format("Writing %s", filename));
Highgui.imwrite(filename, image);
}
}
public class HelloOpenCV {
public static void main(String[] args) {
System.out.println("Hello, OpenCV");
// Load the native library.
// System.loadLibrary("opencv");
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
new DetectFaceDemo().run();
}
}
相关文章推荐
- 【OpenCV】特征人脸 训练、识别、重构、存取
- 【计算机视觉】OpenCV人脸识别facerec源码分析1——FaceRecognizer概述
- keras系列︱人脸表情分类与识别:opencv人脸检测+Keras情绪分类(四)
- 基于openCv2的人脸识别入门
- Android使用OpenCV实现「人脸检测」和「人脸识别」
- python使用opencv实现人脸识别系统
- OpenCV人脸识别Eigen算法源码分析
- OpenCV实现人脸识别——EigenFace特征脸法
- 人脸识别 opencv和python
- Java使用OpenCV实现人脸识别/人眼检测/图片截取/合成/添加水印
- 基于QT和OpenCV的人脸检测识别系统(2)
- OpenCV人脸识别之理论篇
- python使用opencv进行人脸识别
- opencv 人脸识别 (二)训练和识别
- Unity+OpenCV 人脸识别追踪
- 基于OpenCV的PHP图像人脸识别技术
- 使用 OpenCV 与 Face++ 人脸识别
- python3.6.3+opencv3.3.0学习笔记七--人脸识别效果实录
- Solaris下人脸识别程序(OpenCV linux 多线程版本)
- OpenCV-Python 人脸识别