-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplotting.py
More file actions
25 lines (23 loc) · 740 Bytes
/
plotting.py
File metadata and controls
25 lines (23 loc) · 740 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
25
import numpy as np
import matplotlib.pyplot as plt
import cv2
def plot_face_bb(p, bb, scale=True, path=True, plot=True):
if path:
im = cv2.imread(p)
else:
im = cv2.cvtColor(p, cv2.COLOR_RGB2BGR)
if scale:
h, w, _ = im.shape
cv2.rectangle(im, (int(bb[0] * h), int(bb[1] * w)),
(int(bb[2] * h), int(bb[3] * w)),
(255, 255, 0), thickness=4)
# print bb * np.asarray([h, w, h, w])
else:
cv2.rectangle(im, (int(bb[0]), int(bb[1])), (int(bb[2]), int(bb[3])),
(255, 255, 0), thickness=4)
print "no"
if plot:
plt.figure()
plt.imshow(im[:, :, ::-1])
else:
return im[:, :, ::-1]