Пример #1
0
    def __init__(self):
        self.lock_ = Lock()  # create a lock for this thread
        self.alive_ = True

        # create and initialise server for this processor
        self.server_ = VisionServer(self, V_SETT.VISION_SRV_NET_OPEN,
                                    V_SETT.VISION_SRV_PORT,
                                    V_SETT.MAX_PENDING_REQS)

        # obtain frame capture device obj
        self.cam_ = Camera(0)
        self.fps_ = 0

        # flags that will tell wheter data can be trusted (accurate)
        self.trust_bal_ = self.trust_blu_ = self.trust_ylw_ = None
        # these hold robots' and ball's coordinates and direction
        self.bal_center_ = None
        self.blu_robot_center_ = None
        self.ylw_robot_center_ = None
        self.blu_dir_ = self.ylw_dir_ = None
        # these hold pitcj and goal coordinates
        self.l_goal_t_ = self.l_goal_b_ = self.r_goal_t_ = self.r_goal_b_ = None
        self.pitch_tl_ = self.pitch_bl_ = self.pitch_tr_ = self.pitch_br_ = None

        # create colour objects and set their threshold values
        self.red_color_ = ColorSpace(ColorSpace.HSV)
        self.red_color_.set_trsh_bounds((0, 80, 80), (10, 255, 255))  # pitch 2
        self.blu_color_ = ColorSpace(ColorSpace.HSV)
        self.blu_color_.set_trsh_bounds((92, 132, 199), (180, 255, 255))
        self.ylw_color_ = ColorSpace(ColorSpace.RGB)
        self.ylw_color_.set_trsh_bounds((0, 0, 0), (255, 255, 255))