当前位置: 首页>>代码示例>>Python>>正文


Python cv2.FONT_HERSHEY_DUPLEX属性代码示例

本文整理汇总了Python中cv2.FONT_HERSHEY_DUPLEX属性的典型用法代码示例。如果您正苦于以下问题:Python cv2.FONT_HERSHEY_DUPLEX属性的具体用法?Python cv2.FONT_HERSHEY_DUPLEX怎么用?Python cv2.FONT_HERSHEY_DUPLEX使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在cv2的用法示例。


在下文中一共展示了cv2.FONT_HERSHEY_DUPLEX属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: bboxes_draw_on_img

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import FONT_HERSHEY_DUPLEX [as 别名]
def bboxes_draw_on_img(img, classes, scores, bboxes, thickness=2):
    shape = img.shape
    for i in range(bboxes.shape[0]):
        label = labels[classes[i] - 1]
        if label not in accept_labels:
            continue
        bbox = bboxes[i]
        #color = colors_tableau[classes[i] - 1]
        p1 = (int(bbox[0] * shape[0]), int(bbox[1] * shape[1]))
        p2 = (int(bbox[2] * shape[0]), int(bbox[3] * shape[1]))
        cv2.rectangle(img, p1[::-1], p2[::-1], (0,0,255), 1)
        s = '%s' % (label)
        p1 = (p1[0]-5, p1[1])
        cv2.putText(img, s, p1[::-1], cv2.FONT_HERSHEY_DUPLEX, 0.7, (0,0,255), 1)


# =========================================================================== #
# Matplotlib show...
# =========================================================================== # 
开发者ID:huseinzol05,项目名称:Gather-Deployment,代码行数:21,代码来源:visualization.py

示例2: loop

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import FONT_HERSHEY_DUPLEX [as 别名]
def loop(self):
        font = cv2.FONT_HERSHEY_DUPLEX
        pos = (10,30)
        font_scale = 0.9
        font_color = (0, 0, 0)
        line_type = 1

        while True:
            start_time = datetime.datetime.now()
            ret, image = self.capture.read()

            #image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) #/ 255.0

            cv2.imshow('image', image)
            if self.videowriter is not None:
                if self.videowriter.isOpened():
                    self.videowriter.write(image)
            if cv2.waitKey(1) & 0xFF == ord('q'):
                break

        # When everything done, release the capture
        self.capture.release()
        cv2.destroyAllWindows() 
开发者ID:PacktPublishing,项目名称:Advanced-Deep-Learning-with-Keras,代码行数:25,代码来源:video.py

示例3: draw_bbox

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import FONT_HERSHEY_DUPLEX [as 别名]
def draw_bbox(self, img, bboxes, labels, relative=False):
        if len(labels) == 0:
            return img
        img = img.copy()
        h, w = img.shape[:2]

        if relative:
            bboxes = bboxes * [w, h, w, h]

        bboxes = bboxes.astype(np.int)
        labels = labels.astype(np.int)

        for bbox, label in zip(bboxes, labels):
            left, top, right, bot = bbox
            color = self.colors[label]
            label = self.id_to_label[label]
            cv2.rectangle(img, (left, top), (right, bot), color, 2)
            #img[max(0,top-18):min(h+1,top+2), max(0,left-2):min(left + len(label)*7+5,w+1)] = 15
            cv2.putText(img, label, (left+1, top-5), cv2.FONT_HERSHEY_DUPLEX, 0.4, color, 1, cv2.LINE_AA)

        return img 
开发者ID:uoip,项目名称:SSD-variants,代码行数:23,代码来源:pascal_voc.py

示例4: draw_bbox

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import FONT_HERSHEY_DUPLEX [as 别名]
def draw_bbox(self, img, bboxes, labels, relative=False):
        if len(labels) == 0:
            return img
        img = img.copy()
        h, w = img.shape[:2]

        if relative:
            bboxes = bboxes * [w, h, w, h]

        bboxes = bboxes.astype(np.int)
        labels = labels.astype(np.int)

        for bbox, label in zip(bboxes, labels):
            left, top, right, bot = bbox
            color = self.colors[label]
            label = self.id_to_label[label]
            cv2.rectangle(img, (left, top), (right, bot), color, 2)
            cv2.putText(img, label, (left+1, top-5), cv2.FONT_HERSHEY_DUPLEX, 
                0.4, color, 1, cv2.LINE_AA)

        return img 
