提交 | 用户 | 时间
|
149dd0
|
1 |
package com.iailab.module.data.video.dahua; |
H |
2 |
|
08b6a5
|
3 |
import com.iailab.module.data.video.config.VideoConfiguration; |
H |
4 |
import com.iailab.module.data.video.service.CameraService; |
149dd0
|
5 |
import com.iailab.netsdk.lib.NetSDKLib; |
H |
6 |
import com.sun.jna.Pointer; |
|
7 |
|
08b6a5
|
8 |
import javax.annotation.Resource; |
149dd0
|
9 |
import javax.imageio.ImageIO; |
H |
10 |
import java.awt.image.BufferedImage; |
|
11 |
import java.io.ByteArrayInputStream; |
|
12 |
import java.io.File; |
|
13 |
import java.io.IOException; |
|
14 |
import java.util.Calendar; |
|
15 |
import java.util.HashMap; |
|
16 |
import java.util.Map; |
|
17 |
|
|
18 |
/** |
|
19 |
* 设置抓图回调 |
|
20 |
* |
|
21 |
* @author PanZhibao |
|
22 |
* @Description |
|
23 |
* @createTime 2024年03月06日 |
|
24 |
*/ |
|
25 |
public class DHCaptureReceiveCB implements NetSDKLib.fSnapRev { |
|
26 |
|
08b6a5
|
27 |
@Resource |
H |
28 |
private CameraService cameraService; |
|
29 |
|
149dd0
|
30 |
@Override |
H |
31 |
public void invoke(NetSDKLib.LLong lLoginID, Pointer pBuf, int revLen, int encodeType, int cmdSerial, Pointer dwUser) { |
|
32 |
System.out.println("DHCaptureReceiveCB:"); |
|
33 |
Calendar calendar = Calendar.getInstance(); |
|
34 |
if (pBuf != null && revLen > 0) { |
|
35 |
String strFileName = DHSavePath.getSavePath().getSaveCapturePath(String.valueOf(cmdSerial), calendar.getTime()); |
|
36 |
System.out.println("cmdSerial=" + cmdSerial); |
|
37 |
System.out.println("strFileName=" + strFileName); |
|
38 |
|
|
39 |
byte[] buf = pBuf.getByteArray(0, revLen); |
|
40 |
ByteArrayInputStream byteArrInput = new ByteArrayInputStream(buf); |
|
41 |
try { |
|
42 |
BufferedImage bufferedImage = ImageIO.read(byteArrInput); |
|
43 |
if (bufferedImage == null) { |
|
44 |
return; |
|
45 |
} |
|
46 |
ImageIO.write(bufferedImage, "jpg", new File(strFileName)); |
|
47 |
} catch (IOException e) { |
|
48 |
e.printStackTrace(); |
|
49 |
} |
|
50 |
|
08b6a5
|
51 |
// 处理图片 |
149dd0
|
52 |
Map<String, String> params = new HashMap<>(); |
H |
53 |
params.put("strFileName", strFileName); |
|
54 |
params.put("cmdSerial", Integer.valueOf(cmdSerial).toString()); |
08b6a5
|
55 |
params.put("brand", "DH"); |
H |
56 |
cameraService.dealCapture(params); |
149dd0
|
57 |
} |
H |
58 |
} |
|
59 |
} |