Skip to content

Commit

Permalink
Fixed the metrics. (#424)
Browse files Browse the repository at this point in the history
  • Loading branch information
ATATC committed Oct 2, 2024
1 parent 17d7510 commit a74ba56
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions leads_vec/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from PIL.Image import open
from customtkinter import CTkLabel, DoubleVar
from cv2 import VideoCapture, imencode, IMWRITE_JPEG_QUALITY
from cv2 import VideoCapture, imencode, IMWRITE_JPEG_QUALITY, CAP_PROP_FPS

from leads import L, require_config
from leads_gui import RuntimeData, Window, ContextManager, Speedometer
Expand All @@ -26,6 +26,7 @@ def video_tester(container: Callable[[], None]) -> float:
def video_test() -> dict[str, float]:
r = {}
vc = VideoCapture(require_config().get("benchmark_camera_port", 0))
r["camera fps"] = vc.get(CAP_PROP_FPS)
if not vc.isOpened():
L.error("No camera available")
return r
Expand Down Expand Up @@ -84,12 +85,13 @@ def main() -> int:
L.info("Video test complete")
for k, v in report.items():
L.info(f"{k}: {v:.3f}")
baseline = {"gui": 30, "video capture": 30, "video capture + encoding": 30, "video capture + Base64 encoding": 30,
"video capture + PIL": 30}
camera_fps = report.pop("camera fps")
baseline = {"gui": 30, "video capture": camera_fps, "video capture + encoding": camera_fps,
"video capture + Base64 encoding": camera_fps, "video capture + PIL": camera_fps}
score = 0
for k, v in report.items():
score += v / baseline[k]
L.info("Score:", str(score / len(report)))
L.info(f"Score: {100 * score / len(report):.2f}%")
return 0


Expand Down

0 comments on commit a74ba56

Please sign in to comment.