Spaces:
Sleeping
Sleeping
Download debug_view.py from rajesh9698/all: direct link, hf CLI and curl.
- Browser
- Download file 1.51 kB
-
https://huggingface.co/spaces/rajesh9698/all/resolve/main/debug_view.py
- Command line
-
hf download hf://spaces/rajesh9698/all/debug_view.py
-
curl -L -o debug_view.py https://huggingface.co/spaces/rajesh9698/all/resolve/main/debug_view.py
1.51 kB
| import cv2 | |
| import os | |
| import sys | |
| import numpy as np | |
| # Add backend to path | |
| sys.path.append(os.path.join(r"c:\Users\Rajesh s\Downloads\KARPAGAM HACKATHON", "backend")) | |
| from detector import engine, model | |
| video_path = r"c:\Users\Rajesh s\Downloads\KARPAGAM HACKATHON\test_traffic_video.mp4" | |
| if not os.path.exists(video_path): | |
| print("Video not found!") | |
| sys.exit(1) | |
| cap = cv2.VideoCapture(video_path) | |
| success, frame = cap.read() | |
| if not success: | |
| print("Could not read frame!") | |
| sys.exit(1) | |
| frame = cv2.resize(frame, (800, 600)) | |
| results = model.track(frame, persist=True, verbose=False, classes=[2, 3, 5, 7])[0] | |
| # Draw ALL detected cars in BLUE | |
| if results.boxes: | |
| for box in results.boxes: | |
| x1, y1, x2, y2 = map(int, box.xyxy[0]) | |
| cv2.rectangle(frame, (x1, y1), (x2, y2), (255, 255, 0), 2) | |
| cv2.putText(frame, "CAR", (x1, y1-5), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 0), 1) | |
| # Draw ALL calibrated slots in GREEN | |
| for i, slot in enumerate(engine.cached_slots or []): | |
| y1, x1, y2, x2 = slot | |
| cv2.rectangle(frame, (x1, y1), (x2, y2), (0, 255, 0), 1) | |
| cv2.putText(frame, f"Slot {i+1}", (x1, y1+15), cv2.FONT_HERSHEY_SIMPLEX, 0.4, (0, 255, 0), 1) | |
| output_path = r"c:\Users\Rajesh s\Downloads\KARPAGAM HACKATHON\debug_alignment.jpg" | |
| cv2.imwrite(output_path, frame) | |
| print(f"Debug image saved at: {output_path}") | |
| print("Please check this image to see if the Green boxes (slots) align with the Blue boxes (cars).") | |
| cap.release() | |