德扑之星有限公司官方网站

德扑之星官网下载中醫人工智能領軍品牌

接口簡介

AI面診接口主要通過拍攝面部圖片進行識別,返回兩頰、鼻子、眼睛、嘴唇的類型和對應的概率值,面診的證型結論和對應的食療方案

接口地址

訪問地址:https://www.swugb.com/admin/api/face_analysis_v2

請求方式:POST

請求格式:application/x-www-form-urlencode

* 所有的請乞降響應數據編碼為utf-8格式,URL里的所有參數名和參數值請做URL編碼

請求參數

字段 類型 是否必傳 說明
appid String 是 開放平臺創建的appid
imgpath String 是 傳入進行識別的網絡圖片地址
timestamp String 是 請求端口的時間,時間格式yyyyMMddHHmmss
version String 是 api版本,默認為1.0
sign String 是 簽名。把timestamp用MD5進行加密加上appid對應的key,然后再次用MD5進行加密天生簽名,所有的MD5加密為大寫。

響應參數

字段 類型 說明
msg String 響應信息,成功為ok,錯誤為對應的錯誤信息
code Int 響應碼,200-成功 201-沒有可用次數 400-參數缺失或錯誤 500-
data json 識別結果數據

data參數

字段 說明
nose 酒糟鼻,取值鼻頭正常、有酒糟鼻癥狀及各自對應概率
hair 發際線,取值發際線正常、發際線靠后及各自對應概率
faceColor 面色,取值黑色、白色、黃色、紅色、青色及各自對應概率
leftBanDian 左臉斑點,取值左臉無斑點、左臉有斑點及各自對應概率
leftCuoChuang 左臉痤瘡,取值左臉無痤瘡、左臉有痤瘡及各自對應概率
rightBanDian 右臉斑點,取值右臉無斑點、右臉有斑點及各自對應概率
rightCuoChuang 右臉痤瘡,取值右臉無痤瘡、右臉有痤瘡及各自對應概率
lipColor 唇色,取值淡白、淡紅、黑紫、深紅及各自對應概率
lipWater 唇部干裂,取值水潤、干裂及各自對應概率
cropFaceUrl 裁剪的人臉url地址

message參數

字段內容 說明
調用成功 正常返回所有結果
圖片讀取失敗 圖像格式有誤或其他原因導致無法打開
未檢測到人臉 圖片中未檢測到人臉
檢測到多個人臉 圖片中包含多個人臉
檢測到多個人臉 圖片中包含多個人臉
人臉尺寸過小 人臉尺寸過小或者人臉越界
未摘下眼鏡 未摘下眼鏡
圖片下載失敗 原始圖片url路徑有誤
服務器繁忙 服務器并發過高

返回結果示例:

{
    "msg":"成功",
    "code":200,
    "data":{
        "message":"調用成功",
        "nose":{
            "鼻頭正常":0.99979204,
            "有酒糟鼻癥狀":0.00020798302
        },
        "hair":{
            "發際線正常":0.9778505,
            "發際線靠后":0.022149438
        },
        "faceColor":{
            "黑色":0.41139233210500004,
            "白色":0.00448131606555,
            "黃色":0.005320582335,
            "紅色":0.49493583250000006,
            "青色":0.00022487049200000002
        },
        "leftBanDian":{
            "左臉無斑點":0.0038473506,
            "左臉有斑點":0.9961526
        },
        "leftCuoChuang":{
            "左臉無痤瘡":0.90414184,
            "左臉有痤瘡":0.09585814
        },
        "rightBanDian":{
            "右臉無斑點":0.045944422,
            "右臉有斑點":0.95405555
        },
        "rightCuoChuang":{
            "右臉無痤瘡":0.99999785,
            "右臉有痤瘡":2.204213
        },
        "lipColor":{
            "淡白":0.00017499177,
            "淡紅":0.9997421,
            "黑紫":0.000003683799,
            "深紅":0.00039005504
        },
        "lipWater":{
            "水潤":0.9998386,
            "干裂":0.00016144048
        },
        "cropFaceUrl":"xxx"
    }
}        

java調用代碼示例