开发者ID:uoip,项目名称:transforms,代码行数:23,代码来源:pascal_voc.py

示例5: _draw_annotations

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import FONT_HERSHEY_DUPLEX [as 别名]
def _draw_annotations(self, img):
        self.joints2d.set(t=self.camera.t, rt=self.camera.rt, f=self.camera.f, c=self.camera.c, k=self.camera.k)

        if self.view_bones.isChecked():
            kintree = self.model.kintree_table[:, 1:]
            for k in range(kintree.shape[1]):
                cv2.line(img, (int(self.joints2d.r[kintree[0, k], 0]), int(self.joints2d.r[kintree[0, k], 1])),
                         (int(self.joints2d.r[kintree[1, k], 0]), int(self.joints2d.r[kintree[1, k], 1])),
                         (0.98, 0.98, 0.98), 3)

        if self.view_joints.isChecked():
            for j in self.joints2d.r:
                cv2.circle(img, (int(j[0]), int(j[1])), 5, (0.38, 0.68, 0.15), -1)

        if self.view_joint_ids.isChecked():
            for k, j in enumerate(self.joints2d.r):
                cv2.putText(img, str(k), (int(j[0]), int(j[1])), cv2.FONT_HERSHEY_DUPLEX, 0.6, (0.3, 0.23, 0.9), 2)

        return img 
开发者ID:thmoa,项目名称:smpl_viewer,代码行数:21,代码来源:main_window.py

示例6: draw_extract_box

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import FONT_HERSHEY_DUPLEX [as 别名]
def draw_extract_box(self, color_id=2, thickness=1):
        """ Draw the extracted face box """
        if not self.roi:
            return
        color = self.colors[color_id]
        for idx, roi in enumerate(self.roi):
            logger.trace("Drawing Extract Box: (idx: %s, roi: %s)", idx, roi)
            top_left = [point for point in roi.squeeze()[0]]
            top_left = (top_left[0], top_left[1] - 10)
            cv2.putText(self.image,
                        str(idx),
                        top_left,
                        cv2.FONT_HERSHEY_DUPLEX,
                        1.0,
                        color,
                        thickness)
            cv2.polylines(self.image, [roi], True, color, thickness) 
开发者ID:deepfakes,项目名称:faceswap,代码行数:19,代码来源:annotate.py

示例7: bboxes_draw_on_img

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import FONT_HERSHEY_DUPLEX [as 别名]
def bboxes_draw_on_img(img, classes, scores, bboxes, colors, thickness=2):
    shape = img.shape
    for i in range(bboxes.shape[0]):
        bbox = bboxes[i]
        color = colors[classes[i]]
        # Draw bounding box...
        p1 = (int(bbox[0] * shape[0]), int(bbox[1] * shape[1]))
        p2 = (int(bbox[2] * shape[0]), int(bbox[3] * shape[1]))
        cv2.rectangle(img, p1[::-1], p2[::-1], color, thickness)
        # Draw text...
        s = '%s/%.3f' % (classes[i], scores[i])
        p1 = (p1[0]-5, p1[1])
        cv2.putText(img, s, p1[::-1], cv2.FONT_HERSHEY_DUPLEX, 0.4, color, 1)


# =========================================================================== #
# Matplotlib show...
# =========================================================================== # 
开发者ID:LevinJ,项目名称:SSD_tensorflow_VOC,代码行数:20,代码来源:visualization.py

