Browse Source

/*infra_1800红外相关修改。*/

master
htjcAdmin 8 months ago
parent
commit
c7ff14bc22
5 changed files with 94 additions and 39 deletions
  1. +12
    -0
      src/main/java/com/inspect/simulator/constant/AlgConstants.java
  2. +0
    -1
      src/main/java/com/inspect/simulator/controller/AlgorithmController.java
  3. +30
    -0
      src/main/java/com/inspect/simulator/controller/InfraredController.java
  4. +11
    -3
      src/main/java/com/inspect/simulator/service/impl/AlgorithmServiceImpl.java
  5. +41
    -35
      src/main/java/com/inspect/simulator/service/impl/HikVisionServiceImpl.java

+ 12
- 0
src/main/java/com/inspect/simulator/constant/AlgConstants.java View File

@ -0,0 +1,12 @@
package com.inspect.simulator.constant;
public class AlgConstants {
public static final String METER = "meter";
public static final String INFRA_1800 = "infra_1800";
public static final String INFRA_YU3 = "infra_yu3";
public static final String INFRA_CAMERA = "infra_camera";
public static final String INFRA_CAMERA_REVERSE = "infra_camera_reverse";
public static final String XB = "xb";
public static final String ALG_SUBTYPE_CODE = "alg_subtype_code";
}

+ 0
- 1
src/main/java/com/inspect/simulator/controller/AlgorithmController.java View File

