java特征提取_特征提取

该博客介绍了一个使用Java实现的特征点检测算法。通过创建一个Point类来表示点,利用HashMap存储每个点及其出现次数。每帧数据中,遍历所有点,如果点在上一帧存在则增加计数,否则初始化为1。最后更新最大出现次数并清空旧的点集合,以备下一次迭代。这个过程实现了对连续帧中特征点的跟踪和计数。
摘要由CSDN通过智能技术生成

自定义一个Point用来存放点,然后将point存放在map中,每次都进行更新。每一帧都新建一个map,若上一帧中存在该点,则将该点对应的值+1,并存放在map中,判断是否为新的最大。若上一帧不存在该点,则存放入map中,value为1 import java.util.*;

public class Main{

public static void main(String[] args){

Scanner sc = new Scanner(System.in);

int n = sc.nextInt();

HashMap points = new HashMap();

for(int i = 0; i < n; i ++){

int m = sc.nextInt();

int res = 0;

for(int j = 0; j < m; j ++){

int p = sc.nextInt();

HashMap tempPoints = new HashMap();

for (int k = 0; k < p; k ++){

int x = sc.nextInt();

int y = sc.nextInt();

Point temp = new Point(x,y);

Integer num = points.get(temp);

if (num == null){

num = new Integer(1);

} else{

num += 1;

}

res = num > res ? num : res;

tempPoints.put(temp,num);

}

points.clear();

points = tempPoints;

}

System.out.print(res);

}

}

}

class Point{

int x;

int y;

public Point(int x, int y) {

this.x = x;

this.y = y;

}

public Point() {

}

public int getX() {

return x;

}

public void setX(int x) {

this.x = x;

}

public int getY() {

return y;

}

public void setY(int y) {

this.y = y;

}

@Override

public boolean equals(Object o) {

if (this == o) return true;

if (o == null || getClass() != o.getClass()) return false;

Point point = (Point) o;

return x == point.x &&

y == point.y;

}

@Override

public int hashCode() {

return Objects.hash(x, y);

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值