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


Python cv2.drawMarker方法代码示例

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


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

示例1: move_to

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import drawMarker [as 别名]
def move_to(self,x=u'0',y=u'0',delay=u'1s',element=u'//canvas',mark_screen=False):
        """ Moves the pointer to screen coodinate of the element

        Default element is `canvas`
        """
        action = ActionChains(self._selenium.driver)
        action.move_to_element_with_offset(self._selenium.get_webelement(element), 0, 0).perform()
        time.sleep(5)
        action.move_to_element_with_offset(self._selenium.get_webelement(element), int(x),int(y)).perform()
        time.sleep(DateTime.convert_time(delay))
        if mark_screen:
            BuiltIn().log("Marked to screen on (%d,%d)" % (x,y))
            img_file = self.capture_screenshot(extra='_move')
            img = cv2.imread(Common.get_result_path() + '/' + img_file)
            cv2.drawMarker(img, (int(x),int(y)), color=(0,255,0), markerType=cv2.MARKER_CROSS, thickness=2)
            cv2.imwrite(Common.get_result_path() + '/' + img_file,img)
        BuiltIn().log('Moved the pointer to (%d,%d)' % (x,y)) 
开发者ID:bachng2017,项目名称:RENAT,代码行数:19,代码来源:Fic.py

示例2: click_on

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import drawMarker [as 别名]
def click_on(self,point,element=u'//canvas',mark_screen=False):
        """ Click on a screen coordinate of an element

        Default element is `//cannvas`
        """
        x,y = point
        el = self._selenium.get_webelement(element)
        action = ActionChains(self._selenium.driver)
        action.move_to_element_with_offset(el,0,0).perform()
        action.move_to_element_with_offset(el,x,y).perform()
        if mark_screen:
            BuiltIn().log("Marked to screen on (%d,%d)" % (x,y))
            img_file = self.capture_screenshot(extra='_click')
            img = cv2.imread(Common.get_result_path() + '/' + img_file)
            cv2.drawMarker(img, (int(x),int(y)), color=(0,255,0), markerType=cv2.MARKER_CROSS, thickness=2)
            cv2.imwrite(Common.get_result_path() + '/' + img_file,img)
        action.click().perform()
        self.wait_until_loaded()
        BuiltIn().log("Clicked on element %s at (%d,%d)" % (element,x,y)) 
开发者ID:bachng2017,项目名称:RENAT,代码行数:21,代码来源:Fic.py

示例3: annotate

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import drawMarker [as 别名]
def annotate(self, image):
        x1, y1, x2, y2 = self.bbox
        image = cv2.rectangle(image, (x1, y1), (x2, y2), (0, 0, 255), 3)
        image = cv2.putText(image, self.activity, (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.9, (0, 0, 255), 2)
        image = cv2.drawMarker(image, self.centroid, (255, 0, 0), 0, 30, 4)
        return image 
开发者ID:smellslikeml,项目名称:ActionAI,代码行数:8,代码来源:iva.py

示例4: annotate

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import drawMarker [as 别名]
def annotate(self, tracker, image, boxes):
        '''
        Used to return image with
        person instances designated 
        by the bounding box and a 
        marker at the centroid.
        Annotated with tracker id
        and activity label
        '''
        for row in topology:
            try:
                a_idx, b_idx = row[2:]
                a_part, b_part = cfg.body_dict[int(a_idx.data.cpu().numpy())], cfg.body_dict[int(b_idx.data.cpu().numpy())]
                a_coord, b_coord = tracker.pose_dict[a_part], tracker.pose_dict[b_part]
                cv2.line(image, a_coord, b_coord, tracker.skeleton_color, 2)
            except KeyError:
                pass

        if boxes:
            try:
                x1, y1, x2, y2 = tracker.bbox
                image = cv2.rectangle(image, (x1 - self.offset, y1 - self.offset), 
                                             (x2 + self.offset, y2 + self.offset), 
                                             self.box_color, 2) 
                image = cv2.drawMarker(image, tracker.centroid, self.centroid_color, 0, 30, self.thickness) 
                cv2.putText(image, tracker.id, (x1 - self.offset, y1 - self.offset), \
                                   cv2.FONT_HERSHEY_SIMPLEX, self.fontScale, self.text_color, self.thickness) 
                cv2.putText(image, str(tracker.activity), (x1 - self.offset, y1 - self.offest), \
                                   cv2.FONT_HERSHEY_SIMPLEX, self.fontScale, self.text_color, self.thickness) 
            except:
                pass

        return image 
开发者ID:smellslikeml,项目名称:ActionAI,代码行数:35,代码来源:utils.py

示例5: draw_marker

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import drawMarker [as 别名]
def draw_marker(img, position):
    cv2.drawMarker(img, (position[1], position[0]), (0,255,0)) 
开发者ID:ymao1993,项目名称:HumanRecognition,代码行数:4,代码来源:extract_pose.py

示例6: _extract_faces

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import drawMarker [as 别名]
def _extract_faces(self, frame_set_path, frame_id, transform_set_path,
                       transform_set_id, detector, offset_percent,
                       min_confidence, debug_):
        """
        This method extracts faces from a frame.

        :param str frame_set_path:The frame set path.
        :param int frame_id: The frame ID.
        :param str transform_set_path: The transform set path.
        :param transform_set_id: The transform set ID.
        :param MTCNN detector: The detector to use to detect faces.
        :param float offset_percent:
        :param float min_confidence: The minimum confidence value required to
            accept/reject a detected face.
        :param bool debug_: True if should place markers on landmarks else
            False if should not.
        :rtype: None
        """

        frame_path = FrameFile.path(frame_set_path, frame_id, 'jpg')
        img = cv2.imread(frame_path)
        img_height, img_width = img.shape[:2]

        results = detector.detect_faces(img)
        for r in results:
            if r['confidence'] < min_confidence:
                continue

            x, y, width, height = r['box']

            adjusted_x = int(max(0, x - (0.5 * width * offset_percent)))
            adjusted_y = int(max(0, y - (0.5 * height * offset_percent)))
            t = x + width + (0.5 * width * offset_percent)
            adjusted_right_x = int(min(img_width, t))
            t = y + height + (0.5 * height * offset_percent)
            adjusted_bottom_y = int(min(img_height, t))

            metadata = {'face': {k: [v[0] - adjusted_x, v[1] - adjusted_y]
                                 for k, v in r['keypoints'].items()}}

            transform_id = TransformModel().insert(transform_set_id, frame_id,
                                                   json.dumps(metadata), 0)

            face_crop = img[adjusted_y:adjusted_bottom_y,
                            adjusted_x:adjusted_right_x]
            output_path = TransformFile.path(transform_set_path, transform_id,
                                             'jpg')

            if debug_ is True:
                for _, v in metadata['face'].items():
                    cv2.drawMarker(face_crop, tuple(v), (0, 0, 255),
                                   markerType=cv2.MARKER_DIAMOND,
                                   markerSize=15, thickness=2)

            cv2.imwrite(output_path, face_crop,
                        [cv2.IMWRITE_JPEG_QUALITY, 100])

            debug(f'Transform with ID {transform_id:08d} at {output_path} '
                  f'extracted from frame with ID {frame_id:08d} at '
                  f'{frame_path}', 4) 
开发者ID:zerofox-oss,项目名称:deepstar,代码行数:62,代码来源:mtcnn_frame_set_select_extract_plugin.py


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