作为一个初级码农,什么百度云,阿里云,腾讯云都搞一搞,前几天看到百度的一个AI平台,挺有意思的,于是乎做了一个人脸识别的小例子。看起来挺牛逼的,做完之后你只会佩服百度的强大!

百度人脸识别Java版-LMLPHP

 

先展示下项目吧!

百度人脸识别Java版-LMLPHP百度人脸识别Java版-LMLPHP

 

通过调用摄像头,实现获取人脸图像,然后一秒钟截取一张视频图像传至后台处理,处理完后则返回用户信息。通过这个样例可以让项目中的用户验证变得高大上。

 

那我们现在谈谈他是怎么实现的?

1.你得注册个百度云,创建一个应用

百度人脸识别Java版-LMLPHP

2.点击刚刚创建的应用,查看一下百度给你的接口。

百度人脸识别Java版-LMLPHP

查看这两个接口的URL是否包含该v3的字样,这就是他帮助文档的意思。

百度人脸识别Java版-LMLPHP

 

3.我们根据百度给的帮文档看看他具体是怎么实现的。

4.你用的是百度资源,首先得让他知道你是谁,然后他才给你使用。这也是token认证的作用。

百度人脸识别Java版-LMLPHP

 

package com.lb.service;

import org.json.JSONObject;

import com.lb.token.Token;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
import java.util.Map;

/**
 * 获取token类
 */
public class GetToken {

	public static void SaveToken(String url) {
    	String token = getAuth();
    	System.out.println("token:"+token);
    	Token.token = token;
	}

	/**
     * 获取权限token
     * @return 返回示例:
     * {
     * "access_token": "24.460da4889caad24cccdb1fea17221975.2592000.1491995545.282335-1234567",
     * "expires_in": 2592000
     * }
     */
    public static String getAuth() {
        // 官网获取的 API Key 更新为你注册的
        String clientId = Token.token;
        // 官网获取的 Secret Key 更新为你注册的
        String clientSecret = Token.clientSecret;
        return getAuth(clientId, clientSecret);
    }

    /**
     * 获取API访问token
     * 该token有一定的有效期,需要自行管理,当失效时需重新获取.
     * @param ak - 百度云官网获取的 API Key
     * @param sk - 百度云官网获取的 Securet Key
     * @return assess_token 示例:
     * "24.460da4889caad24cccdb1fea17221975.2592000.1491995545.282335-1234567"
     */
    public static String getAuth(String ak, String sk) {
        // 获取token地址
        String authHost = "https://aip.baidubce.com/oauth/2.0/token?";
        String getAccessTokenUrl = authHost
                // 1. grant_type为固定参数
                + "grant_type=client_credentials"
                // 2. 官网获取的 API Key
                + "&client_id=" + ak
                // 3. 官网获取的 Secret Key
                + "&client_secret=" + sk;
        try {
            URL realUrl = new URL(getAccessTokenUrl);
            // 打开和URL之间的连接
            HttpURLConnection connection = (HttpURLConnection) realUrl.openConnection();
            connection.setRequestMethod("GET");
            connection.connect();
            // 获取所有响应头字段
            Map<String, List<String>> map = connection.getHeaderFields();
            // 遍历所有的响应头字段
            for (String key : map.keySet()) {
                System.err.println(key + "--->" + map.get(key));
            }
            // 定义 BufferedReader输入流来读取URL的响应
            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String result = "";
            String line;
            while ((line = in.readLine()) != null) {
                result += line;
            }
            /**
             * 返回结果示例
             */
            System.err.println("result:" + result);
            JSONObject jsonObject = new JSONObject(result);
            String access_token = jsonObject.getString("access_token");
            return access_token;
        } catch (Exception e) {
            System.err.printf("获取token失败!");
            e.printStackTrace(System.err);
        }
        return null;
    }

}

百度人脸识别Java版-LMLPHP

 

5.获取到token后我们即可调用百度的接口。

百度人脸识别Java版-LMLPHP

百度人脸识别Java版-LMLPHP

