示例#1
0
        /// <summary>
        /// 特征值检测
        /// </summary>
        /// <param name="bts">图片对象的byte数组</param>
        /// <returns></returns>
        public FaceDetectResponse FaceDetect(byte[] bts)
        {
            FaceHttp http  = new FaceHttp();
            string   image = Convert.ToBase64String(bts);
            //http.HttpPost("", "");
            FaceDetectRequest request = new FaceDetectRequest()
            {
                faceimage = image
            };
            string url   = ConstUrl.URL_CN + ConstUrl.FaceDeteiveResouse + "?appkey=" + faceKey;
            var    value = http.HttpPost(url, Newtonsoft.Json.JsonConvert.SerializeObject(request));

            return(Newtonsoft.Json.JsonConvert.DeserializeObject <FaceDetectResponse>(value));
        }
        public async void Run(IWebClient client)
        {
            var request = new FaceDetectRequest
            {
                ImageFile            = new System.IO.FileInfo(@".\imgs\1.jpg"),
                IsReturnLandMark     = true,
                ReturnAttributesType = AttributesType.All
            };

            var response = await client.GetResponseAsync(request);

            foreach (Face face in response.Faces)
            {
                Console.WriteLine("token:\t{0}\t{1}", face.FaceToken, face.FaceRectangle.ToString());
                Console.WriteLine("性别:\t{0}", face.Attributes.GenderValue.Value);
                Console.WriteLine("年龄:\t{0}", face.Attributes.Age);
                Console.WriteLine("颜值:\t{0}", face.Attributes.Gender == Gender.Male ? face.Attributes.Beauty.MaleScore : face.Attributes.Beauty.FemaleScore);
            }
        }
示例#3
0
        /// <summary>
        /// Detect and analyze human faces within the image that you provided.
        /// Detect API can detect all the faces within the image. Each detected face gets its face_token, which can be used in follow-up analysis and operations. With a Standard API Key, you can specify a rectangle area within the image to perform face detection.
        /// Detect API can analyze detected faces directly, providing face landmarks and attributes information. With a Free API Key, only the 5 largest faces by its bounding box size can be analyzed, while you can use Face Analyze API to analyze the rest faces. With a Standard API Key, you can analyze all the detected faces.
        /// </summary>
        /// <param name="request">Request for detecting</param>
        /// <exception cref="HttpRequestException"></exception>
        /// <returns>Detect result</returns>
        public async Task <FaceDetectResponse> FaceDetectAsync(FaceDetectRequest request)
        {
            var detectUrl = $"{_baseUrl}/facepp/{Version}/detect";

            return(await FaceApiRequest <FaceDetectRequest, FaceDetectResponse>(request, detectUrl));
        }
示例#4
0
 /// <summary>
 /// 特征值检测
 /// </summary>
 /// <param name="bts">图片对象的byte数组</param>
 /// <returns></returns>
 public FaceDetectResponse FaceDetect(byte[] bts)
 {
     FaceHttp http = new FaceHttp();
     string image = Convert.ToBase64String(bts);
     //http.HttpPost("", "");
     FaceDetectRequest request = new FaceDetectRequest() { faceimage = image };
     string url = ConstUrl.URL_CN + ConstUrl.FaceDeteiveResouse + "?appkey=" + faceKey;
     var value = http.HttpPost(url, Newtonsoft.Json.JsonConvert.SerializeObject(request));
     return Newtonsoft.Json.JsonConvert.DeserializeObject<FaceDetectResponse>(value);
 }