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;
|
}
|
}
|