根据帮助文档我们只需请求百度的接口,按照上述格式传递一些参数,他则返回对比数据给你

百度人脸识别Java版-LMLPHP

package com.lb.service;

import com.baidu.ai.aip.utils.HttpUtil;
import com.google.gson.Gson;
import com.lb.opj.Msg;
import com.lb.token.Token;
import com.baidu.ai.aip.utils.Base64Util;
import com.baidu.ai.aip.utils.FileUtil;
import com.baidu.ai.aip.utils.GsonUtils;

import java.util.*;

/**
* 人脸对比
*/
public class FaceMatch {

    /**
    * 重要提示代码中所需工具类
    * FileUtil,Base64Util,HttpUtil,GsonUtils请从
    * https://ai.baidu.com/file/658A35ABAB2D404FBF903F64D47C1F72
    * https://ai.baidu.com/file/C8D81F3301E24D2892968F09AE1AD6E2
    * https://ai.baidu.com/file/544D677F5D4E4F17B4122FBD60DB82B3
    * https://ai.baidu.com/file/470B3ACCA3FE43788B5A963BF0B625F3
    * 下载
    */
    public static String match(String path,byte[] b) {
        // 请求url
        String url = "https://aip.baidubce.com/rest/2.0/face/v3/match";
        try {

            //byte[] bytes1 = FileUtil.readFileByBytes(path+"photo/up.png");
        	byte[] bytes1 = b;
            byte[] bytes2 = FileUtil.readFileByBytes(path+"photo/lanbing.jpg");
            String image1 = Base64Util.encode(bytes1);
            String image2 = Base64Util.encode(bytes2);

            List<Map<String, Object>> images = new ArrayList<>();

            Map<String, Object> map1 = new HashMap<>();
            map1.put("image", image1);
            map1.put("image_type", "BASE64");
            map1.put("face_type", "LIVE");
            map1.put("quality_control", "LOW");
            map1.put("liveness_control", "NORMAL");

            Map<String, Object> map2 = new HashMap<>();
            map2.put("image", image2);
            map2.put("image_type", "BASE64");
            map2.put("face_type", "LIVE");
            map2.put("quality_control", "LOW");
            map2.put("liveness_control", "NORMAL");

            images.add(map1);
            images.add(map2);

            String param = GsonUtils.toJson(images);

            // 注意这里仅为了简化编码每一次请求都去获取access_token,线上环境access_token有过期时间, 客户端可自行缓存,过期后重新获取。
            String accessToken = Token.token;

            String result = HttpUtil.post(url, accessToken, "application/json", param);
            System.out.println(result);
            return result;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public static void Compare(String path,byte[] b) {
    	Gson g = new Gson();
    	Msg msg = g.fromJson(FaceMatch.match(path,b), Msg.class);
    	System.out.println("匹配得分:"+msg.showScore());

    }
}

 

其中他用到了几个百度的类,具体如下:

package com.baidu.ai.aip.utils;

/**
 * Base64 宸ュ叿绫�
 */
public class Base64Util {
    private static final char last2byte = (char) Integer.parseInt("00000011", 2);
    private static final char last4byte = (char) Integer.parseInt("00001111", 2);
    private static final char last6byte = (char) Integer.parseInt("00111111", 2);
    private static final char lead6byte = (char) Integer.parseInt("11111100", 2);
    private static final char lead4byte = (char) Integer.parseInt("11110000", 2);
    private static final char lead2byte = (char) Integer.parseInt("11000000", 2);
    private static final char[] encodeTable = new char[]{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'};

    public Base64Util() {
    }

    public static String encode(byte[] from) {
        StringBuilder to = new StringBuilder((int) ((double) from.length * 1.34D) + 3);
        int num = 0;
        char currentByte = 0;

        int i;
        for (i = 0; i < from.length; ++i) {
            for (num %= 8; num < 8; num += 6) {
                switch (num) {
                    case 0:
                        currentByte = (char) (from[i] & lead6byte);
                        currentByte = (char) (currentByte >>> 2);
                    case 1:
                    case 3:
                    case 5:
                    default:
                        break;
                    case 2:
                        currentByte = (char) (from[i] & last6byte);
                        break;
                    case 4:
                        currentByte = (char) (from[i] & last4byte);
                        currentByte = (char) (currentByte << 2);
                        if (i + 1 < from.length) {
                            currentByte = (char) (currentByte | (from[i + 1] & lead2byte) >>> 6);
                        }
                        break;
                    case 6:
                        currentByte = (char) (from[i] & last2byte);
                        currentByte = (char) (currentByte << 4);
                        if (i + 1 < from.length) {
                            currentByte = (char) (currentByte | (from[i + 1] & lead4byte) >>> 4);
                        }
                }

                to.append(encodeTable[currentByte]);
            }
        }

        if (to.length() % 4 != 0) {
            for (i = 4 - to.length() % 4; i > 0; --i) {
                to.append("=");
            }
        }

        return to.toString();
    }
}


package com.baidu.ai.aip.utils;

import java.io.*;

/**
 * 鏂囦欢璇诲彇宸ュ叿绫�
 */
public class FileUtil {

    /**
     * 璇诲彇鏂囦欢鍐呭锛屼綔涓哄瓧绗︿覆杩斿洖
     */
    public static String readFileAsString(String filePath) throws IOException {
        File file = new File(filePath);
        if (!file.exists()) {
            throw new FileNotFoundException(filePath);
        }

        if (file.length() > 1024 * 1024 * 1024) {
            throw new IOException("File is too large");
        }

        StringBuilder sb = new StringBuilder((int) (file.length()));
        // 鍒涘缓瀛楄妭杈撳叆娴�
        FileInputStream fis = new FileInputStream(filePath);
        // 鍒涘缓涓�涓暱搴︿负10240鐨凚uffer
        byte[] bbuf = new byte[10240];
        // 鐢ㄤ簬淇濆瓨瀹為檯璇诲彇鐨勫瓧鑺傛暟
        int hasRead = 0;
        while ( (hasRead = fis.read(bbuf)) > 0 ) {
            sb.append(new String(bbuf, 0, hasRead));
        }
        fis.close();
        return sb.toString();
    }

    /**
     * 鏍规嵁鏂囦欢璺緞璇诲彇byte[] 鏁扮粍
     */
    public static byte[] readFileByBytes(String filePath) throws IOException {
        File file = new File(filePath);
        if (!file.exists()) {
            throw new FileNotFoundException(filePath);
        } else {
            ByteArrayOutputStream bos = new ByteArrayOutputStream((int) file.length());
            BufferedInputStream in = null;

            try {
                in = new BufferedInputStream(new FileInputStream(file));
                short bufSize = 1024;
                byte[] buffer = new byte[bufSize];
                int len1;
                while (-1 != (len1 = in.read(buffer, 0, bufSize))) {
                    bos.write(buffer, 0, len1);
                }

                byte[] var7 = bos.toByteArray();
                return var7;
            } finally {
                try {
                    if (in != null) {
                        in.close();
                    }
                } catch (IOException var14) {
                    var14.printStackTrace();
                }

                bos.close();
            }
        }
    }
}


/*
 * Copyright (C) 2017 Baidu, Inc. All Rights Reserved.
 */
package com.baidu.ai.aip.utils;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;

import java.lang.reflect.Type;

/**
 * Json宸ュ叿绫�.
 */
public class GsonUtils {
    private static Gson gson = new GsonBuilder().create();

    public static String toJson(Object value) {
        return gson.toJson(value);
    }

    public static <T> T fromJson(String json, Class<T> classOfT) throws JsonParseException {
        return gson.fromJson(json, classOfT);
    }

    public static <T> T fromJson(String json, Type typeOfT) throws JsonParseException {
        return (T) gson.fromJson(json, typeOfT);
    }
}

package com.baidu.ai.aip.utils;

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
import java.util.Map;

/**
 * http 宸ュ叿绫�
 */
public class HttpUtil {

    public static String post(String requestUrl, String accessToken, String params)
            throws Exception {
        String contentType = "application/x-www-form-urlencoded";
        return HttpUtil.post(requestUrl, accessToken, contentType, params);
    }

    public static String post(String requestUrl, String accessToken, String contentType, String params)
            throws Exception {
        String encoding = "UTF-8";
        if (requestUrl.contains("nlp")) {
            encoding = "GBK";
        }
        return HttpUtil.post(requestUrl, accessToken, contentType, params, encoding);
    }

    public static String post(String requestUrl, String accessToken, String contentType, String params, String encoding)
            throws Exception {
        String url = requestUrl + "?access_token=" + accessToken;
        return HttpUtil.postGeneralUrl(url, contentType, params, encoding);
    }

    public static String postGeneralUrl(String generalUrl, String contentType, String params, String encoding)
            throws Exception {
        URL url = new URL(generalUrl);
        // 鎵撳紑鍜孶RL涔嬮棿鐨勮繛鎺�
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        // 璁剧疆閫氱敤鐨勮姹傚睘鎬�
        connection.setRequestProperty("Content-Type", contentType);
        connection.setRequestProperty("Connection", "Keep-Alive");
        connection.setUseCaches(false);
        connection.setDoOutput(true);
        connection.setDoInput(true);

        // 寰楀埌璇锋眰鐨勮緭鍑烘祦瀵硅薄
        DataOutputStream out = new DataOutputStream(connection.getOutputStream());
        out.write(params.getBytes(encoding));
        out.flush();
        out.close();

        // 寤虹珛瀹為檯鐨勮繛鎺�
        connection.connect();
        // 鑾峰彇鎵�鏈夊搷搴斿ご瀛楁
        Map<String, List<String>> headers = connection.getHeaderFields();
        // 閬嶅巻鎵�鏈夌殑鍝嶅簲澶村瓧娈�
        for (String key : headers.keySet()) {
            System.err.println(key + "--->" + headers.get(key));
        }
        // 瀹氫箟 BufferedReader杈撳叆娴佹潵璇诲彇URL鐨勫搷搴�
        BufferedReader in = null;
        in = new BufferedReader(
                new InputStreamReader(connection.getInputStream(), encoding));
        String result = "";
        String getLine;
        while ((getLine = in.readLine()) != null) {
            result += getLine;
        }
        in.close();
        System.err.println("result:" + result);
        return result;
    }
}

 

我们所做的就是按百度的格式给她两张图片,然后他就给你结果。我们所做的只此而已。

 

6.我们如何实现登录注册呢。

 

先在我们的应用里建个人脸库。

百度人脸识别Java版-LMLPHP

 

百度人脸识别Java版-LMLPHP

package com.lb.service;

import com.baidu.ai.aip.utils.HttpUtil;
import com.lb.token.Token;
import com.baidu.ai.aip.utils.Base64Util;
import com.baidu.ai.aip.utils.FileUtil;
import com.baidu.ai.aip.utils.GsonUtils;

import java.io.IOException;
import java.util.*;

/**
* 人脸注册
*/
public class FaceAdd {

    /**
    * 重要提示代码中所需工具类
    * FileUtil,Base64Util,HttpUtil,GsonUtils请从
    * https://ai.baidu.com/file/658A35ABAB2D404FBF903F64D47C1F72
    * https://ai.baidu.com/file/C8D81F3301E24D2892968F09AE1AD6E2
    * https://ai.baidu.com/file/544D677F5D4E4F17B4122FBD60DB82B3
    * https://ai.baidu.com/file/470B3ACCA3FE43788B5A963BF0B625F3
    * 下载
    */
    public static String add(String image,String user_id,String user_info) {
        // 请求url
        String url = "https://aip.baidubce.com/rest/2.0/face/v3/faceset/user/add";
        try {
            Map<String, Object> map = new HashMap<>();
            map.put("image", image);
            map.put("group_id", Token.userGroup);
            map.put("user_id", user_id);
            map.put("user_info", user_info);
            map.put("liveness_control", "NORMAL");
            map.put("image_type", "BASE64");
            map.put("quality_control", "LOW");

            String param = GsonUtils.toJson(map);

            // 注意这里仅为了简化编码每一次请求都去获取access_token,线上环境access_token有过期时间, 客户端可自行缓存,过期后重新获取。
            String accessToken = Token.token;

            String result = HttpUtil.post(url, accessToken, "application/json", param);
            System.out.println(result);
            return result;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public static void main(String[] args) {
    	byte[] bytes1;
		try {
			bytes1 = FileUtil.readFileByBytes("E:\\java02\\faceTest\\WebContent\\photo\\lanbing.jpg");
			String image1 = Base64Util.encode(bytes1);
			FaceAdd.add(image1,"18897829387","兰兵");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

    }
}

 

7.人脸搜索

百度人脸识别Java版-LMLPHP

 

package com.lb.service;

import com.baidu.ai.aip.utils.HttpUtil;
import com.google.gson.Gson;
import com.lb.opj.MsgSearch;
import com.lb.token.Token;
import com.baidu.ai.aip.utils.Base64Util;
import com.baidu.ai.aip.utils.FileUtil;
import com.baidu.ai.aip.utils.GsonUtils;

import java.io.IOException;
import java.util.*;

/**
* 人脸搜索
*/
public class FaceSearch {

    /**
    * 重要提示代码中所需工具类
    * FileUtil,Base64Util,HttpUtil,GsonUtils请从
    * https://ai.baidu.com/file/658A35ABAB2D404FBF903F64D47C1F72
    * https://ai.baidu.com/file/C8D81F3301E24D2892968F09AE1AD6E2
    * https://ai.baidu.com/file/544D677F5D4E4F17B4122FBD60DB82B3
    * https://ai.baidu.com/file/470B3ACCA3FE43788B5A963BF0B625F3
    * 下载
    */
    public static String search(String image) {
        // 请求url
        String url = "https://aip.baidubce.com/rest/2.0/face/v3/search";
        try {
            Map<String, Object> map = new HashMap<>();
            map.put("image", image);
            map.put("liveness_control", "NORMAL");
            map.put("group_id_list", Token.userGroup);
            map.put("image_type", "BASE64");
            map.put("quality_control", "LOW");

            String param = GsonUtils.toJson(map);

            // 注意这里仅为了简化编码每一次请求都去获取access_token,线上环境access_token有过期时间, 客户端可自行缓存,过期后重新获取。
            String accessToken = Token.token;

            String result = HttpUtil.post(url, accessToken, "application/json", param);
            System.out.println(result);
            return result;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public static String Search(byte[] bytes1) {

		String image1 = Base64Util.encode(bytes1);
		Gson g = new Gson();
		MsgSearch msg = g.fromJson(FaceSearch.search(image1), MsgSearch.class);
		return g.toJson(msg.ShowSearched());

    }
}

 

 

以上是后台的代码,我们只需传图片到后台调用即可。

register.html

<!DOCTYPE html>
<html lang="ZH-CN">
<head>
<meta charset="utf-8">
<title>face 测试</title>
<style>
#video {
	border: 1px solid #ddd;
}

.booth {
	position: relative;
}

.picLine {
	border: 1px solid #ddd;
	width: 400px;
	height: 300px;
	position: absolute;
	top: 0px;
	left: 0px;
}

.vid {
	border: 1px solid #ddd;
	width: 400px;
	height: 300px;
	position: absolute;
	top: 0px;
	left: 0px;
	z-index: 99;
}

.screencapture {
	border: 1px solid #ddd;
	width: 400px;
	height: 300px;
	position: absolute;
	left: 500px;
}

.info {
	position: absolute;
	top: 350px;
}
</style>

<script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>
</head>
<body>
	<div class="booth">

		<div class="vid">
			<video id="video" width="400" height="300"></video>
		</div>
	</div>

	<div>
		<div class="screencapture">
			<canvas id='canvas' width='400' height='300'></canvas>
		</div>
	</div>
	<div class="info">
		<label>账号:</label> <input type="text" name="account" id="account">
		<label>姓名:</label> <input type="text" name="name" id="name"> <br>
		<br> <br>
		<button id='tack'>注册</button>
	</div>



	<script>
    var video = document.getElementById('video'),
            canvas = document.getElementById('canvas'),
            snap = document.getElementById('tack'),
            img = document.getElementById('img'),
            vendorUrl = window.URL || window.webkitURL;

    //媒体对象
    navigator.getMedia = navigator.getUserMedia ||
            navagator.webkitGetUserMedia ||
            navigator.mozGetUserMedia ||
            navigator.msGetUserMedia;
    navigator.getMedia({
        video: true, //使用摄像头对象
        audio: false  //不适用音频
    }, function (strem) {
        console.log(strem);
        video.src = vendorUrl.createObjectURL(strem);
        video.play();
    }, function (error) {
        //error.code
        console.log(error);
    });
    snap.addEventListener('click', function () {

        //绘制canvas图形
        canvas.getContext('2d').drawImage(video, 0, 0, 400, 300);
        var saveImg = canvas.toDataURL('image/png');
        var account = document.getElementById("account").value;
        var name = document.getElementById("name").value;

        $.ajax({
            url: "Uploadpic",
            type: 'post',
            data: {"saveImg":saveImg.substring(22),"name":name,"account":account},
            success: function () {
                alert('保存成功');
            }
        });
    })


</script>
</body>
</html>

login.html

<!DOCTYPE html>
<html lang="ZH-CN">
<head>
<meta charset="utf-8">
<title>face 测试</title>
<style>
#video {
	border: 1px solid #ddd;
}

.booth {
	position: relative;
}

.picLine {
	border: 1px solid #ddd;
	width: 400px;
	height: 300px;
	position: absolute;
	top: 0px;
	left: 0px;
}

.vid {
	border: 1px solid #ddd;
	width: 400px;
	height: 300px;
	position: absolute;
	top: 0px;
	left: 0px;
	z-index: 99;
}

.screencapture {
	border: 1px solid #ddd;
	width: 400px;
	height: 300px;
	position: absolute;
	left: 500px;
}

.info {
	position: absolute;
	top: 350px;
}
</style>

<script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>
</head>
<body>
	<div class="booth">

		<div class="vid">
			<video id="video" width="400" height="300"></video>
		</div>
	</div>

	<div>
		<div class="screencapture">
			<canvas id='canvas' width='400' height='300'></canvas>
		</div>
	</div>
	<div class="info">
		<p id="name">adsfsf</p>
	</div>



	<script>
    var video = document.getElementById('video'),
            canvas = document.getElementById('canvas'),
            snap = document.getElementById('tack'),
            img = document.getElementById('img'),
            vendorUrl = window.URL || window.webkitURL;

    //媒体对象
    navigator.getMedia = navigator.getUserMedia ||
            navagator.webkitGetUserMedia ||
            navigator.mozGetUserMedia ||
            navigator.msGetUserMedia;
    navigator.getMedia({
        video: true, //使用摄像头对象
        audio: false  //不适用音频
    }, function (strem) {
        console.log(strem);
        video.src = vendorUrl.createObjectURL(strem);
        video.play();
    }, function (error) {
        //error.code
        console.log(error);
    });

    //截取图片并请求后台
    function login() {
    	var isok = false;
        //绘制canvas图形
        canvas.getContext('2d').drawImage(video, 0, 0, 400, 300);
        var saveImg = canvas.toDataURL('image/png');

        $.ajax({
            url: "Login",
            type: 'post',
            data: {"saveImg":saveImg.substring(22)},
            success: function (data) {

                document.getElementById("name").innerHTML = data;
            	this.isok = true;
                console.info(data);
            }
        });

        return isok;
    }

    //隔一秒请求一次
    function search(){
    	var lo = login();
    	if(lo){
    		return 0;
    	}else{
    		setTimeout(search,1000);
    	}
    }

    window.onload=function (){
    	search();
    }

</script>
</body>
</html>

总结:我们所要做的就是获取用户图像信息,通过百度的接口传给她就OK了·。

 

完整代码:https://download.csdn.net/download/qq_34042417/10700082

10-02 19:24