-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdraw.py
More file actions
24 lines (18 loc) · 732 Bytes
/
draw.py
File metadata and controls
24 lines (18 loc) · 732 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import numpy as np
import cv2 as cv
def drawRectangle(frame, aa, bb, color=(0, 255, 0)):
"""
Draw rectangle borders from aa and bb points (ie topLeft and bottomRight)
:param frame: frame to draw
:param aa: top left corner
:param bb: bottpm right corner
"""
pts = np.array([[aa[1], aa[0]],
[bb[1], aa[0]],
[bb[1], bb[0]],
[aa[1], bb[0]]], dtype=np.int32)
cv.polylines(frame, [pts], True, color)
def drawUserRectangle(frame, topLeft, bottomRight):
drawRectangle(frame, topLeft, bottomRight, color=(255, 0, 0))
def drawTracking(frame, resultTracking):
drawRectangle(frame, resultTracking.aa, resultTracking.bb, color=(0, 255, 0))