首页 文章 精选 留言 我的

精选列表

搜索[文档识别],共10000篇文章
优秀的个人博客,低调大师

opencv 人脸识别 java版------2

代码下载地址http://download.csdn.net/detail/u013378306/9656546 1.环境搭建:见上一篇博客 整个项目的结构图: 2.编写DetectFaceDemo.java,代码如下: packagecom.njupt.zhb.test; importorg.opencv.core.Core; importorg.opencv.core.Mat; importorg.opencv.core.MatOfRect; importorg.opencv.core.Point; importorg.opencv.core.Rect; importorg.opencv.core.Scalar; importorg.opencv.highgui.Highgui; importorg.opencv.objdetect.CascadeClassifier; // //Detectsfacesinanimage,drawsboxesaroundthem,andwritestheresults //to"faceDetection.png". // publicclassDetectFaceDemo{ publicvoidrun(){ System.out.println("\nRunningDetectFaceDemo"); System.out.println(getClass().getResource("lbpcascade_frontalface.xml").getPath()); //Createafacedetectorfromthecascadefileintheresources //directory. //CascadeClassifierfaceDetector=newCascadeClassifier(getClass().getResource("lbpcascade_frontalface.xml").getPath()); //Matimage=Highgui.imread(getClass().getResource("lena.png").getPath()); //注意:源程序的路径会多打印一个‘/’,因此总是出现如下错误 /* *Detected0facesWritingfaceDetection.pnglibpngwarning:Image *widthiszeroinIHDRlibpngwarning:ImageheightiszeroinIHDR *libpngerror:InvalidIHDRdata */ //因此,我们将第一个字符去掉 StringxmlfilePath=getClass().getResource("lbpcascade_frontalface.xml").getPath().substring(1); CascadeClassifierfaceDetector=newCascadeClassifier(xmlfilePath); Matimage=Highgui.imread(getClass().getResource("we.jpg").getPath().substring(1)); //Detectfacesintheimage. //MatOfRectisaspecialcontainerclassforRect. MatOfRectfaceDetections=newMatOfRect(); faceDetector.detectMultiScale(image,faceDetections); System.out.println(String.format("Detected%sfaces",faceDetections.toArray().length)); //Drawaboundingboxaroundeachface. for(Rectrect:faceDetections.toArray()){ Core.rectangle(image,newPoint(rect.x,rect.y),newPoint(rect.x+rect.width,rect.y+rect.height),newScalar(0,255,0)); } //Savethevisualizeddetection. Stringfilename="faceDetection.png"; System.out.println(String.format("Writing%s",filename)); Highgui.imwrite(filename,image); } } 3.编写测试类: packagecom.njupt.zhb.test; publicclassTestMain{ publicstaticvoidmain(String[]args){ System.out.println("Hello,OpenCV"); //Loadthenativelibrary. System.loadLibrary("opencv_java246"); newDetectFaceDemo().run(); } } //运行结果: //Hello,OpenCV // //RunningDetectFaceDemo ///E:/eclipse_Jee/workspace/JavaOpenCV246/bin/com/njupt/zhb/test/lbpcascade_frontalface.xml //Detected8faces //WritingfaceDetection.png 运行结果:

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册