def main(): logging.basicConfig( format='%(levelname)s: %(name)s: %(message)s', level=logging.WARNING) callback_obj = gp.check_result(gp.use_python_logging()) camera = gp.check_result(gp.gp_camera_new()) gp.check_result(gp.gp_camera_init(camera)) text = gp.check_result(gp.gp_camera_get_summary(camera)) print('Summary') print('=======') print(text.text) print('Abilities') print('=========') abilities = gp.check_result(gp.gp_camera_get_abilities(camera)) print('model:', abilities.model) print('status:', abilities.status) print('port:', abilities.port) print('speed:', abilities.speed) print('operations:', abilities.operations) print('file_operations:', abilities.file_operations) print('folder_operations:', abilities.folder_operations) print('usb_vendor:', abilities.usb_vendor) print('usb_product:', abilities.usb_product) print('usb_class:', abilities.usb_class) print('usb_subclass:', abilities.usb_subclass) print('usb_protocol:', abilities.usb_protocol) print('library:', abilities.library) print('id:', abilities.id) print('device_type:', abilities.device_type) gp.check_result(gp.gp_camera_exit(camera)) return 0
def main(): logging.basicConfig(format='%(levelname)s: %(name)s: %(message)s', level=logging.WARNING) callback_obj = gp.check_result(gp.use_python_logging()) camera = gp.check_result(gp.gp_camera_new()) gp.check_result(gp.gp_camera_init(camera)) text = gp.check_result(gp.gp_camera_get_summary(camera)) print('Summary') print('=======') print(text.text) print('Abilities') print('=========') abilities = gp.check_result(gp.gp_camera_get_abilities(camera)) print('model:', abilities.model) print('status:', abilities.status) print('port:', abilities.port) print('speed:', abilities.speed) print('operations:', abilities.operations) print('file_operations:', abilities.file_operations) print('folder_operations:', abilities.folder_operations) print('usb_vendor:', abilities.usb_vendor) print('usb_product:', abilities.usb_product) print('usb_class:', abilities.usb_class) print('usb_subclass:', abilities.usb_subclass) print('usb_protocol:', abilities.usb_protocol) print('library:', abilities.library) print('id:', abilities.id) print('device_type:', abilities.device_type) gp.check_result(gp.gp_camera_exit(camera)) return 0
def test_camera(): global camera, context, config, camera_config_name, camera_config print("Testing Camera") logging.basicConfig(format='%(levelname)s: %(name)s: %(message)s', level=logging.WARNING) gp.check_result(gp.use_python_logging()) context = gp.gp_context_new() camera_list = [] for name, addr in context.camera_autodetect(): camera_list.append((name, addr)) if not camera_list: print('No camera detected') return 1 camera_list.sort(key=lambda x: x[0]) name, addr = camera_list[0] camera = gp.Camera() #camera = gp.check_result(gp.gp_camera_new()) gp.check_result(gp.gp_camera_init(camera, context)) config = gp.check_result(gp.gp_camera_get_config(camera, context)) text = gp.check_result(gp.gp_camera_get_summary(camera, context)) print('Summary') print('=======') print(text.text) print('Abilities') print('=========') abilities = gp.check_result(gp.gp_camera_get_abilities(camera)) print('model:', abilities.model) print('status:', abilities.status) print('port:', abilities.port) print('speed:', abilities.speed) print('operations:', abilities.operations) print('file_operations:', abilities.file_operations) print('folder_operations:', abilities.folder_operations) print('usb_vendor:', abilities.usb_vendor) print('usb_product:', abilities.usb_product) print('usb_class:', abilities.usb_class) print('usb_subclass:', abilities.usb_subclass) print('usb_protocol:', abilities.usb_protocol) print('library:', abilities.library) print('id:', abilities.id) print('device_type:', abilities.device_type) child_count = gp.check_result(gp.gp_widget_count_children(config)) if child_count < 1: return tabs = None for n in range(child_count): child = gp.check_result(gp.gp_widget_get_child(config, n)) camera_config.append(getConfig(child)) label = gp.check_result(gp.gp_widget_get_label(child)) camera_config_name.append(label) print('!!!!!!! CONFIG ', child, label) name = gp.check_result(gp.gp_widget_get_name(child)) gp.check_result(gp.gp_camera_exit(camera, context)) return 0
def connect(self): self.context = gp.gp_context_new() print self.context self.camera = gp.check_result(gp.gp_camera_new()) print self.camera gp.check_result(gp.gp_camera_init(self.camera, self.context)) text = gp.check_result(gp.gp_camera_get_summary(self.camera, self.context)) print('Summary') print('=======') print(text.text) print('Abilities') print('=========') abilities = gp.check_result(gp.gp_camera_get_abilities(self.camera)) print('model:', abilities.model) print('status:', abilities.status) print('port:', abilities.port) print('speed:', abilities.speed) print('operations:', abilities.operations) print('file_operations:', abilities.file_operations) print('folder_operations:', abilities.folder_operations) print('usb_vendor:', abilities.usb_vendor) print('usb_product:', abilities.usb_product) print('usb_class:', abilities.usb_class) print('usb_subclass:', abilities.usb_subclass) print('usb_protocol:', abilities.usb_protocol) print('library:', abilities.library) print('id:', abilities.id) print('device_type:', abilities.device_type) print "--------------" print abilities rospy.set_param('AROM_camera/%s/model' %(self.name), abilities.model) rospy.set_param('AROM_camera/%s/config' %(self.name), {'name': self.arg['name'], 'civil_name': self.arg['civil_name'], 'driver': self.arg['driver'], 'model': abilities.model, '#main':{ '@capture': {'type': 'button', 'msg_name': 'capture'}, '@Shutter_speed': {'type': 'select', 'msg_name': 'shutter_speed', 'value': {'0': "1/4000", '1': "1/1000", '2': "1/800"}}, '@ISO': {'type': 'select', 'msg_name': 'gain', 'value': {'0': "AUTO", '1': "100", '2': "200"}}, '@ISO': {'type': 'select', 'msg_name': 'gain', 'value': {'0': "AUTO", '1': "100", '2': "200"}} } } )
def detect_cameras(self): """ Detects the connected cameras and if the ownername matches with `LEFTNAME` or `RIGHTNAME`, it will be stored under the variable `cameras` """ _cameras = self.context.camera_autodetect() msg = [(False, "None"), (False, "None")] if len(_cameras) == 0: raise Exception("Unable to find any camera") # Stores the left and right camera ports = gp.PortInfoList() ports.load() for index, (name, addr) in enumerate(_cameras): logger.debug("Count: {}, Name: {}, Addr: {}".format( index, name, addr)) # Get the ports and search for the camera idx = ports.lookup_path(addr) try: camera = gp.Camera() camera.set_port_info(ports[idx]) camera.init(self.context) # Check if the ownername matches to given values ownername = self._get_config("ownername", camera) abilities = gp.check_result(gp.gp_camera_get_abilities(camera)) except gp.GPhoto2Error as error: logger.error(str(error)) else: if ownername == self.LEFTNAME: camera._camera_name = self.LEFTNAME camera._camera_id = CameraID.LEFT self.cameras[CameraID.LEFT] = camera msg[CameraID.LEFT] = True, str(abilities.model) logger.info("Connected: " + str(abilities.model)) elif ownername == self.RIGHTNAME: camera._camera_name = self.RIGHTNAME camera._camera_id = CameraID.RIGHT self.cameras[CameraID.RIGHT] = camera msg[CameraID.RIGHT] = True, str(abilities.model) logger.info("Connected: " + str(abilities.model)) return self.connected, msg
def main(): # use Python logging logging.basicConfig(format='%(levelname)s: %(name)s: %(message)s', level=logging.WARNING) callback_obj = gp.check_result(gp.use_python_logging()) # open camera connection camera = gp.check_result(gp.gp_camera_new()) gp.check_result(gp.gp_camera_init(camera)) # get camera details abilities = gp.check_result(gp.gp_camera_get_abilities(camera)) # get configuration tree config = gp.check_result(gp.gp_camera_get_config(camera)) # find the date/time setting config item and set it if set_datetime(config, abilities.model): # apply the changed config gp.check_result(gp.gp_camera_set_config(camera, config)) else: print('Could not set date & time') # clean up gp.check_result(gp.gp_camera_exit(camera)) return 0
def main(): # use Python logging logging.basicConfig( format='%(levelname)s: %(name)s: %(message)s', level=logging.WARNING) callback_obj = gp.check_result(gp.use_python_logging()) # open camera connection camera = gp.check_result(gp.gp_camera_new()) gp.check_result(gp.gp_camera_init(camera)) # get camera details abilities = gp.check_result(gp.gp_camera_get_abilities(camera)) # get configuration tree config = gp.check_result(gp.gp_camera_get_config(camera)) # find the date/time setting config item and set it if set_datetime(config, abilities.model): # apply the changed config gp.check_result(gp.gp_camera_set_config(camera, config)) else: print('Could not set date & time') # clean up gp.check_result(gp.gp_camera_exit(camera)) return 0