Beispiel #1
0
def load_camera_settings():
	global image_height, image_width

        c_params = CameraParams(lens=4.0, xresolution=0, yresolution=0)
        if os.path.exists(config_file):
            c_params.load(config_file)
	    image_height = c_params.yresolution
	    image_width = c_params.xresolution
            print("Loaded %s" % config_file)
        else:
            print("Warning: %s not found. Using default resolution height=%i and width=%i" % (config_file,image_height,image_width))
Beispiel #2
0
def load_camera_settings():
    global image_height, image_width

    c_params = CameraParams(lens=4.0, xresolution=0, yresolution=0)
    if os.path.exists(config_file):
        c_params.load(config_file)
        image_height = c_params.yresolution
        image_width = c_params.xresolution
        print("Loaded %s" % config_file)
    else:
        print(
            "Warning: %s not found. Using default resolution height=%i and width=%i"
            % (config_file, image_height, image_width))
    def getCameraWidth(self, alt):
        '''Using the camera parameters, with the width of the
        ground strip that the camera can see from a particular altitude'''

        #use the camera parameters
        c_params = CameraParams(lens=4.0)
        # load camera params and get the width of an image on the ground
        path = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'data', 'chameleon1_arecont0.json')
        c_params.load(path)
        aov = math.degrees(2.0*math.atan((c_params.sensorwidth/1000.0)/(2.0*c_params.lens/1000.0)))
        groundWidth = 2.0*alt*math.tan(math.radians(aov/2))

        return groundWidth
Beispiel #4
0
    def getCameraWidth(self, alt):
        '''Using the camera parameters, with the width of the
        ground strip that the camera can see from a particular altitude'''

        #use the camera parameters
        c_params = CameraParams(lens=4.0)
        # load camera params and get the width of an image on the ground
        path = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..',
                            'data', 'chameleon1_arecont0.json')
        c_params.load(path)
        aov = math.degrees(2.0 * math.atan(
            (c_params.sensorwidth / 1000.0) / (2.0 * c_params.lens / 1000.0)))
        groundWidth = 2.0 * alt * math.tan(math.radians(aov / 2))

        return groundWidth
Beispiel #5
0
class camera_state(object):
    def __init__(self):
        self.running = False
        self.unload = threading.Event()
        self.unload.clear()

        self.capture_thread = None
        self.save_thread = None
        self.scan_thread1 = None
        self.scan_thread2 = None
        self.transmit_thread = None
        self.view_thread = None

        self.settings = mp_settings.MPSettings(
            [
                ("depth", int, 8),
                ("gcs_address", str, None),
                ("gcs_view_port", int, 7543),
                ("bandwidth", int, 40000),
                ("bandwidth2", int, 2000),
                ("capture_brightness", int, 150),
                ("gamma", int, 950),
                ("brightness", float, 1.0),
                ("quality", int, 75),
                ("save_pgm", int, 1),
                ("transmit", int, 1),
                ("roll_stabilised", int, 1),
                ("minscore", int, 75),
                ("minscore2", int, 500),
                ("altitude", int, None),
                ("send1", int, 1),
                ("send2", int, 1),
                ("maxqueue1", int, None),
                ("maxqueue2", int, 30),
                ("thumbsize", int, 60),
                ("packet_loss", int, 0),
                ("gcs_slave", str, None),
                ("filter_type", str, "simple"),
                ("fullres", int, 0),
            ]
        )

        self.capture_count = 0
        self.scan_count = 0
        self.error_count = 0
        self.error_msg = None
        self.region_count = 0
        self.fps = 0
        self.scan_fps = 0
        self.cam = None
        self.save_queue = Queue.Queue()
        self.scan_queue = Queue.Queue()
        self.transmit_queue = Queue.Queue()
        self.viewing = False

        self.c_params = CameraParams(lens=4.0)
        self.jpeg_size = 0
        self.xmit_queue = 0
        self.xmit_queue2 = 0
        self.efficiency = 1.0

        self.last_watch = 0
        self.frame_loss = 0
        self.boundary = None
        self.boundary_polygon = None

        self.bandwidth_used = 0
        self.rtt_estimate = 0
        self.bsocket = None
        self.bsend2 = None
        self.bsend_slave = None

        # setup directory for images
        self.camera_dir = os.path.join(os.path.dirname(mpstate.logfile_name), "camera")
        cuav_util.mkdir_p(self.camera_dir)

        self.mpos = mav_position.MavInterpolator(backlog=5000, gps_lag=0.3)
        self.joelog = cuav_joe.JoeLog(os.path.join(self.camera_dir, "joe.log"), append=mpstate.continue_mode)
        # load camera params
        path = os.path.join(
            os.path.dirname(os.path.realpath(__file__)), "..", "..", "..", "cuav", "data", "chameleon1_arecont0.json"
        )
        self.c_params.load(path)
Beispiel #6
0
class camera_state(object):
    def __init__(self):
        self.running = False
        self.unload = threading.Event()
        self.unload.clear()

        self.capture_thread = None
        self.save_thread = None
        self.scan_thread1 = None
        self.scan_thread2 = None
        self.transmit_thread = None
        self.view_thread = None

        self.settings = mp_settings.MPSettings(
            [ ('depth', int, 8),
              ('gcs_address', str, None),
              ('gcs_view_port', int, 7543),
              ('bandwidth',  int, 40000),
              ('bandwidth2', int, 2000),
              ('capture_brightness', int, 150),
              ('gamma', int, 950),
              ('brightness', float, 1.0),
              ('quality', int, 75),
              ('save_pgm', int, 1),
              ('transmit', int, 1),
              ('roll_stabilised', int, 1),
              ('minscore', int, 75),
              ('minscore2', int, 500),
              ('altitude', int, None),
              ('send1', int, 1),
              ('send2', int, 1),
              ('maxqueue1', int, None),
              ('maxqueue2', int, 30),
              ('thumbsize', int, 60),
              ('packet_loss', int, 0),             
              ('gcs_slave', str, None)  
              ]
            )

        self.capture_count = 0
        self.scan_count = 0
        self.error_count = 0
        self.error_msg = None
        self.region_count = 0
        self.fps = 0
        self.scan_fps = 0
        self.cam = None
        self.save_queue = Queue.Queue()
        self.scan_queue = Queue.Queue()
        self.transmit_queue = Queue.Queue()
        self.viewing = False
        
        self.c_params = CameraParams(lens=4.0)
        self.jpeg_size = 0
        self.xmit_queue = 0
        self.xmit_queue2 = 0
        self.efficiency = 1.0

        self.last_watch = 0
        self.frame_loss = 0
        self.boundary = None
        self.boundary_polygon = None

        self.bandwidth_used = 0
        self.rtt_estimate = 0
        self.bsocket = None
        self.bsend2 = None
        self.bsend_slave = None
        
        # setup directory for images
        self.camera_dir = os.path.join(os.path.dirname(mpstate.logfile_name),
                                      "camera")
        cuav_util.mkdir_p(self.camera_dir)

        self.mpos = mav_position.MavInterpolator(backlog=5000, gps_lag=0.3)
        self.joelog = cuav_joe.JoeLog(os.path.join(self.camera_dir, 'joe.log'), append=mpstate.continue_mode)
        # load camera params
        path = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', '..', '..',
                            'cuav', 'data', 'chameleon1_arecont0.json')
        self.c_params.load(path)