def set_feature(self, nodemap, node_name, feature_name, value): ''' method to get any stt from a camera nodemap: the node map of a collection of camera properties, e.g. TLDEVICE node_name: Name of the specific node, such as DeviceInformation feature_name: Name of the specific feature, such as ModelNumber ''' try: node = PySpin.CCategoryPtr(nodemap.GetNode(node_name)) if PySpin.IsAvailable(node) and PySpin.IsReadable(node): features = node.GetFeatures() for feature in features: node_feature = PySpin.CValuePtr(feature) if node_feature.GetName() == feature_name: node_feature.FromString(value) else: print('No feature named %s found' % feature_name) return None except PySpin.SpinnakerException as ex: print("Error: %s" % ex)
def print_device_info(nodemap, cam_num): """ This function prints the device information of the camera from the transport layer; please see NodeMapInfo example for more in-depth comments on printing device information from the nodemap. :param nodemap: Transport layer device nodemap. :param cam_num: Camera number. :type nodemap: INodeMap :type cam_num: int :returns: True if successful, False otherwise. :rtype: bool """ print('Printing device information for camera %d... \n' % cam_num) try: result = True node_device_information = PySpin.CCategoryPtr( nodemap.GetNode('DeviceInformation')) if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable( node_device_information): features = node_device_information.GetFeatures() for feature in features: node_feature = PySpin.CValuePtr(feature) print( '%s: %s' % (node_feature.GetName(), node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) else: print('Device control information not available.') print() except PySpin.SpinnakerException as ex: print('Error: %s' % ex) return False return result
def get_model(self): """ This function get the model name """ try: node_device_information = PySpin.CCategoryPtr( self.nodemap_tldevice.GetNode("DeviceInformation")) if PySpin.IsAvailable( node_device_information) and PySpin.IsReadable( node_device_information): features = node_device_information.GetFeatures() for feature in features: node_feature = PySpin.CValuePtr(feature) if node_feature.GetName() == 'DeviceModelName': return node_feature.ToString() else: return 'N/A' except PySpin.SpinnakerException as ex: print("Error: %s" % ex) return 'N/A'