package com.heyu.api.alibaba.handle.facebody;


import com.aliyun.facebody20191230.models.DetectFaceRequest;
import com.aliyun.facebody20191230.models.DetectFaceResponse;
import com.aliyun.teautil.models.RuntimeOptions;
import com.heyu.api.data.annotation.CustomPath;
import com.heyu.api.alibaba.AlibabaBaseHandle;
import com.heyu.api.alibaba.request.facebody.ADetectFaceRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * https://next.api.aliyun.com/api/facebody/2019-12-30/DetectFace?tab=DEMO&lang=JAVA
 * <p>
 * 人脸检测定位
 */
@Component
@Slf4j
@CustomPath("detectFace")
public class ADetectFaceHandle extends AlibabaBaseHandle<ADetectFaceRequest, DetectFaceResponse> {

    @Autowired
    private com.aliyun.facebody20191230.Client client;

    @Override
    public String check(ADetectFaceRequest aDetectFaceRequest) {
        return checkUrlBase64(aDetectFaceRequest);
    }



    @Override
    public DetectFaceResponse run(ADetectFaceRequest aDetectFaceRequest, RuntimeOptions runtime) throws Exception {
        DetectFaceRequest detectFaceRequest = new DetectFaceRequest();
        detectFaceRequest.setImageURL(aDetectFaceRequest.getImageUrl());
        detectFaceRequest.setMaxFaceNumber(aDetectFaceRequest.maxFaceNumber);
        detectFaceRequest.setLandmark(aDetectFaceRequest.getLandmark());
        detectFaceRequest.setPose(aDetectFaceRequest.getPose());
        detectFaceRequest.setQuality(aDetectFaceRequest.getQuality());
        // 复制代码运行请自行打印 API 的返回值
        return client.detectFaceWithOptions(detectFaceRequest, runtime);
    }
}
