Browse Source

视频分析相关接口优化

yangyue 1 year ago
parent
commit
fa60584207

+ 9 - 7
video/src/main/java/cn/com/taiji/video/service/impl/VideoUrlServiceImpl.java

@@ -185,10 +185,10 @@ public class VideoUrlServiceImpl implements IVideoUrlService {
         }
         VideoAnalysisPieDTO videoAnalysisPieDTO = new VideoAnalysisPieDTO();
         // videoAnalysisPieDTO.setAnalysis(analysisDTO);
-        Integer total = 0;
-        Integer face = 0;
-        Integer car = 0;
-        Integer body = 0;
+        int total = 0;
+        int face = 0;
+        int car = 0;
+        int body = 0;
         if (null != analysisDTO && analysisDTO.size() > 0) {
             for (AnalysisDTO dto: analysisDTO) {
                 total += dto.getCount();
@@ -205,9 +205,11 @@ public class VideoUrlServiceImpl implements IVideoUrlService {
         }
         videoAnalysisPieDTO.setTotal(total);
         if (total != 0) {
-            videoAnalysisPieDTO.setFace(new BigDecimal(face*100/total).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
-            videoAnalysisPieDTO.setCar(new BigDecimal(car*100/total).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
-            videoAnalysisPieDTO.setBody(new BigDecimal(body*100/total).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
+            log.info(String.valueOf(face));
+            log.info(String.valueOf(car));
+            videoAnalysisPieDTO.setFace((new BigDecimal((float)face/total).setScale(4,BigDecimal.ROUND_HALF_UP).doubleValue())*100);
+            videoAnalysisPieDTO.setCar((new BigDecimal((float)car/total).setScale(4,BigDecimal.ROUND_HALF_UP).doubleValue())*100);
+            videoAnalysisPieDTO.setBody((new BigDecimal((float)body/total).setScale(4,BigDecimal.ROUND_HALF_UP).doubleValue())*100);
         } else {
             videoAnalysisPieDTO.setFace(0.00);
             videoAnalysisPieDTO.setCar(0.00);