日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人工智能 > ChatGpt >内容正文

ChatGpt

java 百度账号注册界面_基于百度AI开放平台的人脸识别的注册登录(1)

發布時間:2025/3/19 ChatGpt 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java 百度账号注册界面_基于百度AI开放平台的人脸识别的注册登录(1) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

百度ai開放平臺首頁

2.選擇產品服務,人臉與人體識別,人臉識別選項。打開后如圖所示

人臉識別

3.點擊立即使用

3.jpg

4.點擊創捷應用

創建應用

這一頁大家按自己需求填寫即可

5.創建完成后點擊管理應用會出現如下圖所示

管里應用

這里我們需要的就是AppID、API Key和Secret Key這三項

6.接下來就開始用eclipse來寫Java代碼了

主要目錄

核心代碼

LoginServlet.java

package servlet;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.io.PrintWriter;

import java.io.Reader;

import java.net.HttpURLConnection;

import java.net.URL;

import java.net.URLEncoder;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

import javax.servlet.ServletException;

import javax.servlet.annotation.WebServlet;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import org.json.JSONObject;

import util.AipFaceHelper;

import util.StringUtil;

/**

* Servlet implementation class LoginServlet

*/

@WebServlet("/LoginServlet")

public class LoginServlet extends HttpServlet {

protected void doGet(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

request.setCharacterEncoding("UTF-8"); // 設置防止提交的中文數據亂碼

response.setContentType("text/html;charset=UTF-8"); // 設置響應的信息不亂碼

PrintWriter out = response.getWriter();// 獲取一個能夠向客戶端顯示信息的對象

// 傳入可選參數調用接口

HashMap options = new HashMap();

options.put("quality_control", "LOW");// 圖片質量控制

options.put("liveness_control", "LOW");// 活體檢測控制

options.put("user_id", "no1");

options.put("max_user_num", "1"); // 查找后返回的用戶數量。返回相似度最高的幾個用戶

String image = request.getParameter("base");

image = StringUtil.base64SubString(image);

String imageType = "BASE64";

String groupIdList = "test01"; // 從指定的group中進行查找 用逗號分隔,上限20個

// 人臉搜索

JSONObject res = AipFaceHelper.getInstance().search(image, imageType, groupIdList, options);

System.out.println(res.toString(2));

out.print(res.toString(2));

}

protected void doPost(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

// TODO Auto-generated method stub

doGet(request, response);

}

}

RegServlet.java

package servlet;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.io.PrintWriter;

import java.net.HttpURLConnection;

import java.net.URL;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

import javax.servlet.ServletException;

import javax.servlet.annotation.WebServlet;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import org.json.JSONObject;

import util.AipFaceHelper;

import util.StringUtil;

/**

* Servlet implementation class RegServlet

*/

@WebServlet("/RegServlet")

public class RegServlet extends HttpServlet {

protected void doGet(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

request.setCharacterEncoding("UTF-8"); // 設置防止提交的中文數據亂碼

response.setContentType("text/html;charset=UTF-8"); // 設置響應的信息不亂碼

PrintWriter out = response.getWriter();// 獲取一個能夠向客戶端顯示信息的對象

HashMap options = new HashMap();

options.put("user_info", "user's info");// 用戶資料,長度限制256B

options.put("quality_control", "LOW");// 圖片質量控制

options.put("liveness_control", "LOW");// 活體檢測控制

// 取決于image_type參數,傳入BASE64字符串或URL字符串或FACE_TOKEN字符串

String image = request.getParameter("base");

image = StringUtil.base64SubString(image);

String imageType = "BASE64";

String groupId = "test01";

String userId = "no1";

// 人臉注冊

JSONObject res = AipFaceHelper.getInstance().addUser(image, imageType, groupId, userId, options);

System.out.println(res.toString(2));

out.print(res.toString(2));

}

protected void doPost(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

// TODO Auto-generated method stub

doGet(request, response);

}

}

AipFaceHelper.java

package util;

import com.baidu.aip.face.AipFace;

public class AipFaceHelper {

// 設置APPID/AK/SK

private static final String APP_ID = "15769139";

private static final String API_KEY = "3wmj05WUe5HyVK1amYpN8Ym6";

private static final String SECRET_KEY = "mMlsBOSugeaBZrMn14q5g44M5eBRsHmV";

private static AipFace client = null;

private AipFaceHelper() {

}

public static AipFace getInstance() {

if (client == null) {

client = new AipFace(APP_ID, API_KEY, SECRET_KEY);

//設置網絡連接參數

client.setConnectionTimeoutInMillis(2000);

client.setSocketTimeoutInMillis(60000);

}

return client;

}

}

StringUtil.java

package util;

public class StringUtil {

public static String base64SubString(String base) {

return base.substring(22);

}

}

welcome.jsp

pageEncoding="UTF-8"%>

Insert title here

恭喜您,使用人臉識別登陸系統成功

index.jsp

pageEncoding="UTF-8"%>

人臉識別 ? 在線版

data-backdrop="static" tabindex="-1" role="dialog"

aria-labelledby="myModalLabel">

style="display: inline-block">BFace ? 人臉識別

aria-label="Close">

×

請將頭部放在視頻區域內,匹配成功將會自動登入系統

如果視頻內未出現識別框或長時間未響應 請單擊此處

muted>

data-target="#myModal" οnclick="showLogin()">登陸

data-target="#myModal" οnclick="showReg()">注冊

function showLogin() {

//調用人臉識別方法

login("http://localhost:8080/faceDiscern/LoginServlet");

}

function showReg() {

//調用人臉識別方法

reg("http://localhost:8080/faceDiscern/RegServlet");

}

總結

以上是生活随笔為你收集整理的java 百度账号注册界面_基于百度AI开放平台的人脸识别的注册登录(1)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。