Ejemplo n.º 1
0
    def __init__(self, pitch, color, our_side, video_port=0, comm_port='/dev/ttyUSB0', comms=1):
        """
        Entry point for the SDP system.

        Params:
            [int] video_port                port number for the camera
            [string] comm_port              port number for the arduino
            [int] pitch                     0 - main pitch, 1 - secondary pitch
            [string] our_side               the side we're on - 'left' or 'right'
            *[int] port                     The camera port to take the feed from
            *[Robot_Controller] attacker    Robot controller object - Attacker Robot has a RED
                                            power wire
            *[Robot_Controller] defender    Robot controller object - Defender Robot has a YELLOW
                                            power wire
        """
        assert pitch in [0, 1]
        assert color in ['yellow', 'blue']
        assert our_side in ['left', 'right']

        self.pitch = pitch

        # Set up the Arduino communications
        self.arduino = Arduino(comm_port, 115200, 1, comms)

        # Set up camera for frames
        self.camera = Camera(port=video_port, pitch=self.pitch)
        frame = self.camera.get_frame()
        center_point = self.camera.get_adjusted_center(frame)

        # Set up vision
        self.calibration = tools.get_colors(pitch)
        self.vision = Vision(
            pitch=pitch, color=color, our_side=our_side,
            frame_shape=frame.shape, frame_center=center_point,
            calibration=self.calibration)

        # Set up postprocessing for vision
        self.postprocessing = Postprocessing()

        # Set up main planner
        self.planner = Planner(our_side=our_side, pitch_num=self.pitch)

        # Set up GUI
        self.GUI = GUI(calibration=self.calibration, arduino=self.arduino, pitch=self.pitch)

        self.color = color
        self.side = our_side

        self.preprocessing = Preprocessing()

        self.attacker = Attacker_Controller()
        self.defender = Defender_Controller()
Ejemplo n.º 2
0
b.show(frame)
"""

scalibration = tools.get_colors(0)
#  print scalibration

vision = _Vision(pitch=0,
                 color='blue',
                 our_side='left',
                 frame_shape=frame.shape,
                 frame_center=cam.get_adjusted_center(frame),
                 calibration=scalibration)

# Set up postprocessing for oldvision

postprocessing = Postprocessing()

GUI = GUI(calibration=scalibration, pitch=0)

preprocessing = Preprocessing()

frame = cam.get_frame()
pre_options = preprocessing.options
# Apply preprocessing methods toggled in the UI
preprocessed = preprocessing.run(frame, pre_options)
frame = preprocessed['frame']
if 'background_sub' in preprocessed:
    cv2.imshow('bg sub', preprocessed['background_sub'])
    cv2.waitKey()

height, width, channels = frame.shape
Ejemplo n.º 3
0
                    metavar='Parameter Set Name',
                    type=str,
                    help='Name of parameter set')

args = parser.parse_args()
batch_name = args.batch_name
param_set_name = args.param_set_name

# load config module
config_module = importlib.import_module('postprocessing.pp_config_' +
                                        param_set_name)
Config = config_module.Config

# create Config and Postprocessing
config = Config(batch_name)
post = Postprocessing(config)
submission = Submission(config)

path_to_test_preds = config.POST_PREDICTIONS_IN_DIR
path_to_test_imgs = config.TEST_IMAGES_IN_DIR
out_dir = config.OUTPUT_DIR
if not os.path.exists(out_dir):
    os.makedirs(out_dir)


# aux function
def get_id_from_filename(file_name):
    int_list = list(filter(str.isdigit, f))
    result = ''
    for el in int_list:
        result += str(el)