public static ArrayList<Match> filterFarMatchL(ArrayList<Match> matches, double minX, double minY) {
int arcStep = ModifiableConst.getSolpeArcStep();
if (matches.size() <= 1) return matches;
int[] ms = new int[90 / arcStep]; // 用陣列的索引保存每個度數的key,不使用map來保存,性能優化
for (Match m : matches) {
double r = Math.atan((m.kp2.getY() + minY - m.kp1.getY()) / (m.kp2.getX() + minX - m.kp1.getX())) * 360
/ (2 * Math.PI);
m.slopeArc = (int) r / arcStep * arcStep; // 第一次計算就把 match的斜率保存起來。
if (m.slopeArc < 0) m.slopeArc += 90;
ms[m.slopeArc / arcStep] = ms[m.slopeArc / arcStep] + 1;
}
int count = 0;
int idx = 0;
for (int i = 0; i < ms.length; i++) {// 找到斜率相同的最多的一個度數
if (ms[i] > count) {
count = ms[i];
idx = i;
}
}
idx = idx * arcStep;
ArrayList<Match> survivors = new ArrayList<Match>();
for (Match m : matches) {
if (m.slopeArc == idx) survivors.add(m);
}
return survivors;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/172506.html
上一篇:windows+python+opencv環境下,cv2.VideoCapture()發現不了usb接入的攝像頭。
下一篇:有沒有大佬會selenium啊
