예제 #1
0
    def __init__(self, table, camera):
        self.table = table
        self.camera = camera
        self.frames_in_flight = 120

        self.table_tracker = TableTracker(table, camera, TableReferenceFrame())
        self.rectifier = Rectifier(table, margin=0.10, camera=camera, resolution=120)

        self.background_analyzer = BackgroundAnalyzer(table, self.rectifier)
        self.team_foosmen_analyzer = TeamFoosmenAnalyzer(table, self.rectifier)
        self.ball_analyzer = BallAnalyzer(table, self.rectifier)

        self.rod_analyzer = [RodAnalyzer(table, rod, self.rectifier) for rod in table.rods]
예제 #2
0
class GameAnalyzer:

    def __init__(self, table, camera):
        self.table = table
        self.camera = camera
        self.frames_in_flight = 120

        self.table_tracker = TableTracker(table, camera, TableReferenceFrame())
        self.rectifier = Rectifier(table, margin=0.10, camera=camera, resolution=120)

        self.background_analyzer = BackgroundAnalyzer(table, self.rectifier)
        self.team_foosmen_analyzer = TeamFoosmenAnalyzer(table, self.rectifier)
        self.ball_analyzer = BallAnalyzer(table, self.rectifier)

        self.rod_analyzer = [RodAnalyzer(table, rod, self.rectifier) for rod in table.rods]

    def analyze(self, data):
        self.table_tracker.locate_table(data)
        self.table_tracker.settle_table(data)
        self.table_tracker.compute_camera_transform(data)

        self.rectifier.rectify(data.frames)

        self.background_analyzer.estimate_color(data)
        self.background_analyzer.analyze_color(data)

        for i, team in enumerate(self.table.teams):
            self.team_foosmen_analyzer.initialize_model(team, data)
            self.team_foosmen_analyzer.analyze_color(team, data)
            self.team_foosmen_analyzer.compute_visible_llr(team, data)
            self.team_foosmen_analyzer.compute_location_llr(team, data)

        for i, rod in enumerate(self.table.rods):
            analyzer = self.rod_analyzer[i]

            for j, foosman in enumerate(rod.foosmen):
                foosman_analyzer = analyzer.foosman_analyzer[j]
                foosman_analyzer.compute_shift_llr(data)

            analyzer.compute_shift_llr(data)

        self.ball_analyzer.analyze_color(data)
        self.ball_analyzer.compute_visible_llr(data)
        self.ball_analyzer.compute_location_llr(data)