-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
43 lines (29 loc) · 809 Bytes
/
main.py
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
import cv2
import torch
import numpy as np
from tracker import *
model = torch.hub.load('ultralytics/yolov5', 'yolov5s', pretrained=True)
cap=cv2.VideoCapture('highway.mp4')
count=0
tracker = Tracker()
def POINTS(event, x, y, flags, param):
if event == cv2.EVENT_MOUSEMOVE :
colorsBGR = [x, y]
print(colorsBGR)
cv2.namedWindow('FRAME')
cv2.setMouseCallback('FRAME', POINTS)
while True:
ret,frame=cap.read()
if not ret:
break
count += 1
if count % 3 != 0:
continue
frame=cv2.resize(frame,(1020,600))
results=model(frame)
results.pandas().xyxy[0]
cv2.imshow("FRAME",frame)
if cv2.waitKey(0)&0xFF==27:
break
cap.release()
cv2.destroyAllWindows()