@ -125,7 +125,6 @@ public class AlgorithmController {
.body(algorithmService.infraredPicAnalyse(analyseRequestStr));
}
@PostMapping("/simu/bigModel/picAnalyseRetNotify")
public ResponseEntity<String> bigModelPicAnalyseRetNotify(@RequestBody String picAnalyseResult) {
return ResponseEntity


+ 30
- 0
src/main/java/com/inspect/simulator/controller/InfraredController.java View File

@ -1,8 +1,11 @@
package com.inspect.simulator.controller;
import com.alibaba.fastjson.JSONObject;
import com.inspect.simulator.domain.Infrared.*;
import com.inspect.simulator.service.HikVisionService;
import com.inspect.simulator.hikVision.utils.AjaxResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@ -11,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
@RestController
@CrossOrigin
public class InfraredController {
private final Logger log = LoggerFactory.getLogger(this.getClass());
@Autowired
private HikVisionService hikVisionService;
@ -57,4 +61,30 @@ public class InfraredController {
public ResponseEntity<String> irPicAnalyse(@RequestBody final String analyseRequest) {
return hikVisionService.irPicAnalyse(analyseRequest);
}
@GetMapping("/device/radiometry-temper/{cameraCode}")
public ResponseEntity<String> deviceRadiometryTemper(
@PathVariable("cameraCode") String cameraCode,
@RequestParam("presetId") Integer presetId,
@RequestParam("ruleId") Integer ruleId,
@RequestParam("meterType") Integer meterType
) {
log.info("deviceRadiometryTemper, cameraCode: {}, presetId: {}, ruleId: {}, meterType: {}",
cameraCode, presetId, ruleId, meterType);
JSONObject subJsonObject = new JSONObject();
subJsonObject.put("meterType", 2);
subJsonObject.put("temperUnit", 1);
subJsonObject.put("temperAver", 60.0);
subJsonObject.put("temperMax", 100.0);
subJsonObject.put("temperMin", 50.0);
subJsonObject.put("temperMid", 60.0);
subJsonObject.put("temperStd", 1);
JSONObject jsonObject = new JSONObject();
jsonObject.put("resultCode", 0);
jsonObject.put("resultMsg", "success");
jsonObject.put("radiometryInfo", subJsonObject);
return ResponseEntity.ok(jsonObject.toJSONString());
}
}

+ 11
- 3
src/main/java/com/inspect/simulator/service/impl/AlgorithmServiceImpl.java View File

@ -27,7 +27,9 @@ import retrofit2.Response;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class AlgorithmServiceImpl implements AlgorithmService {
@ -51,13 +53,16 @@ public class AlgorithmServiceImpl implements AlgorithmService {
log.info(Color.MAGENTA + "[FILTER] filterPicAnalyse: analyseRequestStr={}" + Color.END, analyseRequestStr);
AnalyseRequest analyseRequest = new Gson().fromJson(analyseRequestStr, AnalyseRequest.class);
String[] typeList = analyseRequest.getObjectList().get(0).getTypeList();
String typeListStr = String.join(",", typeList);
AnalyseResult analyseResult = new AnalyseResult();
analyseResult.setRequestId(analyseRequest.getRequestId());
AnalyseResPoint analyseResPoint = new AnalyseResPoint();
analyseResPoint.setValue("0");
analyseResPoint.setConf("0.85");
analyseResPoint.setCode("2000");
analyseResPoint.setType("infra_yu3");
analyseResPoint.setType(typeListStr);
analyseResPoint.setResImageUrl(analyseRequest.getObjectList().get(0).getImageUrlList()[0]);
List<AnalyseResPoint> analyseResPoints = new ArrayList<>();
analyseResPoints.add(analyseResPoint);
@ -87,13 +92,15 @@ public class AlgorithmServiceImpl implements AlgorithmService {
log.info(Color.MAGENTA + "[BIG MODEL] bigModelPicAnalyse: analyseRequestStr={}" + Color.END, analyseRequestStr);
AnalyseRequest analyseRequest = new Gson().fromJson(analyseRequestStr, AnalyseRequest.class);
String[] typeList = analyseRequest.getObjectList().get(0).getTypeList();
String typeListStr = String.join(",", typeList);
AnalyseResult analyseResult = new AnalyseResult();
analyseResult.setRequestId(analyseRequest.getRequestId());
AnalyseResPoint analyseResPoint = new AnalyseResPoint();
analyseResPoint.setValue("1");
analyseResPoint.setConf("0.95");
analyseResPoint.setCode("2000");
analyseResPoint.setType("infra_yu3");
analyseResPoint.setType(typeListStr);
analyseResPoint.setResImageUrl(analyseRequest.getObjectList().get(0).getImageUrlList()[0]);
List<AnalyseResPoint> analyseResPoints = new ArrayList<>();
analyseResPoints.add(analyseResPoint);
@ -194,6 +201,7 @@ public class AlgorithmServiceImpl implements AlgorithmService {
AnalyseResPoint analyseResPoint = new AnalyseResPoint();
// analyseResPoint.setValue("0");
// analyseResPoint.setConf("0.85");
String typeListStr = String.join(",", typeList);
if (String.valueOf((double) infraredInfo.getFrameMax()) != null) {
analyseResPoint.setValue("0");//成功
@ -202,7 +210,7 @@ public class AlgorithmServiceImpl implements AlgorithmService {
}
analyseResPoint.setConf(String.format("%.2f", (double) infraredInfo.getFrameMax()));
analyseResPoint.setResImageUrl(infraredInfo.getOutPath());
analyseResPoint.setType("infra_yu3");
analyseResPoint.setType(typeListStr);
analyseResPoint.setCode("2000");
// analyseResPoint.setResImageUrl(analyseRequest.getObjectList().get(0).getImageUrlList()[0]);
List<AnalyseResPoint> analyseResPoints = new ArrayList<>();


+ 41
- 35
src/main/java/com/inspect/simulator/service/impl/HikVisionServiceImpl.java View File

@ -10,6 +10,7 @@ import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.inspect.simulator.constant.AlgConstants;
import com.inspect.simulator.domain.Infrared.*;
import com.inspect.simulator.domain.algorithm.in.AnalyseReqItem;
import com.inspect.simulator.domain.algorithm.in.AnalyseRequest;
@ -315,11 +316,14 @@ public class HikVisionServiceImpl implements HikVisionService {
@Override
public AjaxResult capturePicture(InfraPictureInfo infraPictureInfo) {
log.info("capturePicture, coordinate:{}", infraPictureInfo);
if (infraPictureInfo.getImgType().equals("infra_camera_reverse")) {
final String imageType = infraPictureInfo.getImgType();
if (AlgConstants.INFRA_CAMERA.equals(imageType)) {
return AjaxResult.success("设置成功");
} else if (infraPictureInfo.getImgType().equals("infra_1800")) {
} else if (AlgConstants.INFRA_CAMERA_REVERSE.equals(imageType)) {
return AjaxResult.success("设置成功");
} else if (infraPictureInfo.getImgType().equals("infra_yu3")) {
} else if (AlgConstants.INFRA_1800.equals(imageType)) {
return AjaxResult.success("设置成功");
} else if (AlgConstants.INFRA_YU3.equals(imageType)) {
Long channelId = infraPictureInfo.getChannelId();
//channelId = 1299L;
BasedataEqpBookChannel basedataEqpBookChannel = basedataEqpBookChannelMapper.selectBasedataEqpBookChannelByChannelId(channelId);
@ -640,8 +644,8 @@ public class HikVisionServiceImpl implements HikVisionService {
// 设置标注样式
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Font font = new Font("微软雅黑", Font.BOLD, 17);
if (infraPictureInfo.getImgType().equals("infra_yu3")) {
final String imageType = infraPictureInfo.getImgType();
if (AlgConstants.INFRA_YU3.equals(imageType)) {
for (Coordinate c : coordinates) {
//点标注
if (c.getFirstX() != null && c.getFirstY() != null && c.getSecondX() == null && c.getSecondY() == null) {
@ -700,7 +704,7 @@ public class HikVisionServiceImpl implements HikVisionService {
}
}
}
} else if (infraPictureInfo.getImgType().equals("infra_1800")) {
} else if (AlgConstants.INFRA_1800.equals(imageType)) {
for (Coordinate c : coordinates) {
g2d.setFont(font);
//矩阵标注
@ -739,7 +743,7 @@ public class HikVisionServiceImpl implements HikVisionService {
}
}
}
} else if (infraPictureInfo.getImgType().equals("infra_camera_reverse")) {
} else if (AlgConstants.INFRA_CAMERA_REVERSE.equals(imageType)) {
for (Coordinate c : coordinates) {
g2d.setFont(font);
//矩阵标注
@ -962,6 +966,7 @@ public class HikVisionServiceImpl implements HikVisionService {
//华软上传图片到ftp
public boolean pic2Ftp(String newPath, InputStream originalPath, String ftpUrlAddress, Integer ftpUrlPort, String ftpUrlAccount, String ftpUrlPwd) {
FTPClient ftps = new FTPClient();
;
ftps.setConnectTimeout(2000); // 连接超时3秒
ftps.setDataTimeout(2000); // 数据传输超时3秒
ftps.setDefaultTimeout(2000); // 控制通道超时3秒
@ -1094,7 +1099,7 @@ public class HikVisionServiceImpl implements HikVisionService {
// infraPictureInfo.setChannelId();
infraPictureInfo.setImgType(typeListImg[0]);
infraPictureInfo.setFilePath(imageUrlList[0]);
InfraredInfo infraredInfo = calculatePicture(infraPictureInfo,"1,1,639,511,640,512");
InfraredInfo infraredInfo = calculatePicture(infraPictureInfo, "1,1,639,511,640,512");
AnalyseResult analyseResult = new AnalyseResult();
@ -1121,8 +1126,8 @@ public class HikVisionServiceImpl implements HikVisionService {
List<AnalyseResItem> analyseResItems = new ArrayList<>();
analyseResItems.add(analyseResItem);
analyseResult.setResultList(analyseResItems);
System.out.println("返回值打印: 是否成功(0成功;1失败)"+analyseResPoint.getValue()+
",最高温度值"+analyseResPoint.getConf()+",返回图片路径:"+analyseResPoint.getResImageUrl());
System.out.println("返回值打印: 是否成功(0成功;1失败)" + analyseResPoint.getValue() +
",最高温度值" + analyseResPoint.getConf() + ",返回图片路径:" + analyseResPoint.getResImageUrl());
try {
String analyseResultOutJson = JSONObject.toJSONString(analyseResult);
log.info("[INFRARED] irPicAnalyse: feedbackUrl={}, analyseResultOutJson={}", feedbackUrl, analyseResultOutJson);
@ -1136,7 +1141,7 @@ public class HikVisionServiceImpl implements HikVisionService {
public InfraredInfo calculatePicture(InfraPictureInfo infraPictureInfo, String picData) {
log.info("进入红外图片接口!" );
log.info("进入红外图片接口!");
InfraredInfo infraredInfo = new InfraredInfo();
String imagePath = infraPictureInfo.getFilePath();
InputStream inputStream = downloadFtp(imagePath);
@ -1155,7 +1160,7 @@ public class HikVisionServiceImpl implements HikVisionService {
secondY = Integer.parseInt(parts[3]);
imgHeight = Integer.parseInt(parts[4]);
imgWidth = Integer.parseInt(parts[5]);
}else {
} else {
log.error("无点位信息!");
}
List<Coordinate> coordinates = new ArrayList<>();
@ -1164,46 +1169,47 @@ public class HikVisionServiceImpl implements HikVisionService {
infraPictureInfo.setImgHeight(imgHeight);
infraPictureInfo.setCoordinates(coordinates);
if (infraPictureInfo.getImgType().equals("infra_camera_reverse")) {
final String imageType = infraPictureInfo.getImgType();
if (AlgConstants.INFRA_CAMERA_REVERSE.equals(imageType)) {
//相机红外
// byte[] imageBytes = Files.readAllBytes(Paths.get(imagePath));
// infraredInfo = readDataHw(imageBytes, infraPictureInfo.getCoordinates().get(0));
InputStream inputStreamPath = downloadFtp(imagePath);
float[][] matrix = tempCount.countTemp(inputStreamPath,61.20,7.10);//最高值最低值
float[][] matrix = tempCount.countTemp(inputStreamPath, 61.20, 7.10);//最高值最低值
infraredInfo.setTemperatureMatrix(matrix);
//画框标注
String s = ImageOverlays(infraPictureInfo, infraredInfo);
infraredInfo.setOutPath(s);
} else if (infraPictureInfo.getImgType().equals("infra_1800")) {
} else if (AlgConstants.INFRA_1800.equals(imageType)) {
//ivs1800红外图
String s = ImageOverlays(infraPictureInfo, infraredInfo);
infraredInfo.setOutPath(s);
} else if (infraPictureInfo.getImgType().equals("infra_yu3")) {
} else if (AlgConstants.INFRA_YU3.equals(imageType)) {
//无人机红外图
// sdk版本调用x64
// float[][] imageTem = djService.getImageTem("D:/projects/pic/hw/1.JPG");
if (!produceEnvironment) {
//调用华软接口
String protocol = hrFtpUrl.substring(0, 6); // "ftp://"
String withoutProtocol = hrFtpUrl.substring(6); // "zthr02:zthr02@123.184.14.138:50021/"
String[] userAndHost = withoutProtocol.split("@");
if (userAndHost.length != 2) {
throw new IllegalArgumentException("URL 格式错误,缺少 @ 分隔符");
}
String[] userPass = userAndHost[0].split(":");
String username = userPass[0];
String password = userPass[1];
String hostPort = userAndHost[1].replace("/", ""); // 移除末尾的 "/"
String[] hostAndPort = hostPort.split(":");
String host = hostAndPort[0];
int port = Integer.parseInt(hostAndPort[1]);
String imageName = Paths.get(imagePath).getFileName().toString();
boolean isLoginHr = pic2Ftp(imageName, inputStream, host, port, username, password);
String ftpUrlName = "[\"" + hrFtpUrl + imageName + "\"]";
//调用华软接口
String protocol = hrFtpUrl.substring(0, 6); // "ftp://"
String withoutProtocol = hrFtpUrl.substring(6); // "zthr02:zthr02@123.184.14.138:50021/"
String[] userAndHost = withoutProtocol.split("@");
if (userAndHost.length != 2) {
throw new IllegalArgumentException("URL 格式错误,缺少 @ 分隔符");
}
String[] userPass = userAndHost[0].split(":");
String username = userPass[0];
String password = userPass[1];
String hostPort = userAndHost[1].replace("/", ""); // 移除末尾的 "/"
String[] hostAndPort = hostPort.split(":");
String host = hostAndPort[0];
int port = Integer.parseInt(hostAndPort[1]);
String imageName = Paths.get(imagePath).getFileName().toString();
boolean isLoginHr = pic2Ftp(imageName, inputStream, host, port, username, password);
String ftpUrlName = "[\"" + hrFtpUrl + imageName + "\"]";
float[][] imageTem = new float[0][];
if (isLoginHr) {
@ -1255,7 +1261,7 @@ public class HikVisionServiceImpl implements HikVisionService {
infraredInfo.setOutPath(s);
}
}
}
return infraredInfo;
}


Loading…
Cancel
Save