| | |
| | | |
| | | import com.alibaba.druid.util.StringUtils; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ycl.dto.video.AlarmDataParam; |
| | | import com.ycl.dto.video.AlarmParam; |
| | | import com.ycl.dto.video.CameraInfParam; |
| | | import com.ycl.dto.video.*; |
| | | import com.ycl.entity.video.VideoAlarmReport; |
| | | import com.ycl.mapper.video.VideoAlarmReportMapper; |
| | | import com.ycl.service.caseHandler.IViolationsService; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.imageio.ImageIO; |
| | | import javax.xml.bind.DatatypeConverter; |
| | | import java.awt.*; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | |
| | | |
| | | byte[] data = DatatypeConverter.parseBase64Binary(alarmParam.getPicData()); |
| | | InputStream inputStream = new ByteArrayInputStream(data); |
| | | |
| | | try { |
| | | if (!StringUtils.isEmpty(alarmParam.getAlarmData().getAlarmObject().toString())) { |
| | | String alarmObject = JSON.toJSONString(alarmParam.getAlarmData().getAlarmObject()); |
| | | if (!StringUtils.isEmpty(alarmObject)) { |
| | | BufferedImage image = ImageIO.read(inputStream); |
| | | |
| | | Graphics2D g2 = (Graphics2D)image.getGraphics(); |
| | | g2.setColor(Color.RED); |
| | | g2.setStroke(new BasicStroke(3.0f)); |
| | | List<AlarmObject> alarmObjects = JSON.parseArray(alarmObject, AlarmObject.class); |
| | | alarmObjects.forEach(o -> { |
| | | o.getObjectRect().forEach(rect -> { |
| | | g2.drawRect(rect.getX(), rect.getY(), rect.getW(), rect.getH()); |
| | | }); |
| | | }); |
| | | ByteArrayOutputStream os = new ByteArrayOutputStream(); |
| | | ImageIO.write(image, extension, os); |
| | | inputStream = new ByteArrayInputStream(os.toByteArray()); |
| | | } |
| | | } |
| | | picData = mediaFileUtil.savePicture(inputStream, extension); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |