人脸识别java请问如何用Java编写一个面部识别的程序?
人脸识别java 时间:2021-06-19 阅读:(
)
怎样使用OpenCV进行人脸识别
1.环境搭建:
整个项目的结构图:
2.编写DetectFaceDemo.java,代码如下:
.njupt.zhb.test;
.opencv.core.Core;
.opencv.core.Mat;
.opencv.core.MatOfRect;
.opencv.core.Point;
.opencv.core.Rect;
.opencv.core.Scalar;
.opencv.highgui.Highgui;
.opencv.objdetect.CascadeClassifier;
//
// Detects faces in an image, draws boxes around them, and writes the results
// to "faceDetection.png".
//
public class DetectFaceDemo {
public void run() {
System.out.println("
Running DetectFaceDemo");
System.out.println(getClass().getResource("lbpcascade_frontalface.xml").getPath());
// Create a face detector from the cascade file in the resources
// directory.
//CascadeClassifier faceDetector = new CascadeClassifier(getClass().getResource("lbpcascade_frontalface.xml").getPath());
//Mat image = Highgui.imread(getClass().getResource("lena.png").getPath());
//注意:源程序的路径会多打印一个‘/’,因此总是出现如下错误
/*
* Detected 0 faces Writing faceDetection.png libpng warning: Image
* width is zero in IHDR libpng warning: Image height is zero in IHDR
* libpng error: Invalid IHDR data
*/
//因此,我们将第一个字符去掉
String xmlfilePath=getClass().getResource("lbpcascade_frontalface.xml").getPath().substring(1);
CascadeClassifier faceDetector = new CascadeClassifier(xmlfilePath);
Mat image = Highgui.imread(getClass().getResource("we.jpg").getPath().substring(1));
// 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 = "faceDetection.png";
System.out.println(String.format("Writing %s", filename));
Highgui.imwrite(filename, image);
}
}
3.编写测试类:
.njupt.zhb.test;
public class TestMain {
public static void main(String[] args) {
System.out.println("Hello, OpenCV");
// Load the native library.
System.loadLibrary("opencv_java246");
new DetectFaceDemo().run();
}
}
//运行结果:
//Hello, OpenCV
//
//Running DetectFaceDemo
///E:/eclipse_Jee/workspace/JavaOpenCV246//njupt/zhb/test/lbpcascade_frontalface.xml
//Detected 8 faces
//Writing faceDetection.pngc语言写人脸识别需要用到opencv吗
我去年就用opencv开发的android手机端的关于人脸识别的增强现实应用。
我可以很明确的告诉你,java的opencv顶多调用摄像头用,图像处理都用c++的opencv。
对于opencv的开发,不管从开发效率还是执行效率,绝对是c++。
java版的opencv想都不要想。
谁有人脸识别基于java SDK开发的web应用的demo,能不能分享一下
我知道哪里有,我之前做人脸识别考勤系统的时候就是调用云脉的人脸识别API,识别率还不错的,支持调用语言C++、 C#、 Java(安卓)等,可以用在Windows平台手机和web端,demo你百度下就可以到他们要的用OpenCV开发人脸识别软件,用Java好还是用C/C++好
一般地说,用C/C++比较“主流”些,因为C/C++编译后直接生成可执行文件,不需要虚拟机,程序性能比较好。
另一方面,无论用C/C++还是JAVA,使用 OpenCV进行开发的难度和工作量,没有太大的差异。
如果你程序追求性能,建议用C或C++如何使用face++接口开发微信公共平台的人脸识别
1.环境搭建
整个项目的结构图
2.编写DetectFaceDemo.java,代码如下:
[java] view plaincopy
.njupt.zhb.test;
.opencv.core.Core;
.opencv.core.Mat;
.opencv.core.MatOfRect;
.opencv.core.Point;
.opencv.core.Rect;
.opencv.core.Scalar;
.opencv.highgui.Highgui;
.opencv.objdetect.CascadeClassifier;
//
// Detects faces in an image, draws boxes around them, and writes the results
// to "faceDetection.png".
//
public class DetectFaceDemo {
public void run() {
System.out.println("
Running DetectFaceDemo");
System.out.println(getClass().getResource("lbpcascade_frontalface.xml").getPath());
// Create a face detector from the cascade file in the resources
// directory.
//CascadeClassifier faceDetector = new CascadeClassifier(getClass().getResource("lbpcascade_frontalface.xml").getPath());
//Mat image = Highgui.imread(getClass().getResource("lena....1.环境搭建
整个项目的结构图
2.编写DetectFaceDemo.java,代码如下:
[java] view plaincopy
.njupt.zhb.test;
.opencv.core.Core;
.opencv.core.Mat;
.opencv.core.MatOfRect;
.opencv.core.Point;
.opencv.core.Rect;
.opencv.core.Scalar;
.opencv.highgui.Highgui;
.opencv.objdetect.CascadeClassifier;
//
// Detects faces in an image, draws boxes around them, and writes the results
// to "faceDetection.png".
//
public class DetectFaceDemo {
public void run() {
System.out.println("
Running DetectFaceDemo");
System.out.println(getClass().getResource("lbpcascade_frontalface.xml").getPath());
// Create a face detector from the cascade file in the resources
// directory.
//CascadeClassifier faceDetector = new CascadeClassifier(getClass().getResource("lbpcascade_frontalface.xml").getPath());
//Mat image = Highgui.imread(getClass().getResource("lena.png").getPath());
//注意:源程序的路径会多打印一个‘/’,因此总是出现如下错误
/*
* Detected 0 faces Writing faceDetection.png libpng warning: Image
* width is zero in IHDR libpng warning: Image height is zero in IHDR
* libpng error: Invalid IHDR data
*/
//因此,我们将第一个字符去掉
String xmlfilePath=getClass().getResource("lbpcascade_frontalface.xml").getPath().substring(1);
CascadeClassifier faceDetector = new CascadeClassifier(xmlfilePath);
Mat image = Highgui.imread(getClass().getResource("we.jpg").getPath().substring(1));
// 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 = "faceDetection.png";
System.out.println(String.format("Writing %s", filename));
Highgui.imwrite(filename, image);
}
}
3.编写测试类:
[java] view plaincopy
.njupt.zhb.test;
public class TestMain {
public static void main(String[] args) {
System.out.println("Hello, OpenCV");
// Load the native library.
System.loadLibrary("opencv_java246");
new DetectFaceDemo().run();
}
}
//运行结果:
//Hello, OpenCV
//
//Running DetectFaceDemo
///E:/eclipse_Jee/workspace/JavaOpenCV246//njupt/zhb/test/lbpcascade_frontalface.xml
//Detected 8 faces
//Writing faceDetection.png请问如何用Java编写一个面部识别的程序?
1、手机平台如果是iOS,就学习iOS开发,如果是Android,就学习Android开发。
2、学习面部识别的原理及如何通过面部RGB颜色变化来分析心率,通过固定点的变化分析心率很难。
3、最终完成。
RAKsmart 商家这几年还是在做事情的,虽然他们家顺带做的VPS主机并不是主营业务,毕竟当下的基础云服务器竞争过于激烈,他们家主营业务的独立服务器。包括在去年开始有新增多个数据中心独立服务器,包括有10G带宽的不限流量的独立服务器。当然,如果有需要便宜VPS主机的他们家也是有的,比如有最低月付1.99美元的美国VPS主机,而且可选安装Windows系统。这里商家有提供下面六款六月份的活动便宜V...
imidc怎么样?imidc彩虹数据或彩虹网络现在促销旗下日本多IP站群独立服务器,原价159美元的机器现在只需要88美元,而且给13个独立IPv4,30Mbps直连带宽,不限制月流量!IMIDC又名为彩虹数据,rainbow cloud,香港本土运营商,全线产品都是商家自营的,自有IP网络资源等,提供的产品包括VPS主机、独立服务器、站群独立服务器等,数据中心区域包括香港、日本、台湾、美国和南非...
CloudCone是一家成立于2017年的国外VPS主机商,提供独立服务器租用和VPS主机,其中VPS基于KVM架构,多个不同系列,譬如常规VPS、大硬盘VPS等等,数据中心在洛杉矶MC机房。商家2021年Flash Sale活动继续,最低每月1.99美元,支持7天退款到账户,支持使用PayPal或者支付宝付款,先充值后下单的方式。下面列出几款VPS主机配置信息。CPU:1core内存:768MB...
人脸识别java为你推荐
prisma安卓版prisma 安卓版本为什么不能使用动态图片格式动态图片什么格式pat是什么格式怎么将自己做的PS图片保存为PAT格式?手机软件开发工具如何自己开发一个app软件shoujiao手机板aoblox怎么从英文变成中文qq管家官网腾讯手机管家如何下载QQ手机管家?腾讯合作伙伴大会腾讯位置服务是什么?动画分镜头脚本请问什么是动画分镜头脚本,什么是电影分镜头脚本以及什么是广告分镜头脚本?特斯拉model3降价特斯拉model 3中国有补贴吗ocr软件下载哪个图片转文字软件比较好用?
个人注册域名 已经备案域名 新通用顶级域名 sharktech virpus cpanel 128m内存 bash漏洞 骨干网络 全站静态化 linux服务器维护 如何用qq邮箱发邮件 免费网页申请 空间租赁 监控服务器 中国电信测速网站 photobucket 空间申请 789电视剧网 沈阳idc 更多