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


Python Point.set_off方法代码示例

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


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

示例1: LaserMote

# 需要导入模块: from Point import Point [as 别名]
# 或者: from Point.Point import set_off [as 别名]

#.........这里部分代码省略.........

                    # update last point locations
                    self.point.update_last_seen_position(cx, cy)
                    self.point.set_on()
                    self.point.current_object = self.is_dot_within_rois(cx, cy)

                    # cv2.drawContours(frame, cnt, -1, GREEN, 15)  # draws the contour
                    cv2.circle(frame, (cx, cy), 1, GREEN, thickness=4, lineType=8, shift=0)  # circle cnt center

                elif not self.point.was_seen():
                    # cv2.drawContours(frame, cnt, -1, BLUE, 15)  # draws the contour
                    self.point.set_on()
                    self.point.update_last_seen_position(cx, cy)
                    self.point.current_object = self.is_dot_within_rois(cx, cy)

                    if self.debug:
                        print '[DEBUG] First seen point is at: ({0},{1}).'.format(str(cx), str(cy))
                        print '[DEBUG] Updated last seen coordinates.'

                cv2.putText(
                    frame,
                    self.debug_text(cx, cy, area, found=True), LaserMote.BOTTOM_LEFT_COORD,
                    cv2.FONT_HERSHEY_SIMPLEX, 0.5, WHITE, 1)

                found_valid_point = True
                break  # only one contour

        if not found_valid_point:
            cv2.putText(frame, self.debug_text(),
                        LaserMote.BOTTOM_LEFT_COORD, cv2.FONT_HERSHEY_SIMPLEX, 0.5, WHITE, 1)

            if self.point.is_on() and self.point.was_seen():
                current_object = self.is_dot_within_rois(self.point.last_seen_x, self.point.last_seen_y)
                self.point.set_off(current_object)

        return frame

    def run(self):

        self.setup_capture()
        if self.write_to_video:
            self.setup_video()
        while True:
            # get frame
            ret, frame = self.camera.read()

            # get frame size
            # w, h = frame.shape[:2]

            # mirror the frame
            frame = cv2.flip(frame, 1)

            mask = None
            # wait for space to be clicked to capture background
            if cv2.waitKey(1) == 32:
                print 'background captured'
                self.background = frame
                # clean up noise by adding median blur
                cv2.medianBlur(self.background, 5, self.background)

                self.blacked = cv2.bitwise_and(frame, frame, mask=mask)

            if self.debug and (self.blacked is not None):
                # absDiff = cv2.absdiff(self.background, frame)
                # print absDiff
                # kernel = np.ones((1, 1), np.uint8)
开发者ID:seanjensengrey,项目名称:LaserMote,代码行数:70,代码来源:LaserMote.py


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