1
zhanghua
2024-09-26 c775c6953d9759e70f08acbfa8f6d7490aaae3d1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
package com.netsdk.demo.customize.turkcell;
 
import com.netsdk.lib.NetSDKLib;
import com.netsdk.lib.ToolKits;
import com.sun.jna.Pointer;
 
import java.io.File;
import java.nio.charset.Charset;
 
import static com.netsdk.lib.NetSDKLib.*;
 
 
/**
 * @author 47081
 * @version 1.0
 * @description 智能事件分析回调
 * @date 2020/6/12
 */
public class TurkcellAnalyzerCallback implements NetSDKLib.fAnalyzerDataCallBack {
    private String imagePath="D:\\trafficPath";
    private static TurkcellAnalyzerCallback INSTANCE;
    private TurkcellAnalyzerCallback(){
        File file=new File(imagePath);
        if(!file.exists()){
            file.mkdirs();
        }
    }
    public static TurkcellAnalyzerCallback getInstance(){
        if(INSTANCE==null){
            INSTANCE=new TurkcellAnalyzerCallback();
        }
        return INSTANCE;
    }
    @Override
    public int invoke(NetSDKLib.LLong lAnalyzerHandle, int dwAlarmType, Pointer pAlarmInfo, Pointer pBuffer, int dwBufSize, Pointer dwUser, int nSequence, Pointer reserved) {
        if(lAnalyzerHandle.longValue()==-1){
            return 0;
        }
        String date=null;
        String imageName;
        String savePath;
        if(dwAlarmType== EVENT_IVS_TRAFFICJUNCTION){
            //路口事件,抓拍车牌
            NetSDKLib.DEV_EVENT_TRAFFICJUNCTION_INFO trafficJunction=new NetSDKLib.DEV_EVENT_TRAFFICJUNCTION_INFO();
            //获取车牌信息
            ToolKits.GetPointerDataToStruct(pAlarmInfo,0,trafficJunction);
            date=trafficJunction.UTC.toStringTime();
            NetSDKLib.DEV_EVENT_TRAFFIC_TRAFFICCAR_INFO trafficCar=trafficJunction.stTrafficCar;
            System.out.println(date+" traffic number:"+new String(trafficCar.szPlateNumber,Charset.forName("GBK"))+",plate color:"+new String(trafficCar.szPlateColor,Charset.forName("GBK")));
            //save the picture
            imageName="trafficJunction_"+trafficJunction.UTC.toStringTitle()+".jpg";
            savePath=imagePath+"/"+imageName;
 
            ToolKits.savePicture(pBuffer,dwBufSize,savePath);
            System.out.println("save picture to "+savePath);
        }else if(dwAlarmType==EVENT_IVS_TRAFFIC_DRIVER_SMOKING){
            //驾驶员抽烟事件
            NetSDKLib.DEV_EVENT_TRAFFIC_DRIVER_SMOKING driverSmoking=new NetSDKLib.DEV_EVENT_TRAFFIC_DRIVER_SMOKING();
            ToolKits.GetPointerData(pAlarmInfo,driverSmoking);
            //事件时间
            date=driverSmoking.UTC.toStringTime();
            System.out.println(date+" event type: TRAFFIC_DRIVER_SMOKING");
            //save picture
            imageName="driverSmoking_"+driverSmoking.UTC.toStringTitle()+".jpg";
            savePath=imagePath+"/"+imageName;
 
            ToolKits.savePicture(pBuffer,dwBufSize,savePath);
            System.out.println("save picture to "+savePath);
 
 
        }else if(dwAlarmType==EVENT_IVS_TRAFFIC_DRIVER_CALLING){
            //驾驶员打电话事件
            NetSDKLib.DEV_EVENT_TRAFFIC_DRIVER_CALLING driverCalling=new NetSDKLib.DEV_EVENT_TRAFFIC_DRIVER_CALLING();
            ToolKits.GetPointerData(pAlarmInfo,driverCalling);
            //事件时间
            date=driverCalling.UTC.toStringTime();
            System.out.println(date+" event type: TRAFFIC_DRIVER_CALLING");
            //save picture
            imageName="driverCalling_"+driverCalling.UTC.toStringTitle()+".jpg";
            savePath=imagePath+"/"+imageName;
 
            ToolKits.savePicture(pBuffer,dwBufSize,savePath);
            System.out.println("save picture to "+savePath);
 
        }else if(dwAlarmType==EVENT_IVS_TRAFFIC_TIREDPHYSIOLOGICAL){
            //驾驶员疲劳驾驶事件
            DEV_EVENT_TIREDPHYSIOLOGICAL_INFO tiredPhysiological=new DEV_EVENT_TIREDPHYSIOLOGICAL_INFO();
            ToolKits.GetPointerDataToStruct(pAlarmInfo,0,tiredPhysiological);
            //事件时间
            date=tiredPhysiological.UTC.toStringTime();
            System.out.println(date+" event type: TIREDPHYSIOLOGICAL");
            //save picture
            imageName="tiredPhysiological_"+tiredPhysiological.UTC.toStringTitle()+".jpg";
            savePath=imagePath+"/"+imageName;
 
            ToolKits.savePicture(pBuffer,dwBufSize,savePath);
            System.out.println("save picture to "+savePath);
 
        }else if(dwAlarmType==EVENT_IVS_TRAFFIC_TIREDLOWERHEAD){
            //开车低头事件
            DEV_EVENT_TIREDLOWERHEAD_INFO tiredLowerHead=new DEV_EVENT_TIREDLOWERHEAD_INFO();
            ToolKits.GetPointerDataToStruct(pAlarmInfo,0,tiredLowerHead);
            //事件时间
            date=tiredLowerHead.UTC.toStringTime();
            System.out.println(date+" event type: TiredLowerHead");
            //save picture
            imageName="tiredLowerHead_"+tiredLowerHead.UTC.toStringTitle()+".jpg";
            savePath=imagePath+"/"+imageName;
 
            ToolKits.savePicture(pBuffer,dwBufSize,savePath);
            System.out.println("save picture to "+savePath);
 
        }else if(dwAlarmType==EVENT_IVS_TRAFFIC_DRIVERLOOKAROUND){
            //开车左顾右盼事件
            DEV_EVENT_DRIVERLOOKAROUND_INFO driverLookAround=new DEV_EVENT_DRIVERLOOKAROUND_INFO();
            ToolKits.GetPointerDataToStruct(pAlarmInfo,0,driverLookAround);
            date=driverLookAround.UTC.toStringTime();
            System.out.println(date+" event type: DriverLookAround,channel");
            //save picture
            imageName="driverLookAround_"+driverLookAround.UTC.toStringTitle()+".jpg";
            savePath=imagePath+"/"+imageName;
 
            ToolKits.savePicture(pBuffer,dwBufSize,savePath);
            System.out.println("save picture to "+savePath);
 
        }else if(dwAlarmType==EVENT_IVS_TRAFFIC_DRIVERYAWN){
            //打哈欠事件
            DEV_EVENT_DRIVERYAWN_INFO driverYawn=new DEV_EVENT_DRIVERYAWN_INFO();
            ToolKits.GetPointerDataToStruct(pAlarmInfo,0,driverYawn);
            date=driverYawn.UTC.toStringTime();
            System.out.println(date+" event type: DriverYawn,channelID: "+driverYawn.nChannelID);
            //save picture
            imageName="driverYawn_"+driverYawn.UTC.toStringTitle()+".jpg";
            savePath=imagePath+"/"+imageName;
 
            ToolKits.savePicture(pBuffer,dwBufSize,savePath);
            System.out.println("save picture to "+savePath);
 
        }else{
            System.out.println("other event");
        }
        return 0;
    }
}