本文整理匯總了Python中cv2.FONT_ITALIC屬性的典型用法代碼示例。如果您正苦於以下問題:Python cv2.FONT_ITALIC屬性的具體用法?Python cv2.FONT_ITALIC怎麽用?Python cv2.FONT_ITALIC使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類cv2
的用法示例。
在下文中一共展示了cv2.FONT_ITALIC屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: detect
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import FONT_ITALIC [as 別名]
def detect(imgfile):
origimg = cv2.imread(imgfile)
img = preprocess(origimg)
img = img.astype(np.float32)
img = img.transpose((2, 0, 1))
net.blobs['data'].data[...] = img
out = net.forward()
box, conf, cls = postprocess(origimg, out)
for i in range(len(box)):
p1 = (box[i][0], box[i][1])
p2 = (box[i][2], box[i][3])
cv2.rectangle(origimg, p1, p2, (0,255,0))
p3 = (max(p1[0], 15), max(p1[1], 15))
title = "%s:%.2f" % (CLASSES[int(cls[i])], conf[i])
cv2.putText(origimg, title, p3, cv2.FONT_ITALIC, 0.6, (0, 255, 0), 1)
cv2.imshow("SSD", origimg)
k = cv2.waitKey(0) & 0xff
#Exit if ESC pressed
if k == 27 : return False
return True
示例2: detect
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import FONT_ITALIC [as 別名]
def detect(imgfile):
origimg = cv2.imread(imgfile)
img = preprocess(origimg)
img = img.astype(np.float32)
img = img.transpose((2, 0, 1))
net.blobs['data'].data[...] = img
out = net.forward()
box, conf, cls = postprocess(origimg, out)
for i in range(len(box)):
p1 = (box[i][0], box[i][1])
p2 = (box[i][2], box[i][3])
cv2.rectangle(origimg, p1, p2, (0,255,0))
p3 = (max(p1[0], 15), max(p1[1], 15))
title = "%s:%.2f" % (COCO_CLASSES[int(cls[i])], conf[i])
cv2.putText(origimg, title, p3, cv2.FONT_ITALIC, 0.6, (0, 255, 0), 1)
cv2.imshow("SSD", origimg)
k = cv2.waitKey(0) & 0xff
#Exit if ESC pressed
if k == 27 : return False
return True
示例3: detect
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import FONT_ITALIC [as 別名]
def detect(imgfile):
origimg = cv2.imread(imgfile)
img = preprocess(origimg)
img = img.astype(np.float32)
img = img.transpose((2, 0, 1))
net.blobs['data'].data[...] = img
out = net.forward()
box, conf, cls = postprocess(origimg, out)
for i in range(len(box)):
p1 = (box[i][0], box[i][1])
p2 = (box[i][2], box[i][3])
cv2.rectangle(origimg, p1, p2, (0,255,0))
p3 = (max(p1[0], 15), max(p1[1], 15))
title = "%s:%.2f" % (CLASSES[int(cls[i])], conf[i])
cv2.putText(origimg, title, p3, cv2.FONT_ITALIC, 0.6, (0, 255, 0), 1)
cv2.imshow("SSD", origimg)
k = cv2.waitKey(0) & 0xff
#Exit if ESC pressed
if k == 27 : return False
return True
示例4: cv2_draw_text
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import FONT_ITALIC [as 別名]
def cv2_draw_text(img, locs, labels, colors, thickness, line_type=cv2.LINE_8):
locs = locs.astype(np.int32)
font_line_type = cv2.LINE_8
font = cv2.FONT_ITALIC
font = cv2.FONT_HERSHEY_DUPLEX
font = cv2.FONT_HERSHEY_PLAIN
font = cv2.FONT_HERSHEY_SIMPLEX
for loc, label, color in zip(locs, labels, colors):
color = list(int(c) for c in color)
cv2.putText(img, label, tuple(loc), font, 0.7, color, thickness,
font_line_type, False)
return img
示例5: cv2_draw_bbox_with_label
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import FONT_ITALIC [as 別名]
def cv2_draw_bbox_with_label(img,
bboxes,
colors,
labels=None,
label_colors=None,
thickness=1,
line_type=cv2.LINE_8,
font_line_type=cv2.LINE_8):
# assume bboxes has right format.
bboxes = bboxes.astype(np.int32)
if label_colors is None:
label_colors = colors
if labels is None:
labels = [None] * bboxes.shape[0]
font = cv2.FONT_ITALIC
font = cv2.FONT_HERSHEY_DUPLEX
font = cv2.FONT_HERSHEY_PLAIN
font = cv2.FONT_HERSHEY_SIMPLEX
for bbox, color, label, label_color in zip(bboxes, colors, labels,
label_colors):
color = tuple(int(c) for c in color)
label_color = tuple(int(c) for c in label_color)
cv2.rectangle(img, tuple(bbox[:2]), tuple(bbox[2:]), color, thickness,
line_type)
if label is not None:
cv2.putText(img, label, tuple(bbox[:2]), font, 1, label_color,
thickness, font_line_type, False)
return img
示例6: detect
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import FONT_ITALIC [as 別名]
def detect(img_path):
origimg = cv2.imread(img_path)
img = preprocess(origimg)
img = img.astype(np.float32)
img = img.transpose((2, 0, 1))
net.blobs['data'].data[...] = img
start = time.time()
out = net.forward()
use_time=time.time() - start
print("time="+str(round(use_time*1000,3))+"ms")
box, conf, cls = postprocess(origimg, out)
for i in range(len(box)):
if conf[i] > 0.3:
p1 = (box[i][0], box[i][1])
p2 = (box[i][2], box[i][3])
cv2.rectangle(origimg, p1, p2, (0,255,0))
p3 = (max(p1[0], 15), max(p1[1], 15))
title = "%s:%.2f" % (CLASSES[int(cls[i])], conf[i])
cv2.putText(origimg, title, p3, cv2.FONT_ITALIC, 0.6, (0, 255, 0), 1)
cv2.imshow("SSD", origimg)
cv2.waitKey(1) & 0xff
#Exit if ESC pressed
return True
示例7: cv2_draw_text
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import FONT_ITALIC [as 別名]
def cv2_draw_text(img, locs, labels, colors, thickness, line_type=cv2.LINE_8):
locs = locs.astype(np.int32)
font_line_type = cv2.LINE_8
font = cv2.FONT_ITALIC
font = cv2.FONT_HERSHEY_DUPLEX
font = cv2.FONT_HERSHEY_PLAIN
font = cv2.FONT_HERSHEY_SIMPLEX
for loc, label, color in zip(locs, labels, colors):
color = list(int(c) for c in color)
cv2.putText(
img, label, tuple(loc), font, 0.7, color, thickness, font_line_type, False
)
return img
示例8: plot_scene_with_estimate
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import FONT_ITALIC [as 別名]
def plot_scene_with_estimate(test_img,renderer,K_test, R_est_old, t_est_old,R_est_ref, t_est_ref, test_bb, test_score, obj_id, gts=[], bb_pred=None):
global view_idx
if bb_pred is not None:
scene_detect = test_img.copy()
for bb in bb_pred:
try:
xmin = int(bb['obj_bb'][0])
ymin = int(bb['obj_bb'][1])
xmax = int(bb['obj_bb'][0]+bb['obj_bb'][2])
ymax = int(bb['obj_bb'][1]+bb['obj_bb'][3])
if obj_id == bb['obj_id']:
cv2.rectangle(scene_detect, (xmin,ymin),(xmax,ymax), (0,255,0), 2)
cv2.putText(scene_detect, '%s: %1.3f' % (bb['obj_id'],bb['score']), (xmin, ymax+20), cv2.FONT_ITALIC, .5, (0,255,0), 2)
else:
cv2.rectangle(scene_detect, (xmin,ymin),(xmax,ymax), (0,0,255), 2)
# cv2.putText(scene_detect, '%s: %1.3f' % (bb['obj_id'],bb['score']), (xmin, ymax+20), cv2.FONT_ITALIC, .5, (0,0,255), 2)
except:
pass
#cv2.putText(scene_detect, '%s: %1.3f' % (obj_id,test_score), (xmin, ymax+20), cv2.FONT_ITALIC, .5, (0,255,0), 2)
cv2.imshow('scene_detect',scene_detect)
xmin = int(test_bb[0])
ymin = int(test_bb[1])
xmax = int(test_bb[0]+test_bb[2])
ymax = int(test_bb[1]+test_bb[3])
print 'here'
obj_in_scene, _ = renderer.render( obj_id=0, W=test_img.shape[1],H=test_img.shape[0], K=K_test.copy(), R=R_est_old, t=np.array(t_est_old),near=10,far=10000,random_light=False)
scene_view = test_img.copy()
scene_view[obj_in_scene > 0] = obj_in_scene[obj_in_scene > 0]
cv2.rectangle(scene_view, (xmin,ymin),(xmax,ymax), (0,255,0), 2)
cv2.putText(scene_view, '%s: %1.3f' % (obj_id,test_score), (xmin, ymax+20), cv2.FONT_ITALIC, .5, (0,255,0), 2)
cv2.imshow('scene_estimation',scene_view)
obj_in_scene_ref, _ = renderer.render( obj_id=0, W=test_img.shape[1],H=test_img.shape[0], K=K_test.copy(), R=R_est_ref, t=np.array(t_est_ref),near=10,far=10000,random_light=False)
scene_view_refined = test_img.copy()
g_y = np.zeros_like(obj_in_scene_ref)
g_y[:,:,1]= obj_in_scene_ref[:,:,1]
scene_view_refined[obj_in_scene_ref > 0] = g_y[obj_in_scene_ref > 0]*2./3. + scene_view_refined[obj_in_scene_ref > 0]*1./3.
# scene_view_refined[obj_in_scene_ref > 0] = obj_in_scene_ref[obj_in_scene_ref > 0]
cv2.rectangle(scene_view_refined, (xmin,ymin),(xmax,ymax), (0,255,0), 2)
cv2.putText(scene_view_refined,'%s: %1.3f' % (obj_id,test_score), (xmin, ymax+20), cv2.FONT_ITALIC, .5, (0,255,0), 2)
cv2.imshow('scene_estimation_refined',scene_view_refined)
cv2.waitKey(0)
# cv2.imwrite('/net/rmc-lx0314/home_local/sund_ma/autoencoder_ws/bosch/thr_sc2_obj7/%s.png'% view_idx,scene_view_refined)
view_idx += 1
# for gt in gts:
# if gt['obj_id'] == obj_id:
# obj_in_scene, _ = renderer.render( obj_id=0, W=test_img.shape[1],H=test_img.shape[0], K=K_test.copy(), R=gt['cam_R_m2c'], t=np.array(gt['cam_t_m2c']),near=10,far=10000,random_light=False)
# scene_view = test_img.copy()
# scene_view[obj_in_scene > 0] = obj_in_scene[obj_in_scene > 0]
# cv2.imshow('ground truth scene_estimation',scene_view)