1
2
3
4
|
using
Baidu.Aip.Face;
private
Face client;
client =
new
Face(
"API Key"
,
"Secret Key"
)
|
|
public
JObject FaceDetect(
byte
[] image, Dictionary<
string
,
object
> options =
null
);
|
1
2
3
4
5
|
byte
[] image = File.ReadAllBytes(Application.streamingAssetsPath +
"/1.jpg"
);
Dictionary<
string
,
object
> options =
new
Dictionary<
string
,
object
>()
{
{
"face_fields"
,
"beauty,age,expression,gender"
}
};
client.FaceDetect(image, options);
|
|
client.FaceDetect(image);
|
1
2
3
4
5
6
|
System.Net.ServicePointManager.ServerCertificateValidationCallback +=
delegate
(
object
sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate,
System.Security.Cryptography.X509Certificates.X509Chain chain,
System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
return
true
;
// **** Always accept
};
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
using
System.Collections.Generic;
using
System.IO;
using
Baidu.Aip.Face;
using
UnityEngine;
using
UnityEngine.UI;
public
class
TestFace : MonoBehaviour
{
public
Text debugInfo;
private
Face client;
private
byte
[] image;
private
Dictionary<
string
,
object
> options;
private
void
Awake()
{
System.Net.ServicePointManager.ServerCertificateValidationCallback +=
delegate
(
object
sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate,
System.Security.Cryptography.X509Certificates.X509Chain chain,
System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
return
true
;
// **** Always accept
};
client =
new
Face(
"API Key"
,
"Secret Key"
);
image = File.ReadAllBytes(Application.streamingAssetsPath +
"/1.jpg"
);
options =
new
Dictionary<
string
,
object
>()
{
{
"face_fields"
,
"beauty,age,expression,gender"
}
};
}
public
void
StartDetect()
{
var result = client.FaceDetect(image);
//, options);
debugInfo.text = result.ToString();
}
}
|