zoukankan      html  css  js  c++  java
  • face++实现人脸识别

    因为项目是在多年前完毕,face++的sdk可能有调整,所以部分功能可能不再适用(2017.3)

    近期做了一个使用face++实现人脸识别的功能。当初看着官方文档一点头绪都没有。看了好久才弄明确。所以在这里记录一下,希望能够帮到须要的人。

    首先要注冊一个face++账号。获取apiKey和apiSecret,把face++的jar包加入到libs文件夹下,接下来是实现这个功能的代码。核心代码例如以下:

    					//获取第一张图片的信息
    					byte[] array1 = imageProcessing(firstPath);
    					JSONObject result1 = httpRequests.detectionDetect(new PostParameters().setImg(array1));
    					String face1 = result1.getJSONArray("face").getJSONObject(0).getString("face_id");
    					System.out.println("face1的id=" + face1);
    					//获取第二张图片的信息
    					byte[] array2 = imageProcessing(secondPath);
    					JSONObject result2 = httpRequests.detectionDetect(new PostParameters().setImg(array2));
    					String face2 = result2.getJSONArray("face").getJSONObject(0).getString("face_id");
    					System.out.println("face2的id=" + face2);
    						
    					System.out.println("開始比較:");
    					//对照两张人脸的类似程度
    					JSONObject Compare = httpRequests.recognitionCompare(new PostParameters().setFaceId1(face1).setFaceId2(face2));
    					final Double smilar = Double.valueOf(Compare.getString("similarity"));
    执行后的效果例如以下:

    所有代码点击这里下载




  • 相关阅读:
    【洛谷P4887】【模板】莫队二次离线(第十四分块(前体))
    查询数据库表大小
    java程序使用ssl证书连接mysql
    win32- 函数运行速度测试
    回调函数是嘛东西
    win32-读取控制台中所有的字符串
    关于 websocket 的一些学习
    idea下载地址
    ida 重新定义
    P1650 田忌赛马(贪心)
  • 原文地址:https://www.cnblogs.com/yutingliuyl/p/6755611.html
Copyright © 2011-2022 走看看