shikeying
2022-09-27 26f5dd8ef80e5671cda8fc0e6c0d0298c4e678ff
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
package com.iplatform.recvideo;
 
import com.walker.infrastructure.utils.NumberFormatUtils;
 
/**
 * 相似视频对象定义。
 * @author 时克英
 * @date 2022-09-24
 */
public class SimilarVideoInfo implements Comparable<SimilarVideoInfo> {
 
    private String id;
 
    private double distance = 0;
 
    // 这个相似视频,对应的源视频图像张数
    private int count = 0;
 
    private double score = 0;
 
//    private DecimalFormat df = new DecimalFormat("#.00");
 
    public String getId() {
        return id;
    }
 
    public double getDistance() {
        return distance;
    }
 
    public SimilarVideoInfo(String id, double distance){
        this.id = id;
        this.distance = distance;
    }
 
    /**
     * 返回相似视频的排名分值,目前简单根据数量百分比计算。
     * @return
     */
    public double getScore(){
        if(this.score > 0){
            return this.score;
        }
        if(count == 0){
            return 0;
        }
        double s = (this.count)/100.0;
//        String score = df.format(s);
//        this.score = Double.parseDouble(score);
        this.score = NumberFormatUtils.scaleAccuracy2(s);
        return this.score;
    }
 
    public void increase(){
        this.count ++;
    }
 
    public void setDistance(double distance){
        this.distance = distance;
    }
 
    @Override
    public String toString(){
        return new StringBuilder("[id=").append(id)
                .append(", dis=").append(this.distance)
                .append("]").toString();
    }
 
    @Override
    public int hashCode(){
        return this.id.hashCode();
    }
 
    @Override
    public boolean equals(Object obj){
        if(obj == null){
            return false;
        }
        if(obj instanceof SimilarVideoInfo){
            SimilarVideoInfo e = (SimilarVideoInfo)obj;
            if(e.id.equals(this.id)){
                return true;
            }
        }
        return false;
    }
 
    @Override
    public int compareTo(SimilarVideoInfo o) {
        return o.count - this.count;
    }
}