人脸识别

package com.acts.opencv.demo;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.MatOfRect;
import org.opencv.core.Point;
import org.opencv.core.Rect;
import org.opencv.core.Scalar;
import org.opencv.highgui.Highgui;
import org.opencv.objdetect.CascadeClassifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;import com.acts.opencv.common.utils.Constants;
import com.acts.opencv.common.web.BaseController;/*** OpenCV人脸识别demo* 创建者 Songer* 创建时间  2018年3月9日*/
@Controller
@RequestMapping(value = "demo")
public class DemoController extends BaseController {private static final Logger logger = LoggerFactory.getLogger(DemoController.class);@RequestMapping(value = "detectFace")public void detectFace(HttpServletResponse response, HttpServletRequest request, String url) {System.loadLibrary(Core.NATIVE_LIBRARY_NAME);System.out.println("===========java.library.path:" + System.getProperty("java.library.path"));logger.info("\nRunning DetectFaceDemo");String resourcePath = getClass().getResource("/lbpcascade_frontalface.xml").getPath().substring(1);logger.info("resourcePath============" + resourcePath);CascadeClassifier faceDetector = new CascadeClassifier(resourcePath);logger.info("url==============" + Constants.PATH + url);Mat image = Highgui.imread(Constants.PATH + url);// Detect faces in the image.// MatOfRect is a special container class for Rect.MatOfRect faceDetections = new MatOfRect();faceDetector.detectMultiScale(image, faceDetections);logger.info(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 = url.substring(url.lastIndexOf("/"), url.length());System.out.println(String.format("Writing %s", Constants.PATH + Constants.DEST_IMAGE_PATH + filename));Highgui.imwrite(Constants.PATH + Constants.DEST_IMAGE_PATH + filename, image);renderString(response, Constants.SUCCESS);}public static void main(String[] args) {System.out.println("Hello, OpenCV");// Load the native library.System.loadLibrary("opencv_java2413");System.loadLibrary(Core.NATIVE_LIBRARY_NAME);System.out.println("===========java.library.path:" + System.getProperty("java.library.path"));}
}

静态类

package com.acts.opencv.common.utils;import org.springframework.web.context.ContextLoader;/*** 常量 创建者 Songer 创建时间 2018年3月09日**/
public class Constants {public static final String CURRENT_USER = "UserInfo";public static final String WECHAT_USER = "weChatUserInfo";public static final String REFERENCE_CODE = "referenceCode";public static final String SUCCESS = "success";public static final String ERROR = "error";public static final String SF_FILE_SEPARATOR = System.getProperty("file.separator");// 文件分隔符public static final String SF_LINE_SEPARATOR = System.getProperty("line.separator");// 行分隔符public static final String SF_PATH_SEPARATOR = System.getProperty("path.separator");// 路径分隔符public static final String PATH = ContextLoader.getCurrentWebApplicationContext().getServletContext().getRealPath("/");/*** 文件*/public static final String SOURCE_IMAGE_PATH = Constants.SF_FILE_SEPARATOR + "statics"+ Constants.SF_FILE_SEPARATOR + "sourceimage" + Constants.SF_FILE_SEPARATOR;// 图片原地址public static final String DEST_IMAGE_PATH = Constants.SF_FILE_SEPARATOR + "statics" + Constants.SF_FILE_SEPARATOR+ "destimage" + Constants.SF_FILE_SEPARATOR;// 图片生成地址/*** 返回参数规范*//** 区分类型 1 -- 无错误,Code重复 */public static final String CODE_DUPLICATE = "1";/** 区分类型 2 -- 无错误,名称重复 */public static final String NAME_DUPLICATE = "2";/** 区分类型 3 -- 数量超出 */public static final String NUMBER_OVER = "3";/** 区分类型 0 -- 无错误,程序正常执行 */public static final String NO_ERROR = "0";/** 区分类型 -1 -- 无错误,返回结果为空 */public static final String NULL_POINTER = "-1";/** 区分类型 -2 -- 错误,参数不正确 */public static final String INCORRECT_PARAMETER = "-2";/** 区分类型 -3 -- 错误,程序执行错误 */public static final String PROGRAM_EXECUTION_ERROR = "-3";/** 区分类型 -5 -- 错误,数据已删除 */public static final String DATA_DELETED = "-5";/** 区分类型 -6 -- 错误,参数不一致(验证码) */public static final String DATA_NOT_SAME = "-6";/**json文件缺失  */public static final String NO_JSON_FILE = "-7";/*** 分页中可能用到的常量*/public static final Integer PAGE_SIZE=10;//一页共有十条内容}

图像识别——(java)opencv(人脸识别简单实现)相关推荐

  1. openCV人脸识别简单案例

