人脸识别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、最终完成。
妮妮云的来历妮妮云是 789 陈总 张总 三方共同投资建立的网站 本着“良心 便宜 稳定”的初衷 为小白用户避免被坑妮妮云的市场定位妮妮云主要代理市场稳定速度的云服务器产品,避免新手购买云服务器的时候众多商家不知道如何选择,妮妮云就帮你选择好了产品,无需承担购买风险,不用担心出现被跑路 被诈骗的情况。妮妮云的售后保证妮妮云退款 通过于合作商的友好协商,云服务器提供2天内全额退款到网站余额,超过2天...
819云互联是海外领先的互联网业务平台服务提供商。专注为用户提供低价高性能云计算产品,致力于云计算应用的易用性开发,并引导云计算在国内普及。目前平台研发以及运营云服务基础设施服务平台(IaaS),面向全球客户提供基于云计算的IT解决方案与客户服务,拥有丰富的海外资源、香港,日本,美国等各国优质的IDC资源。官方网站:https://www.819yun.com香港特价物理服务器:地区CPU内存带宽...
? ? ? ?创梦网络怎么样,创梦网络公司位于四川省达州市,属于四川本地企业,资质齐全,IDC/ISP均有,从创梦网络这边租的服务器均可以****,属于一手资源,高防机柜、大带宽、高防IP业务,另外创梦网络近期还会上线四川联通大带宽,四川联通高防IP,一手整CIP段,四川电信,联通高防机柜,CN2专线相关业务。成都优化线路,机柜租用、服务器云服务器租用,适合建站做游戏,不须要在套CDN,全国访问快...
人脸识别java为你推荐
youtube创始人李开复的创新工场是做什么的啊???excel大写金额EXCEL如何显示出汉字大写金额动态图片格式怎么将GIF动态图片的格式变成JPG 动态效果不变?上行宽带上行宽带和下行宽带代表什么?comexception电脑出现ConnectException: 是什么原因?qq管家官网腾讯手机管家官网防盗页面地址是什么?知识百科网站客服代码怎么在网页用HTML代码设置QQ客服腾讯合作伙伴大会如何成为腾讯渠道合作伙伴?医院排队系统医院排队机和医院排队机的区别有哪些?yui3YUI最详细的资料
中国域名交易中心 naning9韩国官网 directadmin 最好看的qq空间 权嘉云 卡巴斯基是免费的吗 最漂亮的qq空间 腾讯总部在哪 美国凤凰城 免费asp空间 德讯 lamp什么意思 注册阿里云邮箱 阵亡将士纪念日 umax asp空间 双十二促销 镇江高防服务器 register.com 美国主机 更多