示例8: get_frame

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import FONT_HERSHEY_DUPLEX [as 别名]
def get_frame(self):
        success, image = self.video.read()
        image_gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
        faces_rects = haar_cascade_face.detectMultiScale(image_gray, scaleFactor=1.2, minNeighbors=5);
        # Let us print the no. of faces found
        #print('Faces found: ', len(faces_rects))

        for (x, y, w, h) in faces_rects:
            cv2.rectangle(image, (x, y), (x + w, y + h), (0, 255, 0), 2)

        if len(faces_rects) > 0:
            
            cv2.putText(img = image, text = 'Faces found:' + str(len(faces_rects)), org=(50,50), fontFace=cv2.FONT_HERSHEY_DUPLEX, fontScale=1, color=(0, 0, 255))
        # We are using Motion JPEG, but OpenCV defaults to capture raw images,
        # so we must encode it into JPEG in order to correctly display the
        # video stream.
        ret, jpeg = cv2.imencode('.jpg', image)
        return jpeg.tobytes() 
开发者ID:shiyazt,项目名称:Live-USB-Webcam-Streaming-on-ThingsBoard-IoT-Platform,代码行数:20,代码来源:camera.py

示例9: draw_bbox

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import FONT_HERSHEY_DUPLEX [as 别名]
def draw_bbox(img, bbox, shape, label, color=[255, 0, 0], thickness=2):
    p1 = (int(bbox[0] * shape[0]), int(bbox[1] * shape[1]))
    p2 = (int(bbox[2] * shape[0]), int(bbox[3] * shape[1]))
    cv2.rectangle(img, p1[::-1], p2[::-1], color, thickness)
    p1 = (p1[0]+15, p1[1])
    cv2.putText(img, str(label), p1[::-1], cv2.FONT_HERSHEY_DUPLEX, 0.5, color, 1)

    return img

# def bboxes_draw_on_img(img, classes, scores, bboxes, thickness=2):
#     shape = img.shape
#     for i in range(bboxes.shape[0]):
#         bbox = bboxes[i]
#         color = colors_tableau[classes[i]]
#         # Draw bounding box...
#         p1 = (int(bbox[0] * shape[0]), int(bbox[1] * shape[1]))
#         p2 = (int(bbox[2] * shape[0]), int(bbox[3] * shape[1]))
#         cv2.rectangle(img, p1[::-1], p2[::-1], color, thickness)
#         # Draw text...
#         s = '%s|%.3f' % (label2name_table[classes[i]], scores[i])
#         p1 = (p1[0]-6, p1[1])
#         cv2.putText(img, s, p1[::-1], cv2.FONT_HERSHEY_DUPLEX, 0.5, color, 1)

#     return img 
开发者ID:HiKapok,项目名称:X-Detector,代码行数:26,代码来源:draw_toolbox.py

示例10: saveImage

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import FONT_HERSHEY_DUPLEX [as 别名]
def saveImage(img, gesture):

    # Define image path and filename
    folder = utils.imgPathsRaw[gesture]
    name = utils.gestureTxt[gesture] + '-' + time.strftime('%Y%m%d-%H%M%S')
    extension = '.png'

    print("Saving " + name + extension + " - Accept ([y]/n)?")

    # Write gesture name to image and show for a few seconds
    imgTxt = img.copy()
    font = cv2.FONT_HERSHEY_DUPLEX
    cv2.putText(imgTxt, utils.gestureTxt[gesture], (10,25), font, 1, (0, 0, 255))
    cv2.imshow('Camera', imgTxt)
    key = cv2.waitKey(2000)
    if key not in [110, 120]:
        # Key is not x or n. Save image
        cv2.imwrite(folder + name + extension, img)
        print("Saved ({}x{})".format(img.shape[1], img.shape[0]))
    else:
        print("Save cancelled") 
开发者ID:DrGFreeman,项目名称:rps-cv,代码行数:23,代码来源:capture.py

示例11: addFrameRateText

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import FONT_HERSHEY_DUPLEX [as 别名]
def addFrameRateText(self, img, pos=(0, 25), bgr=(0,255,0), samples=21):
        """Returns an image with the frame rate added as text on the image
        passed as argument. The framerate is calculated based on the time
        between calls to this method and averaged over a number of samples.
        img: image to which the framerate is to be added,
        bgr: tuple defining the blue, green and red values of the text color,
        samples: number of samples used for averaging.
        """
        # Calculate framerate and reset timer
        self.frameRateFilter.addDataPoint(1 / self.frameRateTimer.getElapsed())
        self.frameRateTimer.reset()
        # Get averaged framerate as a string
        frString = '{}fps'.format(str(int(round(self.frameRateFilter.getMean(),
                                                0))))
        # Add text to image
        cv2.putText(img, frString, pos, cv2.FONT_HERSHEY_DUPLEX, 1, bgr) 
