File size: 2,978 Bytes
a80d6bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
function ImgList = merge_files(file1, file2)
    f1 = load(file1);
    ImgList_file1 = f1.ImgList;
    f2 = load(file2);
    ImgList_file2 = f2.ImgList;

    PV_topN = 10;

    n1 = 0;
    n2 = 0;
    ImgList = struct('queryname', {}, 'topNname', {}, 'topNscore', {}, 'P', {});
    for ii = 1:1:length(ImgList_file1)
        ImgList(ii).queryname = ImgList_file1(ii).queryname;
        
        sum_scores = containers.Map('KeyType', 'char', 'ValueType', 'double');
        for jj = 1 : PV_topN
            name = char(ImgList_file1(ii).topNname(jj));
            if isKey(sum_scores, name)
                sum_scores(name) = sum_scores(name) + ImgList_file1(ii).topNscore(jj);
            else
                sum_scores(name) = ImgList_file1(ii).topNscore(jj);
            end
            name = char(ImgList_file2(ii).topNname(jj));
            if isKey(sum_scores, name)
                sum_scores(name) = sum_scores(name) + ImgList_file2(ii).topNscore(jj);
            else
                sum_scores(name) = ImgList_file2(ii).topNscore(jj);
            end
        end
        
        max_score = 0;
        img_name = 0;
        for key = keys(sum_scores)
            if sum_scores(char(key)) > max_score
                max_score = sum_scores(char(key));
                img_name = key;
            end
        end
        
        id_dense = 0;
        id_sparse = 0;
        for jj = 1 : PV_topN
            if strcmp(char(ImgList_file1(ii).topNname(jj)), img_name)
                id_dense = jj;
            end
            if strcmp(char(ImgList_file2(ii).topNname(jj)), img_name)
                id_sparse = jj;
            end
        end
        
        if id_sparse == 0
            n1 = n1 + 1;
            ImgList(ii).topNscore = [ImgList_file1(ii).topNscore(id_dense)];
            ImgList(ii).topNname = [ImgList_file1(ii).topNname(id_dense)];
            ImgList(ii).P = [ImgList_file1(ii).P(id_dense)];
            continue
        end
        
        if id_dense == 0
            n2 = n2 + 1;
            ImgList(ii).topNscore = [ImgList_file2(ii).topNscore(id_sparse)];
            ImgList(ii).topNname = [ImgList_file2(ii).topNname(id_sparse)];
            ImgList(ii).P = [ImgList_file2(ii).P(id_sparse)];
            continue
        end
        
        max_score = 0;
        if ImgList_file1(ii).topNscore(id_dense) > ImgList_file2(ii).topNscore(id_sparse)
            n1 = n1 + 1;
            ImgList(ii).topNscore = [ImgList_file1(ii).topNscore(id_dense)];
            ImgList(ii).topNname = [ImgList_file1(ii).topNname(id_dense)];
            ImgList(ii).P = [ImgList_file1(ii).P(id_dense)];
        else
            n2 = n2 + 1;
            ImgList(ii).topNscore = [ImgList_file2(ii).topNscore(id_sparse)];
            ImgList(ii).topNname = [ImgList_file2(ii).topNname(id_sparse)];
            ImgList(ii).P = [ImgList_file2(ii).P(id_sparse)];
        end
    end

    fprintf(1, "%d file 1 poses & %d file 2 poses selected\n", n1, n2);
end