我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用cv2.FONT_HERSHEY_SCRIPT_SIMPLEX。
def annotate_landmarks(img, landmarks, font_scale = 0.4): """ Annotate face landmarks on image. Args: img: a cv2 image object. landmarks: numpy matrix consisted of points. Return: annotated image. """ img = img.copy() for idx, point in enumerate(landmarks): pos = (point[0, 0], point[0, 1]) cv2.putText(img, str(idx), pos, fontFace=cv2.FONT_HERSHEY_SCRIPT_SIMPLEX, fontScale=font_scale, color=(0, 0, 255)) cv2.circle(img, pos, 3, color=(0, 255, 255)) return img
def annotate_landmarks(im, landmarks): im = im.copy() for idx, point in enumerate(landmarks): pos = (point[0, 0], point[0, 1]) cv2.putText(im, str(idx), pos, fontFace=cv2.FONT_HERSHEY_SCRIPT_SIMPLEX, fontScale=0.4, color=(0, 0, 255)) cv2.circle(im, pos, 3, color=(0, 255, 255)) return im
def annotate_landmarks(im, landmarks): im = im.copy() for landmark in landmarks: for idx, point in enumerate(landmark): pos = (point[0, 0], point[0, 1]) cv2.putText(im, str(idx), pos, fontFace=cv2.FONT_HERSHEY_SCRIPT_SIMPLEX, fontScale=0.4, color=(0, 0, 255)) cv2.circle(im, pos, 3, color=(0, 255, 255)) return im
def annotate_landmarks(im, landmarks): im = im.copy() for idx, point in enumerate(landmarks): pos = (point[0], point[1]) # put text for the enumeration cv2.putText(im, str(idx), pos, fontFace=cv2.FONT_HERSHEY_SCRIPT_SIMPLEX, fontScale=0.4, color=(0, 0, 255)) # plot a circle on the image to note the point cv2.circle(im, pos, 3, color=(0, 255, 255)) return im
def drawColoredTriangles(img, triangleList, disp): #sort the triangle list by distance from the top left corner in order to get a gradient effect when drawing triangles triangleList=sorted(triangleList, cmp=triDistanceSort) h, w, c = img.shape #get bounding rectangle points of image r = (0, 0, w, h) #iterate through and draw all triangles in the list for idx, t in enumerate(triangleList): #grab individual vertex points pt1 = [t[0], t[1]] pt2 = [t[2], t[3]] pt3 = [t[4], t[5]] #select a position for displaying the enumerated triangle value pos = (t[2], t[3]) #create the triangle triangle = np.array([pt1, pt2, pt3], np.int32) #select a color in HSV!! (manipulate idx for cool color gradients) color = np.uint8([[[idx, 100, 200]]]) #color = np.uint8([[[0, 0, idx]]]) #convert color to BGR bgr_color = cv2.cvtColor(color, cv2.COLOR_HSV2BGR) color = (int(bgr_color[(0, 0, 0)]), int(bgr_color[(0, 0, 1)]), int(bgr_color[(0, 0, 2)])) #draw the triangle if it is within the image bounds if rect_contains(r, pt1) and rect_contains(r, pt2) and rect_contains(r, pt3): cv2.fillPoly(img, [triangle], color) # if display triangle number was selected, display the number.. this helps with triangle manipulation later if(disp==1): cv2.putText(img, str(idx), pos, fontFace=cv2.FONT_HERSHEY_SCRIPT_SIMPLEX, fontScale=0.3, color=(0, 0, 0)) ######################################## example script ########################################