-
Notifications
You must be signed in to change notification settings - Fork 9
/
test_library.py
71 lines (52 loc) · 1.67 KB
/
test_library.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
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
71
from EasyROI import EasyROI
import cv2
from pprint import pprint
if __name__=='__main__':
video_path = 'input/overpass.mp4'
# Initialize cam
cap = cv2.VideoCapture(video_path)
assert cap.isOpened(), 'Cannot capture source'
ret, frame = cap.read()
roi_helper = EasyROI(verbose=True)
# DRAW RECTANGULAR ROI
rect_roi = roi_helper.draw_rectangle(frame, 3)
print("Rectangle Example:")
pprint(rect_roi)
frame_temp = roi_helper.visualize_roi(frame, rect_roi)
cv2.imshow("frame", frame_temp)
key = cv2.waitKey(0)
if key & 0xFF == ord('q'):
cv2.destroyAllWindows()
# DRAW LINE ROI
line_roi = roi_helper.draw_line(frame, 3)
print("Line Example:")
pprint(line_roi)
frame_temp = roi_helper.visualize_roi(frame, line_roi)
cv2.imshow("frame", frame_temp)
key = cv2.waitKey(0)
if key & 0xFF == ord('q'):
cv2.destroyAllWindows()
# DRAW CIRCLE ROI
circle_roi = roi_helper.draw_circle(frame, 3)
print("Circle Example:")
pprint(circle_roi)
frame_temp = roi_helper.visualize_roi(frame, circle_roi)
cv2.imshow("frame", frame_temp)
key = cv2.waitKey(0)
if key & 0xFF == ord('q'):
cv2.destroyAllWindows()
# DRAW POLYGON ROI
polygon_roi = roi_helper.draw_polygon(frame, 3)
print("Polygon Example:")
pprint(polygon_roi)
frame_temp = roi_helper.visualize_roi(frame, polygon_roi)
cv2.imshow("frame", frame_temp)
key = cv2.waitKey(0)
if key & 0xFF == ord('q'):
cv2.destroyAllWindows()
# # '''
# cv2.imshow("frame", frame)
# key = cv2.waitKey(0)
# if key & 0xFF == ord('q'):
# cv2.destroyAllWindows()
# # '''