-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathevaluation_example.py
More file actions
70 lines (51 loc) · 2.45 KB
/
Copy pathevaluation_example.py
File metadata and controls
70 lines (51 loc) · 2.45 KB
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
import cv2
import numpy as np
from radar_optical_flow import RadarOpticalFlowExtrapolation, OpticalFlowMethod
def create_evaluation_test_images():
img1 = np.zeros((400, 400, 3), dtype=np.uint8)
cv2.circle(img1, (150, 150), 50, (0, 255, 0), -1)
cv2.circle(img1, (250, 250), 30, (0, 200, 0), -1)
img2 = np.zeros((400, 400, 3), dtype=np.uint8)
cv2.circle(img2, (170, 170), 50, (0, 255, 0), -1)
cv2.circle(img2, (270, 270), 30, (0, 200, 0), -1)
img3 = np.zeros((400, 400, 3), dtype=np.uint8)
cv2.circle(img3, (190, 190), 50, (0, 255, 0), -1)
cv2.circle(img3, (290, 290), 30, (0, 200, 0), -1)
cv2.imwrite('eval_img1.png', img1)
cv2.imwrite('eval_img2.png', img2)
cv2.imwrite('eval_img3.png', img3)
return img1, img2, img3
def evaluate_all_methods():
print("=== 雷达外推评估测试 ===\n")
create_evaluation_test_images()
# 使用真实的radar_frame系列图像
img1 = cv2.imread('radar_frame_0.png')
img2 = cv2.imread('radar_frame_1.png')
img3 = cv2.imread('radar_frame_2.png')
if img1 is None or img2 is None or img3 is None:
create_evaluation_test_images()
methods = ['farneback', 'lucas_kanade', 'dis']
for method in methods:
print(f"评估方法: {method}")
print("-" * 40)
extrapolator = RadarOpticalFlowExtrapolation(method=OpticalFlowMethod[method.upper()])
predicted = extrapolator.extrapolate(img1, img2, steps=1)
metrics = extrapolator.evaluate(predicted, img3, threshold=50)
print(f"TS评分: {metrics['TS']:.3f}")
print(f"POD探测率: {metrics['POD']:.3f}")
print(f"FAR虚警率: {metrics['FAR']:.3f}")
print(f"BIAS偏差: {metrics['BIAS']:.3f}")
print(f"RMSE误差: {metrics['RMSE']:.1f}")
print(f"命中数: {metrics['hits']}")
print(f"漏报数: {metrics['misses']}")
print(f"虚警数: {metrics['false_alarms']}")
print()
cv2.imwrite(f'eval_pred_{method}_radar.png', predicted)
print("=== 指标说明 ===")
print("TS评分: 0-1,越高越好,综合准确率")
print("POD探测率: 0-1,越高越好,正确探测的比例")
print("FAR虚警率: 0-1,越低越好,错误预报的比例")
print("BIAS偏差: >1高估,<1低估,=1完美")
print("RMSE误差: 越低越好,像素强度差异")
if __name__ == "__main__":
evaluate_all_methods()