def Setup_Camera(verbose, fakeCam=False): ''' Instantiates a camera and returns it, along with the corresponding "dev". This gives access to "deeper" camera functions, such as the device temperature. If fakeCam = True, it returns the fake camera object, a software equivalent, with (presumably realistic) noise, etc. ''' Aravis.update_device_list() # Scan for live cameras if fakeCam: Aravis.enable_interface("Fake") # using arv-fake-gv-camera-0.8 cam = Aravis.Camera.new(None) # Instantiate cam if verbose: print("Instantiated FakeCam") else: # Note: We expect only one "real" camera !! try: cam = Aravis.Camera.new(Aravis.get_device_id(0)) # Instantiate cam if verbose: print("Instantiated real camera") except: print("ERROR - No camera found") # Ooops!! return None, None, None # Send back nothing dev = cam.get_device() # Allows access to "deeper" features return cam, dev # Send back camera, device
def list_available_cameras(self): """ Gather serial numbers of online Aravis/Genicam devices. :return: a list of serial numbers (as strings). This list may be empty if no cameras are online/switched on. For cameras explicitly addressed by IP, the serial numbers have the format sn@ip, with an @ between number and address. :rtype: list .. todo:: optionally implement a specific filter for Blackfly's if Basler cameras should not be listed. """ # Start with (pessimistic) initially empty set of online devices serialNums = [] addrs = [] # Broadcast ethernet/bus for recognized cameras. # Warning/todo: this gathers also cameras that are not of the Blackfly class, # and in conjunction with the SDSS may also recognize the Basler cameras.. Aravis.update_device_list() Ndev = Aravis.get_n_devices() # print(str(Ndev) + " cameras online") # get_device_id returns a string of type, SN, MAC etc for i in range(Ndev): cam = Aravis.Camera.new(Aravis.get_device_id(i)) uid = cam.get_string("DeviceSerialNumber") serialNums.append(uid) addrs.append('') # Try to ping cameras explicitly proposed with ctor. for ip in self.ips_nonlocal: try: cam = Aravis.Camera.new(ip) uid = cam.get_string("DeviceSerialNumber") # If is this was already in the scan: discard, else add if uid not in serialNums: serialNums.append(uid) addrs.append('@' + ip) except: # apparently no such camera at this address.... pass # we zip the two lists to the format 'serialnumber{@ip}' ids = [] for cam in range(len(serialNums)): ids.append(serialNums[cam] + addrs[cam]) return ids
def get_device_ids(): Aravis.update_device_list() n = Aravis.get_n_devices() return [Aravis.get_device_id(i) for i in range(0, n)]
print ("-----") gi.require_version('Aravis', '0.8') from gi.repository import Aravis Aravis.update_device_list() if fakeCam: Aravis.enable_interface("Fake") # using arv-fake-gv-camera-0.8 cam = Aravis.Camera.new(None) # Instantiate cam print ("Instantiated cam with arv-fake-gv-camera-0.8") else: # Note: We expect only one "real"camera try: cam = Aravis.Camera.new(Aravis.get_device_id(0)) # Instantiate cam print ("Instantiated cam with FLIR") except: print("No camera found") exit() printStatus(cam) #--- Execute the reset print("Issuing DeviceReset Command") print("") dev = cam.get_device() # Allows access to "deeper" features dev.execute_command ('DeviceReset') # Do the reset
def get_device_ids(): n = Aravis.get_n_devices() l = [Aravis.get_device_id(i) for i in range(0, n)] return l
def get_device_ids(): Aravis.update_device_list() n = Aravis.get_n_devices() return [Aravis.get_device_id(i) for i in range(0, n)]
def arg_restrictions(): Aravis.update_device_list() n_cams = Aravis.get_n_devices() ids = [Aravis.get_device_id(i) for i in range(n_cams)] return {"id": ids}
async def _connect_internal(self, **kwargs): """Connect to a camera and upload basic binning and ROI parameters. :param kwargs: recognizes the key uid with integer value, the serial number If the key uid is absent, tries to attach to the first camera. This is a subdictionary of 'cameras' in practise. """ # print(self.name) # search for an optional uid key in the arguments try: uid = kwargs['uid'] except: uid = None # reverse lookup of the uid in the list of known cameras cs = BlackflyCameraSystem(BlackflyCamera) slist = cs.list_available_cameras() if uid is None: # uid was not specified: grab the first device that is found # print("no uid provided, attaching to first camera") idx = 0 else: # print("searching " + uid + " in " + str(slist) ) idx = -1 for id in slist: # remove the optional ip address of the id slistuid = id.split("@")[0] if slistuid == uid: idx = slist.index(id) # not found if idx < 0: raise CameraConnectionError("SN " + uid + " not connected") cam = None try: if "@" in slist[idx]: # if the camera was not on local network use the address part cam = Aravis.Camera.new(slist[idx].split("@")[1]) else: # otherwise the index is the same as the search order... cam = Aravis.Camera.new(Aravis.get_device_id(idx)) except: raise CameraConnectionError(" not connected") # search for an optional gain key in the arguments # todo: one could interpret gain=0 here as to call set_gain_auto(ARV_AUTO_ON) try: gain = kwargs['gain'] if gain > 0.0: # todo: it might make sense to squeeze this into the minimum # and maximum range of the camera's gain if outside that range. self.device.set_gain_auto(0) cam.set_gain(gain) except Exception as ex: # print("failed to set gain " + str(ex)) pass # see arvenums.h for the list of pixel formats. This is MONO_16 here, always cam.set_pixel_format(0x01100007) # search for an optional x and y binning factor try: var = kwargs['binning'] cam.set_binning(var[0], var[1]) except Exception as ex: # print("failed to set binning " + str(ex)) # horizontal and vertical binning set to 1 cam.set_binning(1, 1) # scan the general list of genicam featured values # of the four native types for typp, arvLst in kwargs.items(): if arvLst is not None: if typp == 'bool': for genkey, genval in arvLst.items(): try: cam.set_boolean(genkey, int(genval)) except: # probably a typo in the yaml file... todo: log this # print("failed for " + str(genkey)+str(genval)) pass elif typp == 'int': for genkey, genval in arvLst.items(): try: cam.set_integer(genkey, genval) except: # probably a typo in the yaml file... todo: log this # print("failed for " + str(genkey)+str(genval)) pass elif typp == 'float': for genkey, genval in arvLst.items(): try: cam.set_float(genkey, genval) except: # probably a typo in the yaml file... todo: log this # print("failed for " + str(genkey)+str(genval)) pass elif typp == 'string': for genkey, genval in arvLst.items(): try: cam.set_string(genkey, genval) except: # probably a typo in the yaml file... todo: log this # print("failed for " + str(genkey)+str(genval)) pass dev = cam.get_device() # Take full frames by default (maximizing probability of LVM guide camera # to find guide stars in the field) roiBounds = [-1, -1] try: roiBounds[0] = dev.get_integer_feature_value("WidthMax") roiBounds[1] = dev.get_integer_feature_value("HeightMax") # print(" ROI " + str(roiBounds[0]) + " x " + str(roiBounds[1]) ) cam.set_region(0, 0, roiBounds[0], roiBounds[1]) except Exception as ex: # print("failed to set ROI " + str(ex)) pass self.device = cam self.regionBounds = roiBounds
def getcameraids(): Aravis.update_device_list() n_cams = Aravis.get_n_devices() print("%d cameras found" % n_cams) ids = [] for i in range(n_cams): dev_id = Aravis.get_device_id(i) print("Found: %s" % dev_id) ids.append(dev_id) return ids