|
@@ -1,7 +1,6 @@
|
|
|
package com.zd.forward.serivce;
|
|
package com.zd.forward.serivce;
|
|
|
|
|
|
|
|
import com.zd.common.core.exception.ServiceException;
|
|
import com.zd.common.core.exception.ServiceException;
|
|
|
-import com.zd.common.core.utils.IdGen;
|
|
|
|
|
import com.zd.forward.config.AlgorithmYml;
|
|
import com.zd.forward.config.AlgorithmYml;
|
|
|
import com.zd.forward.domain.AnalysisData;
|
|
import com.zd.forward.domain.AnalysisData;
|
|
|
import com.zd.forward.domain.DataPostAnalysisRespDto;
|
|
import com.zd.forward.domain.DataPostAnalysisRespDto;
|
|
@@ -24,7 +23,6 @@ import javax.imageio.ImageIO;
|
|
|
import java.awt.image.BufferedImage;
|
|
import java.awt.image.BufferedImage;
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
-import java.nio.file.Files;
|
|
|
|
|
import java.util.Collections;
|
|
import java.util.Collections;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -67,7 +65,7 @@ public class FireImageService {
|
|
|
@Value("${file.path:/home/AIPIC}")
|
|
@Value("${file.path:/home/AIPIC}")
|
|
|
private String imagePath;
|
|
private String imagePath;
|
|
|
|
|
|
|
|
- public void catchImage() throws Exception {
|
|
|
|
|
|
|
+ public void catchImage() throws IOException {
|
|
|
String streamUrl = fireProperties.getStreamUrl();
|
|
String streamUrl = fireProperties.getStreamUrl();
|
|
|
if (streamUrl == null) {
|
|
if (streamUrl == null) {
|
|
|
throw new ServiceException("未配置流媒体地址");
|
|
throw new ServiceException("未配置流媒体地址");
|
|
@@ -75,10 +73,9 @@ public class FireImageService {
|
|
|
|
|
|
|
|
try (FFmpegFrameGrabber grabber = VideoUtils.createGrabber(streamUrl)) {
|
|
try (FFmpegFrameGrabber grabber = VideoUtils.createGrabber(streamUrl)) {
|
|
|
grabber.start();
|
|
grabber.start();
|
|
|
- String uuid = IdGen.uuid();
|
|
|
|
|
|
|
+ String fileName = "test";
|
|
|
//文件储存对象
|
|
//文件储存对象
|
|
|
- String fileName = imagePath + File.separator + uuid;
|
|
|
|
|
- File tempFile = File.createTempFile(fileName, "." + IMAGE_FORMAT);
|
|
|
|
|
|
|
+ File file=new File(fileName+"." + IMAGE_FORMAT);
|
|
|
//获取第一帧
|
|
//获取第一帧
|
|
|
Frame frame = grabber.grabFrame();
|
|
Frame frame = grabber.grabFrame();
|
|
|
if (frame != null) {
|
|
if (frame != null) {
|
|
@@ -86,16 +83,16 @@ public class FireImageService {
|
|
|
frame = grabber.grabImage();
|
|
frame = grabber.grabImage();
|
|
|
BufferedImage bufferedImage = frameToBufferedImage(frame);
|
|
BufferedImage bufferedImage = frameToBufferedImage(frame);
|
|
|
if (bufferedImage != null) {
|
|
if (bufferedImage != null) {
|
|
|
- ImageIO.write(bufferedImage, IMAGE_FORMAT, tempFile);
|
|
|
|
|
|
|
+ ImageIO.write(bufferedImage, IMAGE_FORMAT, file);
|
|
|
}
|
|
}
|
|
|
- log.info("图片地址为[{}]", tempFile.getAbsoluteFile());
|
|
|
|
|
|
|
+ log.info("图片地址为[{}]", file.getAbsoluteFile());
|
|
|
grabber.stop();
|
|
grabber.stop();
|
|
|
- send(tempFile);
|
|
|
|
|
|
|
+ send(file);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void send(File file) throws IOException {
|
|
|
|
|
|
|
+ private void send(File file) {
|
|
|
if (fireProperties.getAlgoId() == null) {
|
|
if (fireProperties.getAlgoId() == null) {
|
|
|
throw new ServiceException("未配置火焰算法ID");
|
|
throw new ServiceException("未配置火焰算法ID");
|
|
|
}
|
|
}
|
|
@@ -125,7 +122,6 @@ public class FireImageService {
|
|
|
sendSginAccessLogService.saveAlarm(fireProperties);
|
|
sendSginAccessLogService.saveAlarm(fireProperties);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- Files.delete(file.getAbsoluteFile().toPath());
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|