//package com.fdkankan.scene.util; // //import cn.hutool.core.io.FileUtil; //import cn.hutool.http.HttpUtil; //import com.aliyun.imageseg20191230.models.SegmentBodyResponse; //import com.aliyun.oss.OSS; //import com.aliyun.oss.OSSClientBuilder; //import com.aliyun.tea.TeaException; //import com.fdkankan.common.util.FileUtils; //import com.fdkankan.scene.httpclient.MyClient; //import lombok.extern.slf4j.Slf4j; //import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Value; //import org.springframework.cloud.context.config.annotation.RefreshScope; //import org.springframework.stereotype.Component; // //import javax.annotation.Resource; //import java.io.File; // //@Slf4j //@Component //@RefreshScope //public class OssBodySegmentUtil { // // @Value("${oss.bodySegment.point:oss-cn-shanghai.aliyuncs.com}") // private String endPoint; // // @Value("${oss.bodySegment.imagesegPoint:imageseg.cn-shanghai.aliyuncs.com}") // private String imagesegEndPoint; // // @Value("${fyun.key}") // private String accessKeyId; // // @Value("${fyun.secret}") // private String accessKeySecret; // // @Value("${oss.bodySegment.bucket:4dkankan-huadong}") // private String bucket; // // @Resource // private MyClient myClient; // // public void uploadOss(String filePath, String key){ // OSS ossClient = new OSSClientBuilder().build(endPoint, accessKeyId, accessKeySecret); // try { // File file = new File(filePath); // if (!file.exists()) { // log.error("要上传的文件不存在:" + filePath); // return; // } // ossClient.putObject(bucket, key, new File(filePath)); // } catch (Exception e) { // log.error(e.toString() + filePath); // } finally { // ossClient.shutdown(); // } // } // // public void extracted(String imageUrl, String dir, String fileName) throws Exception { // try { // com.aliyun.imageseg20191230.Client client = this.createClient(); // com.aliyun.imageseg20191230.models.SegmentBodyRequest segmentBodyRequest = // new com.aliyun.imageseg20191230.models.SegmentBodyRequest().setImageURL(imageUrl); // com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions(); // // 复制代码运行请自行打印 API 的返回值 // SegmentBodyResponse segmentBodyResponse = client.segmentBodyWithOptions(segmentBodyRequest, runtime); // String imageURL = segmentBodyResponse.getBody().getData().getImageURL(); // log.info("人体抠图imageURL:{}", imageURL); // myClient.downloadFile(imageURL, dir, fileName); // }catch (Exception e){ // log.error("人体抠图失败,imageUrl:" + imageUrl, e); // myClient.downloadFile(imageUrl, dir, fileName); // } // // } // // public static void main(String[] args) { // FileUtils.downLoadFromUrl("http://vibktprfx-prod-prod-damo-eas-cn-shanghai.oss-cn-shanghai.aliyuncs.com/segment-body/2023-02-24/5d44fe44-308c-44c3-8e1d-2d4cbe601f86/image.png?Expires=1677208715&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRpDvh1&Signature=4ZyzaOz6W1nBD9s3KQuFN10c%2BPw%3D", // "1.png","D:\\test"); // } // // /** // * 使用AK&SK初始化账号Client // * @return Client // * @throws Exception // */ // public com.aliyun.imageseg20191230.Client createClient() throws Exception { // com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config() // // 必填,您的 AccessKey ID // .setAccessKeyId(accessKeyId) // // 必填,您的 AccessKey Secret // .setAccessKeySecret(accessKeySecret); // // 访问的域名 // config.endpoint = this.imagesegEndPoint; // return new com.aliyun.imageseg20191230.Client(config); // } // //}