提交修改
This commit is contained in:
parent
05550308b7
commit
cca56d7b93
@ -58,4 +58,7 @@ public class ARecognizeActionRequest {
|
||||
public List<ACommonTextRequest> imageUrlList;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
package com.heyu.api.request;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BaseRequest {
|
||||
}
|
||||
@ -20,7 +20,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@ -43,7 +42,7 @@ public class BodyPostureController extends BaseController {
|
||||
|
||||
@RequestMapping("/mask")
|
||||
@CacheResult
|
||||
public R recognize(BodyPostureReq request) {
|
||||
public R mask(BodyPostureReq request) {
|
||||
List<BodyPostureResp> resp = new ArrayList<>();
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,81 @@
|
||||
package com.heyu.api.controller.face;
|
||||
|
||||
|
||||
import com.aliyun.facebody20191230.models.RecognizeActionResponse;
|
||||
import com.aliyun.facebody20191230.models.RecognizeActionResponseBody;
|
||||
import com.heyu.api.alibaba.handle.facebody.ARecognizeActionHandle;
|
||||
import com.heyu.api.alibaba.request.ACommonTextRequest;
|
||||
import com.heyu.api.alibaba.request.facebody.ARecognizeActionRequest;
|
||||
import com.heyu.api.controller.BaseController;
|
||||
import com.heyu.api.data.annotation.NotIntercept;
|
||||
import com.heyu.api.data.utils.ApiR;
|
||||
import com.heyu.api.data.utils.R;
|
||||
import com.heyu.api.request.CommonReq;
|
||||
import com.heyu.api.request.face.RecognizeImageActionReq;
|
||||
import com.heyu.api.resp.face.RecognizeImageActionResp;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/***
|
||||
* https://next.api.aliyun.com/api/facebody/2019-12-30/RecognizeAction?RegionId=cn-shanghai
|
||||
*
|
||||
*
|
||||
* 动作行为识别 RecognizeAction
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/action/image")
|
||||
@NotIntercept
|
||||
public class RecognizeImageActionController extends BaseController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private ARecognizeActionHandle aRecognizeActionHandle;
|
||||
|
||||
|
||||
@RequestMapping("/recognize")
|
||||
public R recognize(RecognizeImageActionReq req) {
|
||||
|
||||
ARecognizeActionRequest actionRequest = new ARecognizeActionRequest();
|
||||
List<ACommonTextRequest> imageUrlList = new ArrayList<>();
|
||||
|
||||
List<CommonReq> imageUrls = req.getImageUrls();
|
||||
for (CommonReq imageReq : imageUrls) {
|
||||
ACommonTextRequest commonTextRequest = new ACommonTextRequest();
|
||||
commonTextRequest.setImageUrl(imageReq.getImageUrl());
|
||||
commonTextRequest.setImageBase64(imageReq.getImageBase64());
|
||||
imageUrlList.add(commonTextRequest);
|
||||
}
|
||||
actionRequest.setImageUrlList(imageUrlList);
|
||||
|
||||
|
||||
List<RecognizeImageActionResp> resps = new ArrayList<>();
|
||||
|
||||
ApiR<RecognizeActionResponse> aR = aRecognizeActionHandle.handle(actionRequest);
|
||||
if (aR.isSuccess() && isSuccessStatusCode(aR.getData().getStatusCode())) {
|
||||
RecognizeActionResponseBody.RecognizeActionResponseBodyData responseBodyData = aR.getData().getBody().getData();
|
||||
List<RecognizeActionResponseBody.RecognizeActionResponseBodyDataElements> elements = responseBodyData.getElements();
|
||||
if (CollectionUtils.isNotEmpty(elements)) {
|
||||
for (RecognizeActionResponseBody.RecognizeActionResponseBodyDataElements element : elements) {
|
||||
RecognizeImageActionResp actionResp = new RecognizeImageActionResp();
|
||||
|
||||
actionResp.setLabels(element.getLabels());
|
||||
actionResp.setScores(element.getScores());
|
||||
resps.add(actionResp);
|
||||
}
|
||||
}
|
||||
return R.ok().setData(resps);
|
||||
}
|
||||
|
||||
return R.error(aR.getErrorMsg());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
package com.heyu.api.controller.face;
|
||||
|
||||
|
||||
import com.aliyun.facebody20191230.models.RecognizeActionResponse;
|
||||
import com.aliyun.facebody20191230.models.RecognizeActionResponseBody;
|
||||
import com.heyu.api.alibaba.handle.facebody.ARecognizeActionHandle;
|
||||
import com.heyu.api.alibaba.request.facebody.ARecognizeActionRequest;
|
||||
import com.heyu.api.controller.BaseController;
|
||||
import com.heyu.api.data.annotation.NotIntercept;
|
||||
import com.heyu.api.data.utils.ApiR;
|
||||
import com.heyu.api.data.utils.R;
|
||||
import com.heyu.api.request.face.RecognizeVideoActionReq;
|
||||
import com.heyu.api.resp.face.RecognizeVideoActionResp;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/***
|
||||
* https://next.api.aliyun.com/api/facebody/2019-12-30/RecognizeAction?RegionId=cn-shanghai
|
||||
*
|
||||
*
|
||||
* 动作行为识别 RecognizeAction
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/action/video")
|
||||
@NotIntercept
|
||||
public class RecognizeVideoActionController extends BaseController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private ARecognizeActionHandle aRecognizeActionHandle;
|
||||
|
||||
|
||||
@RequestMapping("/recognize")
|
||||
public R recognize(RecognizeVideoActionReq req) {
|
||||
|
||||
ARecognizeActionRequest actionRequest = new ARecognizeActionRequest();
|
||||
|
||||
actionRequest.setVideoUrl(req.getVideoUrl());
|
||||
actionRequest.setVideoBase64(req.getVideoBase64());
|
||||
|
||||
List<RecognizeVideoActionResp> resps = new ArrayList<>();
|
||||
|
||||
ApiR<RecognizeActionResponse> aR = aRecognizeActionHandle.handle(actionRequest);
|
||||
if (aR.isSuccess() && isSuccessStatusCode(aR.getData().getStatusCode())) {
|
||||
RecognizeActionResponseBody.RecognizeActionResponseBodyData responseBodyData = aR.getData().getBody().getData();
|
||||
List<RecognizeActionResponseBody.RecognizeActionResponseBodyDataElements> elements = responseBodyData.getElements();
|
||||
if (CollectionUtils.isNotEmpty(elements)) {
|
||||
for (RecognizeActionResponseBody.RecognizeActionResponseBodyDataElements element : elements) {
|
||||
RecognizeVideoActionResp actionResp = new RecognizeVideoActionResp();
|
||||
|
||||
actionResp.setLabels(element.getLabels());
|
||||
actionResp.setScores(element.getScores());
|
||||
actionResp.setTimestamp(element.getTimestamp());
|
||||
|
||||
|
||||
resps.add(actionResp);
|
||||
}
|
||||
}
|
||||
return R.ok().setData(resps);
|
||||
}
|
||||
|
||||
return R.error(aR.getErrorMsg());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package com.heyu.api.request.face;
|
||||
|
||||
|
||||
import com.heyu.api.data.dto.BaseReq;
|
||||
import com.heyu.api.request.CommonReq;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/***
|
||||
* https://next.api.aliyun.com/api/facebody/2019-12-30/RecognizeAction?RegionId=cn-shanghai
|
||||
*
|
||||
* 动作行为识别 RecognizeAction
|
||||
*/
|
||||
@Data
|
||||
public class RecognizeImageActionReq extends BaseReq {
|
||||
|
||||
/***
|
||||
* 图像列表
|
||||
*
|
||||
* 子级条数 <= 300
|
||||
*
|
||||
*/
|
||||
private List<CommonReq> imageUrls;
|
||||
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
package com.heyu.api.request.face;
|
||||
|
||||
|
||||
import com.heyu.api.data.dto.BaseReq;
|
||||
import lombok.Data;
|
||||
|
||||
/***
|
||||
* https://next.api.aliyun.com/api/facebody/2019-12-30/RecognizeAction?RegionId=cn-shanghai
|
||||
*
|
||||
*动作行为识别 RecognizeAction
|
||||
*/
|
||||
@Data
|
||||
public class RecognizeVideoActionReq extends BaseReq {
|
||||
|
||||
|
||||
/**
|
||||
* 图片的url
|
||||
*/
|
||||
private String videoUrl;
|
||||
|
||||
/**
|
||||
* base 64 编码
|
||||
*/
|
||||
private String videoBase64;
|
||||
|
||||
/**
|
||||
* 图像列表
|
||||
*
|
||||
* Type 为 1 时需要输入的图像 URL 地址,必须输入 4 张图像,且 4 张图像建议为两秒钟视频均匀采样的图像,分辨率和通道数必须一致。推荐使用上海地域的 OSS 链接,对于文件在本地或者非上海地域 OSS 链接的情况,请参见文件 URL 处理。
|
||||
*
|
||||
* 示例值:
|
||||
* http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/RecognizeAction/1RecognizeAction1.png
|
||||
* imageData
|
||||
* string
|
||||
* 图像 Base64 编码字符串,与 URL 共存时,URL 优先。文件的 Base64 编码处理操作,请参见文件 Base64 处理。
|
||||
*
|
||||
* 示例值:
|
||||
* /9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgQ****
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
package com.heyu.api.resp.face;
|
||||
|
||||
|
||||
import com.heyu.api.data.dto.BaseResp;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class RecognizeImageActionResp extends BaseResp {
|
||||
|
||||
/***
|
||||
* 识别到的行为类别。
|
||||
*
|
||||
* 示例值:
|
||||
* 跌倒
|
||||
*/
|
||||
public java.util.List<String> labels;
|
||||
|
||||
|
||||
/***
|
||||
*行为类别的置信度。取值范围 0~1,值越大,识别到的动作越准确。系统根据算法,为不同的动作给出判断的阈值标准,您也可以根据自己的实际情况,对判断的阈值标准进行调整。
|
||||
*
|
||||
* 举手:0.5(低于 0.5 则认为不是举手行为,否则认为是举手行为。)
|
||||
*
|
||||
* 吃喝:0.5(低于 0.5 则认为不是吃喝行为,否则认为是吃喝行为。)
|
||||
*
|
||||
* 吸烟:0.5(低于 0.5 则认为不是吸烟行为,否则认为是吸烟行为。)
|
||||
*
|
||||
* 打电话:0.5(低于 0.5 则认为不是打电话行为,否则认为是打电话行为。)
|
||||
*
|
||||
* 玩手机:0.5(低于 0.5 则认为不是玩手机行为,否则认为是玩手机行为。)
|
||||
*
|
||||
* 趴桌睡觉:0.5(低于 0.5 则认为不是趴桌睡觉行为,否则认为是趴桌睡觉行为。)
|
||||
*
|
||||
* 跌倒:0.5(低于 0.5 则认为不是跌倒行为,否则认为是跌倒行为。)
|
||||
*
|
||||
* 洗手:0.5(低于 0.5 则认为不是洗手行为,否则认为是洗手行为。)
|
||||
*
|
||||
* 拍照:0.5(低于 0.5 则认为不是拍照行为,否则认为是拍照行为。)
|
||||
*
|
||||
* 示例值:
|
||||
* 0.702967643737793
|
||||
*/
|
||||
public java.util.List<Float> scores;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
package com.heyu.api.resp.face;
|
||||
|
||||
|
||||
import com.heyu.api.data.dto.BaseResp;
|
||||
import lombok.Data;
|
||||
|
||||
/***
|
||||
* https://next.api.aliyun.com/api/facebody/2019-12-30/RecognizeAction?RegionId=cn-shanghai
|
||||
|
||||
|
||||
动作行为识别 RecognizeAction*
|
||||
*/
|
||||
@Data
|
||||
public class RecognizeVideoActionResp extends BaseResp {
|
||||
/***
|
||||
* Labels
|
||||
* array<string>
|
||||
* string
|
||||
* 识别到的行为类别。
|
||||
*
|
||||
* 示例值:
|
||||
* 跌倒
|
||||
*/
|
||||
public java.util.List<String> labels;
|
||||
|
||||
|
||||
/***
|
||||
* Scores
|
||||
* array<number<float>>
|
||||
* number<float>
|
||||
* 行为类别的置信度。取值范围 0~1,值越大,识别到的动作越准确。系统根据算法,为不同的动作给出判断的阈值标准,您也可以根据自己的实际情况,对判断的阈值标准进行调整。
|
||||
*
|
||||
* 举手:0.5(低于 0.5 则认为不是举手行为,否则认为是举手行为。)
|
||||
*
|
||||
* 吃喝:0.5(低于 0.5 则认为不是吃喝行为,否则认为是吃喝行为。)
|
||||
*
|
||||
* 吸烟:0.5(低于 0.5 则认为不是吸烟行为,否则认为是吸烟行为。)
|
||||
*
|
||||
* 打电话:0.5(低于 0.5 则认为不是打电话行为,否则认为是打电话行为。)
|
||||
*
|
||||
* 玩手机:0.5(低于 0.5 则认为不是玩手机行为,否则认为是玩手机行为。)
|
||||
*
|
||||
* 趴桌睡觉:0.5(低于 0.5 则认为不是趴桌睡觉行为,否则认为是趴桌睡觉行为。)
|
||||
*
|
||||
* 跌倒:0.5(低于 0.5 则认为不是跌倒行为,否则认为是跌倒行为。)
|
||||
*
|
||||
* 洗手:0.5(低于 0.5 则认为不是洗手行为,否则认为是洗手行为。)
|
||||
*
|
||||
* 拍照:0.5(低于 0.5 则认为不是拍照行为,否则认为是拍照行为。)
|
||||
*
|
||||
* 示例值:
|
||||
* 0.702967643737793
|
||||
*
|
||||
*/
|
||||
public java.util.List<Float> scores;
|
||||
|
||||
/**
|
||||
* Timestamp
|
||||
* integer<int32>
|
||||
* 当前行为在视频或者图像中发生的时间戳信息。
|
||||
*
|
||||
* 示例值:
|
||||
* 3
|
||||
*
|
||||
*/
|
||||
public Integer timestamp;
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user