|
|
|
@ -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; |
|
|
|
} |
|
|
|
|
|
|
|
|