|
|
|
@ -24,6 +24,8 @@ import com.inspect.simulator.hikVision.utils.jna.HCNetSDK; |
|
|
|
import com.inspect.simulator.mapper.BasedataEqpBookChannelMapper; |
|
|
|
import com.inspect.simulator.service.HikVisionService; |
|
|
|
import com.inspect.simulator.service.remote.AnalysisRemoteService; |
|
|
|
import com.inspect.simulator.tempCount.TempCount; |
|
|
|
import com.inspect.simulator.tempCount.TemperatureStats; |
|
|
|
import com.inspect.simulator.utils.HttpClientUtils; |
|
|
|
import com.inspect.simulator.utils.sftp.SftpClient; |
|
|
|
import com.sun.jna.ptr.IntByReference; |
|
|
|
@ -67,8 +69,8 @@ public class HikVisionServiceImpl implements HikVisionService { |
|
|
|
|
|
|
|
// @Autowired |
|
|
|
// private HCNetSDK hcNetSDK; |
|
|
|
|
|
|
|
// @Autowired |
|
|
|
// |
|
|
|
// @Resource |
|
|
|
// private DjService djService; |
|
|
|
|
|
|
|
@Value("${file.picPath:test}") |
|
|
|
@ -95,6 +97,9 @@ public class HikVisionServiceImpl implements HikVisionService { |
|
|
|
@Resource |
|
|
|
private SftpClient sftpClient; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private TempCount tempCount; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private BasedataEqpBookChannelMapper basedataEqpBookChannelMapper; |
|
|
|
|
|
|
|
@ -307,11 +312,11 @@ public class HikVisionServiceImpl implements HikVisionService { |
|
|
|
@Override |
|
|
|
public AjaxResult capturePicture(InfraPictureInfo infraPictureInfo) { |
|
|
|
log.info("capturePicture, coordinate:{}", infraPictureInfo); |
|
|
|
if (infraPictureInfo.getImgType() == 1) { |
|
|
|
if (infraPictureInfo.getImgType().equals("infra_camera_reverse")) { |
|
|
|
return AjaxResult.success("设置成功"); |
|
|
|
} else if (infraPictureInfo.getImgType() == 2) { |
|
|
|
} else if (infraPictureInfo.getImgType().equals("infra_1800")) { |
|
|
|
return AjaxResult.success("设置成功"); |
|
|
|
} else if (infraPictureInfo.getImgType() == 3) { |
|
|
|
} else if (infraPictureInfo.getImgType().equals("infra_yu3")) { |
|
|
|
Long channelId = infraPictureInfo.getChannelId(); |
|
|
|
//channelId = 1299L; |
|
|
|
BasedataEqpBookChannel basedataEqpBookChannel = basedataEqpBookChannelMapper.selectBasedataEqpBookChannelByChannelId(channelId); |
|
|
|
@ -588,35 +593,7 @@ public class HikVisionServiceImpl implements HikVisionService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//NVR返回字符串根据宽高,获取温度矩阵 |
|
|
|
private float[][] getMatrix(Integer picWidth, Integer height) { |
|
|
|
float[][] tempMatrix = new float[height][picWidth]; |
|
|
|
String temperatureStr = "11.00,12.00,12.00,14.00,15.00,22.00,33.00,22.00"; |
|
|
|
String[] tempValues = temperatureStr.split(","); |
|
|
|
float[] temps = new float[tempValues.length]; |
|
|
|
for (int i = 0; i < tempValues.length; i++) { |
|
|
|
temps[i] = Float.parseFloat(tempValues[i]); |
|
|
|
} |
|
|
|
|
|
|
|
// 初始化矩阵,默认填充0.00 |
|
|
|
for (int i = 0; i < height; i++) { |
|
|
|
for (int j = 0; j < picWidth; j++) { |
|
|
|
tempMatrix[i][j] = 0.00f; |
|
|
|
} |
|
|
|
} |
|
|
|
// 按行优先填充数据 |
|
|
|
int index = 0; |
|
|
|
for (int i = 0; i < height; i++) { |
|
|
|
for (int j = 0; j < picWidth; j++) { |
|
|
|
if (index < temps.length) { |
|
|
|
tempMatrix[i][j] = temps[index++]; |
|
|
|
} else { |
|
|
|
break; // 数据用完,剩余保持0.00 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return tempMatrix; |
|
|
|
} |
|
|
|
|
|
|
|
//图片标注__无人机/ivs1800/nvr |
|
|
|
public String ImageOverlays(InfraPictureInfo infraPictureInfo, InfraredInfo infraredInfo) { |
|
|
|
@ -661,7 +638,7 @@ public class HikVisionServiceImpl implements HikVisionService { |
|
|
|
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
|
|
|
Font font = new Font("微软雅黑", Font.BOLD, 17); |
|
|
|
|
|
|
|
if (infraPictureInfo.getImgType() == 3) { |
|
|
|
if (infraPictureInfo.getImgType().equals("infra_yu3")) { |
|
|
|
for (Coordinate c : coordinates) { |
|
|
|
//点标注 |
|
|
|
if (c.getFirstX() != null && c.getFirstY() != null && c.getSecondX() == null && c.getSecondY() == null) { |
|
|
|
@ -720,7 +697,7 @@ public class HikVisionServiceImpl implements HikVisionService { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (infraPictureInfo.getImgType() == 2) { |
|
|
|
} else if (infraPictureInfo.getImgType().equals("infra_1800")) { |
|
|
|
for (Coordinate c : coordinates) { |
|
|
|
g2d.setFont(font); |
|
|
|
//矩阵标注 |
|
|
|
@ -759,12 +736,13 @@ public class HikVisionServiceImpl implements HikVisionService { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (infraPictureInfo.getImgType() == 1) { |
|
|
|
} else if (infraPictureInfo.getImgType().equals("infra_camera_reverse")) { |
|
|
|
for (Coordinate c : coordinates) { |
|
|
|
g2d.setFont(font); |
|
|
|
//矩阵标注 |
|
|
|
if (c.getSecondX() != null && c.getSecondY() != null) { |
|
|
|
// 标注矩形(每两个点确定一个矩形) |
|
|
|
g2d.setColor(Color.RED); |
|
|
|
g2d.setColor(Color.WHITE); |
|
|
|
int x1 = c.getFirstX(); |
|
|
|
int y1 = c.getFirstY(); |
|
|
|
int x2 = c.getSecondX(); |
|
|
|
@ -873,6 +851,7 @@ public class HikVisionServiceImpl implements HikVisionService { |
|
|
|
return null; |
|
|
|
} |
|
|
|
return floats; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//解析获取csv文件温度 |
|
|
|
@ -1106,10 +1085,11 @@ public class HikVisionServiceImpl implements HikVisionService { |
|
|
|
final String feedbackUrl = feedBackHostIp + feedBackPort + "/picAnalyseRetNotify"; |
|
|
|
log.info("[INFRARED] irPicAnalyse: feedbackUrl={}", feedbackUrl); |
|
|
|
String[] imageUrlList = analyseReqItem.getImageUrlList(); |
|
|
|
String[] typeListImg = analyseReqItem.getTypeList(); |
|
|
|
|
|
|
|
InfraPictureInfo infraPictureInfo = new InfraPictureInfo(); |
|
|
|
// infraPictureInfo.setChannelId(); |
|
|
|
infraPictureInfo.setImgType(3); |
|
|
|
infraPictureInfo.setImgType(typeListImg[0]); |
|
|
|
infraPictureInfo.setFilePath(imageUrlList[0]); |
|
|
|
InfraredInfo infraredInfo = calculatePicture(infraPictureInfo,"1,1,639,511,640,512"); |
|
|
|
|
|
|
|
@ -1181,24 +1161,28 @@ public class HikVisionServiceImpl implements HikVisionService { |
|
|
|
infraPictureInfo.setImgHeight(imgHeight); |
|
|
|
infraPictureInfo.setCoordinates(coordinates); |
|
|
|
|
|
|
|
if (infraPictureInfo.getImgType() == 1) { |
|
|
|
if (infraPictureInfo.getImgType().equals("infra_camera_reverse")) { |
|
|
|
//相机红外 |
|
|
|
// byte[] imageBytes = Files.readAllBytes(Paths.get(imagePath)); |
|
|
|
// infraredInfo = readDataHw(imageBytes, infraPictureInfo.getCoordinates().get(0)); |
|
|
|
float[][] matrix = getMatrix(infraPictureInfo.getImgWidth(), infraPictureInfo.getImgHeight());//图片宽、高 |
|
|
|
|
|
|
|
InputStream inputStreamPath = downloadFtp(imagePath); |
|
|
|
|
|
|
|
float[][] matrix = tempCount.countTemp(inputStreamPath,61.20,7.10);//图,最高值,最低值 |
|
|
|
infraredInfo.setTemperatureMatrix(matrix); |
|
|
|
//画框标注 |
|
|
|
String s = ImageOverlays(infraPictureInfo, infraredInfo); |
|
|
|
infraredInfo.setOutPath(s); |
|
|
|
|
|
|
|
} else if (infraPictureInfo.getImgType() == 2) { |
|
|
|
} else if (infraPictureInfo.getImgType().equals("infra_1800")) { |
|
|
|
//ivs1800红外图 |
|
|
|
String s = ImageOverlays(infraPictureInfo, infraredInfo); |
|
|
|
infraredInfo.setOutPath(s); |
|
|
|
} else if (infraPictureInfo.getImgType() == 3) { |
|
|
|
} else if (infraPictureInfo.getImgType().equals("infra_yu3")) { |
|
|
|
//无人机红外图 |
|
|
|
//sdk版本调用x86_32 |
|
|
|
//float[][] imageTem = djService.getImageTem(coordinate.getFilePath()); |
|
|
|
// sdk版本调用x64 |
|
|
|
|
|
|
|
// float[][] imageTem = djService.getImageTem("D:/projects/pic/hw/1.JPG"); |
|
|
|
|
|
|
|
//调用华软接口 |
|
|
|
String protocol = hrFtpUrl.substring(0, 6); // "ftp://" |
|
|
|
@ -1227,19 +1211,17 @@ public class HikVisionServiceImpl implements HikVisionService { |
|
|
|
infraredInfo.setTemperatureMatrix(imageTem); |
|
|
|
} else { |
|
|
|
//不能调用华软接口,使用本地csv |
|
|
|
System.out.println("温度解析错误,接口无法调用!"); |
|
|
|
try { |
|
|
|
imageTem = exceptionHandling(); |
|
|
|
infraredInfo.setTemperatureMatrix(imageTem); |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
log.error("温度解析错误,接口无法调用!"); |
|
|
|
} |
|
|
|
} |
|
|
|
String s = ImageOverlays(infraPictureInfo, infraredInfo); |
|
|
|
infraredInfo.setOutPath(s); |
|
|
|
} else { |
|
|
|
System.out.println("温度解析错误,ftp无法登陆!"); |
|
|
|
//华软ftp不能登录,使用本地csv |
|
|
|
try { |
|
|
|
imageTem = exceptionHandling(); |
|
|
|
|