import com.alibaba.fastjson.JSON;
import com.util.HttpClient;
import java.io.IOException;
import java.security.MessageDigest;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
public class DemoObj {
public static String MD5(String data) throws Exception {
    System.out.println(data);
    MessageDigest md = MessageDigest.getInstance("MD5");
    byte[] array = md.digest(data.getBytes("UTF-8"));
    StringBuilder sb = new StringBuilder();
    for (byte item : array) {
	sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3));
    }
    System.out.println(sb.toString().toUpperCase());
    return sb.toString().toUpperCase();
}
public static void main(String[] args) {
    DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
    String timestamp=df.format(new Date());
    Map body = new HashMap<>();
    body.put("appid", "你的APPID");
    System.out.println(timestamp);
    body.put("timestamp", timestamp);
    body.put("version", "1.0");
    body.put("imgpath", "舌頭圖片地址");
    try {
	body.put「"sign", MD5「MD5「timestamp」+"你的APPID對應的key"」」;
    } catch (Exception e) {
	e.printStackTrace();
    }
    try {
	String s = new HttpClient().doPostMap("https://www.swugb.com/admin/api/face_analysis_v2", body);
	System.out.println(s);
	Map maps = (Map) JSON.parse(s);
	for (Object map : maps.entrySet()){
	    System.out.println(((Map.Entry)map).getKey()+"     " + ((Map.Entry)map).getValue());
	}
    } catch (IOException e) {
	e.printStackTrace();
    }
}
}
    

python調用代碼示例

import hashlib
# 導入time模塊
import time
import requests
import json
def Md5(res):
    print(res)
    md = hashlib.md5()  # 構造一個md5
    md.update(res.encode(encoding='utf-8'))
    # 加密
    print(md.hexdigest().upper())
    return md.hexdigest().upper()
def testapi():
    tures={}
    restime=time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))
    # restime="20190829114035"
    #傳入參數
    tures['timestamp']=restime
    tures['appid']="你的APPID"
    tures['version']='1.0'
    tures['imgpath']='https://wxr-tongue.oss-cn-beijing.aliyuncs.com/images/tongue/IMG_20200913_134618.jpg'
    tures['sign']=Md5「Md5「restime」+"你的APPID對應的key"」
    url = "https://www.swugb.com/admin/api/face_analysis_v2"
    response = requests.post(url, params=tures)
    # print(response.text)
    print(type(response.text))
    load=json.loads(response.text)
    print(load)
            

C#調用代碼示例

using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Security.Cryptography;
using System.Text;
namespace APITest
{
    class Program
    {
	static void Main(string[] args)
	{
	    Dictionary myDictionary = new Dictionary();
	    DateTime dt = DateTime.Now;
	    string ds = dt.ToString("yyyyMMddHHmmss");
	    myDictionary.Add("timestamp",ds);
	    myDictionary.Add「"appid", "你的APPID"」;
	    myDictionary.Add("version","1.0");
	    myDictionary.Add「"imgpath", "待測圖片的云服務地址"」;
	    myDictionary.Add「"sign",GetMD5「GetMD5「ds」+ "你的APPID對應的key"」」;
	    string finalresult = Post("https://www.swugb.com/admin/api/face_analysis_v2",myDictionary);
	    Object jo = JsonConvert.DeserializeObject「finalresult」; //此處結果為最后的調用結果
	    Console.WriteLine(jo);
	    Console.ReadKey();
	}
	//構造MD5
	public static string GetMD5(string sDataIn)
	{
	    MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
	    byte[] bytValue, bytHash;
	    bytValue = System.Text.Encoding.UTF8.GetBytes(sDataIn);
	    bytHash = md5.ComputeHash(bytValue);
	    md5.Clear();
	    string sTemp = "";
	    for (int i = 0; i 
	/// 指定Post地址使用Get 方式獲取全部字符串
	/// 
	/// 請求后臺地址
		    /// 
	public static string Post(string url, Dictionary dic)
	{
	    string result = "";
	    HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
	    req.Method = "POST";
	    req.ContentType = "application/x-www-form-urlencoded";
	    #region 添加Post 參數
	    StringBuilder builder = new StringBuilder();
	    int i = 0;
	    foreach (var item in dic)
	    {
		if (i > 0)
		    builder.Append("&");
		builder.AppendFormat("{0}={1}", item.Key, item.Value);
		i++;
	    }
	    byte[] data = Encoding.UTF8.GetBytes(builder.ToString());
	    req.ContentLength = data.Length;
	    using (Stream reqStream = req.GetRequestStream())
	    {
		reqStream.Write(data, 0, data.Length);
		reqStream.Close();
	    }
	    #endregion
	    HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
	    Stream stream = resp.GetResponseStream();
	    //獲取響應內容
	    using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
	    {
		result = reader.ReadToEnd();
	    }
	    return result;
	}
    }
}
            

javascript調用代碼示例

$.ajax({
type: "POST",
url: "https://www.swugb.com/admin/api/face_analysis_v2",
data: {
     timestamp:restime,
     #restime時間格式為YYmmddHHMMSS
     appid='你的APPID',
     version='1.0',
     imgpath='https://wxr-tongue.oss-cn-beijing.aliyuncs.com/images/tongue/IMG_20200913_134618.jpg',
     sign=Md5「Md5「restime」+'你的APPID對應的key'」
},
success: function(msg) {
		console.log('返回的數據:'+msg);
	}
});
      
德扑之星官网下载 网站地图