开发者ID:DrGFreeman,项目名称:rps-cv,代码行数:18,代码来源:camera.py

示例12: face_process

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import FONT_HERSHEY_DUPLEX [as 别名]
def face_process():
    myprint("face process start",time.time())
    # Find all the faces and face encodings in the current frame of video
    # face_locations = face_recognition.face_locations(rgb_small_frame, model="cnn")
    myprint('face_locations start', time.time())
    face_locations = face_recognition.face_locations(rgb_small_frame, model="hog")
    myprint('face_locations end', time.time())
    myprint('face_encodings start', time.time())
    face_encodings = face_recognition.face_encodings(rgb_small_frame, face_locations)
    myprint('face_encodings end', time.time())
    face_names = []
    for face_encoding in face_encodings:
        # optimize start 采用KNN 排名*权重, 在类别上进行叠加,然后排序取出top1
        name, dis = vote_class(face_encoding)
        # optimize end 采用 排名*权重, 在类别上进行叠加,然后排序取出top1
        face_names.append(name)  # 将人脸数据

    # Display the results
    for (top, right, bottom, left), name in zip(face_locations, face_names):
        # Scale back up face locations since the frame we detected in was scaled to 1/4 size
        top *= 4
        right *= 4
        bottom *= 4
        left *= 4
        myprint('putText start', time.time())
        # Draw a box around the face
        cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2)
        # Draw a label with a name below the face
        cv2.rectangle(frame, (left, bottom - 35), (right, bottom), (0, 0, 255), cv2.FILLED)
        font = cv2.FONT_HERSHEY_DUPLEX
        cv2.putText(frame, name, (left + 6, bottom - 6), font, 1.0, (255, 255, 255), 1)
        myprint("putText end " + name, time.time())
        # say hello and save record to file
        myprint('process_face_records start', time.time())
        process_face_records(name)
        myprint('process_face_records end', time.time())

    # Display the resulting image
    cv2.imshow('Video', frame)
    myprint("face process end", time.time()) 
开发者ID:matiji66,项目名称:face-attendance-machine,代码行数:42,代码来源:facerec_from_webcam_faster.py

示例13: draw_FPS

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import FONT_HERSHEY_DUPLEX [as 别名]
def draw_FPS(frame, FPS):
    cv2.putText(frame, "FPS: %d"%FPS, (40, 40), cv2.FONT_HERSHEY_DUPLEX, 1, (0, 255, 0), 1) 
开发者ID:kwea123,项目名称:VTuber_Unity,代码行数:4,代码来源:visualization.py

示例14: find_gesture

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import FONT_HERSHEY_DUPLEX [as 别名]
def find_gesture(frame_in,finger,palm):
    frame_gesture.set_palm(palm[0],palm[1])
    frame_gesture.set_finger_pos(finger)
    frame_gesture.calc_angles()
    gesture_found=DecideGesture(frame_gesture,GestureDictionary)
    gesture_text="GESTURE:"+str(gesture_found)
    cv2.putText(frame_in,gesture_text,(int(0.56*frame_in.shape[1]),int(0.97*frame_in.shape[0])),cv2.FONT_HERSHEY_DUPLEX,1,(0,255,255),1,8)
    return frame_in,gesture_found

# 7. Remove bg from image 
开发者ID:mahaveerverma,项目名称:hand-gesture-recognition-opencv,代码行数:12,代码来源:HandRecognition.py

示例15: write_text

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import FONT_HERSHEY_DUPLEX [as 别名]
def write_text(image, text):
    h, w = image.shape[0], image.shape[1]
    font = cv2.FONT_HERSHEY_DUPLEX
    cv2.putText(image,text, (w//5, h-40), font, 1,(255,255,255),2,cv2.LINE_AA) 
开发者ID:guille0,项目名称:hazymaze,代码行数:6,代码来源:image_parsing.py


注:本文中的cv2.FONT_HERSHEY_DUPLEX属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。