    1 基础 我们使用机器学习的方法完成人脸检测,首先需要大量的正样本图像(面部图像)和负样本图像(不含面部的图像)来训练分类器.我们需要从其中提取特征.下图中的 Haar 特征会被使用,就像我们的卷积核 ...

  2. java opencv人脸识别_java+opencv+intellij idea实现人脸识别

    首先当然是需要安装opencv了,我用的是opencv2.4.13.下载完之后就可以直接安装了,安装过程也很简单,直接下一步下一步就好,我就不上图了. 接下来在opencv下找到jar包,比如我直接安 ...

  3. 【转】OpenCV人脸识别

    转自:https://blog.csdn.net/learning_tortosie/article/details/85121576 写在前面 这是Adrian Rosebrock博客的第二篇翻译, ...

  4. java实现人脸识别(使用百度云V3版本)

    2017年,开发了第一个版本的人脸识别,当时费时有5天之久终于写出来了,但是只适用于火狐浏览器,别的浏览器都打不开摄像头. 2018年,将人脸识别重新完善,可以支持360.火狐.谷歌等主流浏览器,版本 ...

  5. java实现人脸识别V3版本开发

    有段时间没有写更新公众号了,也许好多人都忘记了自己还关注了这么个公众号. 因为这段时间确实是有其他的事比较忙,还有一个原因就是自己在技术方面没有学习新的东西,所以没有可更新的(包括博客) 今天,我决定 ...

  6. Python+Tensorflow+Opencv人脸识别(任意数量人脸)

    Python+Tensorflow+Opencv的人脸识别 简单的人脸识别 准备工作 开始--先获取必要的人脸图像 训练--分类吧 识别大脸 简单的人脸识别 一直想做机器学习的东东,最近由于工作的调整 ...

  7. OpenCV 人脸识别 源代码

    请直接查看原文 OpenCV 人脸识别 源代码 https://hotdog29.com/?p=553 在 2019年7月6日 上张贴 由 hotdog发表回复 opencv 人脸识别 在本教程中,您 ...

  8. 基于python opencv人脸识别的签到系统

    基于python opencv人脸识别的签到系统 前言 先看下效果 实现的功能 开始准备 页面的构建 功能实现 代码部分 总结 前言 一个基于opencv人脸识别和TensorFlow进行模型训练的人 ...

  9. 基于虹软使用Java实现人脸识别、人脸比对、活性检测等

    基于虹软使用Java实现人脸识别.人脸比对.活性检测等 虹软: 免费,高级版本试用 支持在线.离线 有 Java SDK,C++ SDK 一.注册虹软开发者平台 点击注册 注册完成后可在"我 ...

最新文章

  1. 浅谈likely与unlikely
  2. Eclipse开发环境设置
  3. mysql之数据库主从复制配置报错1677
  4. SVM熟练到精通1:初识SVM
  5. Mysql基本用法-left join、right join、 inner join、子查询和join-02
  6. RedisDesktopManager的安装与使用
  7. JavaScript中函数的上下文——this
  8. 【Java】Java_16 控制循环结构Break、Continue、Return
  9. 产品经理|竞品分析(附《竞品分析报告》模板)
  10. win10设置右键菜单打开cmd
  11. 高数-极限-求极限值--两个重要极限(以及拓展公式)
  12. Arduino +合宙ESP32C3 +1.8/1.44 寸TFT液晶屏驱动显示
  13. QFS文件系统-学习记录
  14. 华为微型计算机,8英寸华为平板M5青春版今日发布
  15. 快速下载“阿里云镜像网站“Centos各个版本 全流程
  16. RuntimeError: CUDA error: CUBLAS_STATUS_NOT_INITIALIZED when calling `cublas‘
  17. 快速学习-XXL-JOB调度中心/执行器 RESTful API
  18. Git:git-merge的--ff和--no-ff
  19. 内网ip 查 核心交换机 流量_局域网通过IP地址如何找到电脑的位置?
  20. Android-记一次阿里的电话面试

热门文章

  1. 【Web技术】1348- 聊聊水印实现的几种方式
  2. 在线协作文档综合评测 :金山文档、腾讯文档、石墨文档
  3. 360搜索的百亿级网页搜索引擎架构实现
  4. gpu浮点计算能力floaps_为何CPU浮点计算能力差,什么是浮点计算,GPU为何擅长浮点计算?...
  5. 不学C语言能直接学C++吗?
  6. 多波次导弹发射中的规划问题(二)
  7. 异常音检测(持续更新)
  8. windows无法连接到打印机
  9. 解决bootstrap table的export扩展模块利用tableExport导出pdf中文乱码问题
  10. 如何在期货与现货市场之间套利?