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


Python Point.was_seen方法代码示例

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


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

示例1: LaserMote

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

#.........这里部分代码省略.........
            cv2.imshow('val', val)

        laser = cv2.bitwise_and(hue, val)
        laser = cv2.bitwise_and(sat, laser, laser)

        hsv = cv2.merge([hue, sat, val])

        return hsv, laser

    def display(self, laser, frame):
        """
        Finds contour and determines if it's valid laser dot or not through area threshold.
        Displays debug text and draws a circle on detected laser point.

        :param laser: image containing only laser dot (i.e image within our threshold).
        :param frame: frame to display and writing debug text on.
        :return: frame.
        """
        contours, hierarchy = cv2.findContours(
            laser, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

        found_valid_point = False
        for cnt in contours:
            area = cv2.contourArea(cnt)
            M = cv2.moments(cnt)
            # check if the contour is withing the area threshold
            if self.min_area < area < self.max_area:
                cx = int(M['m10'] / M['m00'])
                cy = int(M['m01'] / M['m00'])

                # if self.debug:
                #     print "within threshold " + str(area)

                if self.point.was_seen() \
                        :  # and self.get_distance(cx, cy) <= self.distance_threshold:

                    if self.debug:
                        print "[DEBUG] Distance between last seen point ({0},{1})" \
                              " and current point ({2},{3}) :{4}".format(str(self.point.last_seen_x),
                                                                         str(self.point.last_seen_y),
                                                                         str(cx), str(cy),
                                                                         str(self.get_distance(cx, cy)))

                    # 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)
开发者ID:seanjensengrey,项目名称:LaserMote,代码行数:69,代码来源:LaserMote.py


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