Skip to content

Commit

Permalink
added disp_dets2
Browse files Browse the repository at this point in the history
  • Loading branch information
josephs-cvar committed Dec 18, 2019
1 parent a74059d commit 1edb121
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions notebooks/logo_usecase_routines.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,45 @@
data_root = '../data/Logo/logo_usecase_data'
disp_folder = assert_folder('../output/logo_usecase_data')

def disp_dets2(img,dets,save_file_path):
import matplotlib.pyplot as plt
fig = plt.figure(1)
fig.set_size_inches((1.4*8.5,1.4*11),forward=False)
plt.axis("off")
img_d = cv2.cvtColor(copy.deepcopy(img),cv2.COLOR_BGR2RGB)
w = 12
for det in dets:
bbox = det[0]
scores = det[1]
labels = det[3]
pn = det[4]

left = int(bbox[0])
top = int(bbox[1])
# right = left + int(bbox[2])
# bottom = top + int(bbox[3])
right = int(bbox[2])
bottom = int(bbox[3])
if pn=='p':
cv2.rectangle(img_d, (left, top), (right, bottom)
, (255, 0, 0), 4)
else:
cv2.rectangle(img_d, (left, top), (right, bottom)
, (0,255, 0), 4)
i = 0
for s,l in zip(scores,labels):
cv2.rectangle(img_d, (left, top - w), (left + 450, top + w +2*w*i), (255, 255, 255), cv2.FILLED)
i+=1
i = 0
for s,l in zip(scores,labels):
text = '{0} - {1:.3f} {2}'.format(l, s,id2name[l])
cv2.putText(img_d, text, (left, top+2*w*i), cv2.FONT_HERSHEY_SIMPLEX, 0.6, color=(0, 0, 0), thickness=2)
i+=1

plt.imshow(img_d)
#plt.figure(figsize=(28, 28))
fig.savefig(save_file_path)

def test_on_query_image(fs_serv,test_img_fname,score_thresh=0.1,det_engines=1,figure_factor=2.2,FontScale=2.3):
img = cv2.imread(test_img_fname, cv2.IMREAD_COLOR | cv2.IMREAD_IGNORE_ORIENTATION)

Expand Down

0 comments on commit 1edb121

Please sign in to comment.