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
package com.netsdk.demo.customize.faceReconEx;
 
import com.netsdk.lib.NetSDKLib;
import com.netsdk.lib.ToolKits;
 
import java.util.Map;
 
import static com.netsdk.demo.util.StructFieldChooser.*;
 
/**
 * @author 47040
 * @since Created in 2020/11/16 16:09
 */
public class SelectedFieldReadTest {
 
    private static final Map<?, ?> structConfig = GetStructConfig(SelectedFieldReadTest.class, "FaceRecon.json");
 
 
    public static void main(String[] args) {
 
        SelectFieldWithConfig();
 
    }
 
    private static void SelectFieldWithConfig() {
        long a = System.currentTimeMillis();
        NetSDKLib.DEV_EVENT_FACERECOGNITION_INFO testStruct0 = new NetSDKLib.DEV_EVENT_FACERECOGNITION_INFO();
        long b = System.currentTimeMillis();
        System.out.println(b - a);
 
        NetSDKLib.DEV_EVENT_FACERECOGNITION_INFO struct = new NetSDKLib.DEV_EVENT_FACERECOGNITION_INFO();
 
        struct.szName[1] = 'a';
 
        struct.UTC = new NetSDKLib.NET_TIME_EX();
        struct.UTC.setTime(2020, 11, 16, 20, 30, 30);
 
        struct.stuObject = new NetSDKLib.NET_MSG_OBJECT();
        struct.stuObject.stPicInfo = new NetSDKLib.NET_PIC_INFO();
        struct.stuObject.stPicInfo.dwFileLenth = 1000;
        struct.stuObject.stPicInfo.dwOffSet = 2000;
 
        struct.nCandidateNum = 2;
        struct.stuCandidates[0] = new NetSDKLib.CANDIDATE_INFO();
        struct.stuCandidates[0].stPersonInfo = new NetSDKLib.FACERECOGNITION_PERSON_INFO();
        struct.stuCandidates[0].stPersonInfo.wFacePicNum = 1;
        struct.stuCandidates[0].stPersonInfo.szFacePicInfo[0] = new NetSDKLib.NET_PIC_INFO();
        struct.stuCandidates[0].stPersonInfo.szFacePicInfo[0].dwFileLenth = 100;
        struct.stuCandidates[0].stPersonInfo.szFacePicInfo[0].dwOffSet = 200;
        struct.stuCandidates[0].bySimilarity = 80;
        struct.stuCandidates[1] = new NetSDKLib.CANDIDATE_INFO();
        struct.stuCandidates[1].stPersonInfo = new NetSDKLib.FACERECOGNITION_PERSON_INFO();
        struct.stuCandidates[1].stPersonInfo.wFacePicNum = 1;
        struct.stuCandidates[1].stPersonInfo.szFacePicInfo[0] = new NetSDKLib.NET_PIC_INFO();
        struct.stuCandidates[1].stPersonInfo.szFacePicInfo[0].dwFileLenth = 150;
        struct.stuCandidates[1].stPersonInfo.szFacePicInfo[0].dwOffSet = 250;
        struct.stuCandidates[1].bySimilarity = 85;
 
        struct.write();
 
        NetSDKLib.DEV_EVENT_FACERECOGNITION_INFO testStruct = new NetSDKLib.DEV_EVENT_FACERECOGNITION_INFO();
 
        long startTime = System.currentTimeMillis();
 
        ReadAllSelectedFields(structConfig, testStruct, struct.getPointer());
 
        long endTime = System.currentTimeMillis();
        long readAllCost = (endTime - startTime);
        System.out.println("Read All Cost Time:" + readAllCost);
 
        startTime = System.currentTimeMillis();
 
        testStruct.szName[1] = (Byte) GetSelectedSingleFieldValue("szName[1]", testStruct, struct.getPointer());
        testStruct.UTC = (NetSDKLib.NET_TIME_EX) GetSelectedSingleFieldValue("UTC", testStruct, struct.getPointer());
        testStruct.stuObject.stPicInfo.dwFileLenth = (Integer) GetSelectedSingleFieldValue("stuObject.stPicInfo.dwFileLenth", testStruct, struct.getPointer());
        testStruct.stuObject.stPicInfo.dwOffSet = (Integer) GetSelectedSingleFieldValue("stuObject.stPicInfo.dwOffSet", testStruct, struct.getPointer());
 
        testStruct.nCandidateNum = (Integer) GetSelectedSingleFieldValue("nCandidateNum", testStruct, struct.getPointer());
        testStruct.stuCandidates[0].stPersonInfo.wFacePicNum = (Short) GetSelectedSingleFieldValue("stuCandidates[0].stPersonInfo.wFacePicNum", testStruct, struct.getPointer());
        ;
        testStruct.stuCandidates[0].stPersonInfo.szFacePicInfo[0].dwFileLenth = (Integer) GetSelectedSingleFieldValue("stuCandidates[0].stPersonInfo.szFacePicInfo[0].dwFileLenth", testStruct, struct.getPointer());
        testStruct.stuCandidates[0].stPersonInfo.szFacePicInfo[0].dwOffSet = (Integer) GetSelectedSingleFieldValue("stuCandidates[0].stPersonInfo.szFacePicInfo[0].dwOffSet", testStruct, struct.getPointer());
        testStruct.stuCandidates[0].bySimilarity = (Byte) GetSelectedSingleFieldValue("stuCandidates[0].bySimilarity", testStruct, struct.getPointer());
        testStruct.stuCandidates[1].stPersonInfo.wFacePicNum = (Short) GetSelectedSingleFieldValue("stuCandidates[1].stPersonInfo.wFacePicNum", testStruct, struct.getPointer());
        ;
        testStruct.stuCandidates[1].stPersonInfo.szFacePicInfo[0].dwFileLenth = (Integer) GetSelectedSingleFieldValue("stuCandidates[1].stPersonInfo.szFacePicInfo[0].dwFileLenth", testStruct, struct.getPointer());
        testStruct.stuCandidates[1].stPersonInfo.szFacePicInfo[0].dwOffSet = (Integer) GetSelectedSingleFieldValue("stuCandidates[1].stPersonInfo.szFacePicInfo[0].dwOffSet", testStruct, struct.getPointer());
        testStruct.stuCandidates[1].bySimilarity = (Byte) GetSelectedSingleFieldValue("stuCandidates[1].bySimilarity", testStruct, struct.getPointer());
 
        endTime = System.currentTimeMillis();
        long readSingleCost = (endTime - startTime);
        System.out.println("Read Single Cost Time:" + readSingleCost);
 
        startTime = System.currentTimeMillis();
        ToolKits.GetPointerDataToStruct(struct.getPointer(), 0, testStruct);
        endTime = System.currentTimeMillis();
        long noHelpCost = (endTime - startTime);
        System.out.println("无优化 Cost Time:" + noHelpCost);
        System.out.println("效率提升: " + (noHelpCost) / Math.min(readAllCost, readSingleCost) + " 倍");
    }
}