博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Java图片人物照片头像识别
阅读量:4112 次
发布时间:2019-05-25

本文共 1041 字,大约阅读时间需要 3 分钟。

需求:

采用java去识别图片中的是否含有人物头像。

实现:

基于jviolajones实现,具体的jar信息如下:

org.eclipse
jviolajones
2.0
org.jdom
jdom
1.1

依赖一个描述文件haarcascade_frontalface_default.xml,详情参见附件

具体代码如下:

public static void findFaces() throws Exception {	 String fileName1="/home/test/1.jpg";  	 String fileName2="/home/test/2.jpg";  	 String fileName3="/home/test/3.jpg";  	 Detector detector= Detector.create("haarcascade_frontalface_default.xml");	 BufferedImage bi1=ImageIO.read(new File(fileName1));	 	 BufferedImage bi2=ImageIO.read(new File(fileName2));	 BufferedImage bi3=ImageIO.read(new File(fileName3));	 List
res=detector.getFaces(bi1, 2, 1.25f, 0.1f,3,true); System.out.println(res); res=detector.getFaces(bi2, 2, 1.25f, 0.1f,3,true); System.out.println(res); res=detector.getFaces(bi3, 2, 1.25f, 0.1f,3,true); System.out.println(res); }

 

返回结果说明:

List<Rectangle>:为图片中头像出现的区域,包括起始坐标(x,y)以及对于的宽和高。如果需要加涂层可以基于Rectangle进行图层添加

 

转载地址:http://mnqsi.baihongyu.com/

你可能感兴趣的文章
CF 551c 二分搜索+思维题
查看>>
UVA 10054
查看>>
cf 550A 字符串统计
查看>>
CF 字符串+数论
查看>>
POJ 1274 The Perfect Stall 二分匹配模板
查看>>
CF Mike and Fax 字符串组成
查看>>
POJ 3250 单调栈模板
查看>>
CF #338B Longtail Hedgehog 画刺猬
查看>>
Good Bye 2015 B. 位运算
查看>>
Cf #179 (Div. 1) B. Greg and Graph 活用三重floyd
查看>>
CF #165 DIV2 E 最大流的流向
查看>>
Manthan 2011 A. Partial Teacher 拓扑排序or直接数组处理
查看>>
AVL树与红黑树比较
查看>>
排序算法比较与分析
查看>>
似然函数 极大似然估计
查看>>
逻辑回归
查看>>
翻转二叉树
查看>>
核函数
查看>>
自旋锁
查看>>
在构造函数中需要初始化列表初始化的有如下三种情况
查看>>