def stop(self): # clean ups --------------------------------------------------------------- # with no arguments the function will destroy all of the # created devices call is optional. If this function is not called here, # it will be called automatically when the system module is unloading. system.destroy_device() print('---------------------->>>>>>>>>> Sensor terminated ....')
def example_entry_point(): # Get connected devices --------------------------------------------------- # create_device function with no arguments would create a list of # device objects from all connected devices devices = system.create_device() if not len(devices): raise Exception(f'No device found!\n' f'Please connect a device and run the example again.') print(f'Created {len(devices)} device(s)') device = devices[0] print(f'Device used in the example:\n\t{device}') # just to have a viewable image print('Setting \'Width\' and \'Height\' Nodes value to their ' 'max values') device.nodemap['Width'].value = device.nodemap['Width'].max device.nodemap['Height'].value = device.nodemap['Height'].max with device.start_stream(1): print('Stream started') buffer = device.get_buffer() print(f'Image buffer received') # create an image writer # The writer, optionally, can take width, height, and bits per pixel # of the image(s) it would save. if these arguments are not passed # at run time, the first buffer passed to the Writer.save() # function will configure the writer to the arguments buffer's width, # height, and bits per pixel writer = Writer() # default name for the image is 'image_<count>.jpg' where count # is a pre-defined tag that gets updated every time a buffer image # is saved. More custom tags can be added using # Writer.register_tag() function writer.save(buffer) print(f'Image saved {writer.saved_images[-1]}') device.requeue_buffer(buffer) print(f'Image buffer requeued') # device.stop_stream() is automatically called at the end of the # context manger scope # clean up ---------------------------------------------------------------- # This function call with no arguments will destroy all of the # created devices. Having this call here is optional, if it is not # here it will be called automatically when the system module is unloading. system.destroy_device() print('Destroyed all created devices')
def example_entry_point(): # Create a device --------------------------------------------------------- devices = create_devices_with_tries() device = devices[0] print(f'Device used in the example:\n\t{device}') acquire_an_image_and_save_as_DoLPAoLP(device) # Clean up ---------------------------------------------------------------- # Destroy all created devices. This call is optional and will # automatically be called for any remaining devices when the system module # is unloading. system.destroy_device() print('Destroyed all created devices')
def start_stream(self, server): nodemap = self.camera.nodemap # set nodes pixel_format = PixelFormat.Coord3D_ABC16 nodemap.get_node('PixelFormat').value = pixel_format nodemap['Scan3dOperatingMode'].value = 'Distance1500mm' # number of images to accumulate nodemap['Scan3dImageAccumulation'].value = 3 # near mode : Exp250Us, Exp1000Us # nodemap['ExposureTimeSelector'].value = 'Exp1000Us' nodemap['ExposureTimeSelector'].value = 'Exp250Us' # Grab buffers --------------------------------------------- # Starting the stream allocates buffers # and begins filling them with data. while True: try: with self.camera.start_stream(10): start = time.time() buffer = self.camera.get_buffer(1) # channels_pre_pixel = int(buffer.bits_per_pixel / 16) # total_number_of_channels = buffer.width * buffer.height * channels_pre_pixel server.save_and_update_point_cloud(buffer) elapsed_time = time.time() - start print(elapsed_time) # Requeue the chunk data buffers self.camera.requeue_buffer(buffer) time.sleep(INTERVAL) except Exception as e: print(str(e)) sys.exit(1) # break system.destroy_device()
def example_entry_point(): # Create a device devices = create_devices_with_tries() device = devices[0] print(f'Device used in the example:\n\t{device}') nodemap = device.nodemap tl_stream_nodemap = device.tl_stream_nodemap # Set up nodes ----------------------------------------------------------- # Enable stream auto negotiate packet size tl_stream_nodemap['StreamAutoNegotiatePacketSize'].value = True # Enable stream packet resend tl_stream_nodemap['StreamPacketResendEnable'].value = True # Disable automatic exposure and gain before setting an exposure time. # Automatic exposure and gain controls whether they are set manually or # automatically by the device. Setting automatic exposure and gain to # 'Off' stops the device from automatically updating the exposure time # while streaming. set_exposure_auto_to_off(nodemap) #inspired by the above set_acqusition_frame_rate_enabled(nodemap, user_acquisition_rate_Hz) # nodemap['AcquisitionFrameRate'] = np.float64(user_acquisition_rate_Hz) #check all settings are below maximum ex_max = nodemap['ExposureTime'].max print( f'maximum possible exposure for this frame rate now {np.round(ex_max/1000000,6)}s' ) # If 'SequencerMode' is on, turn it off so the sequencer becomes # configurable through 'SequencerConfigurationMode'. # Put sequencer in configuration mode. # Sequencer configuration mode must be on while making changes to # the sequencer sets. set_sequencer_configuration_mode_on(nodemap) # Set up sequencer sets --------------------------------------------------- # From device.nodemap['SequencerSetSelector'].max gives the maximum # of sequencer sets can be set on the device. # Make sure the example works with all devices. # Take the smaller value to set a long exposure time of some devices # exposure_time_long = min(nodemap['ExposureTime'].max, 100000.0) # print('Set up sequencer sets') # sets_settings = [ # { # 'set_number': 0, # 'exposure_time': exposure_time_long / 40, # 'path_next_set': 1, # 'trigger_source': 'FrameStart' # }, # { # 'set_number': 1, # 'exposure_time': exposure_time_long / 20, # 'path_next_set': 2, # 'trigger_source': 'FrameStart' # }, # { # 'set_number': 2, # 'exposure_time': exposure_time_long, # 'path_next_set': 0, # Means it goes back to the set in index 0 # 'trigger_source': 'FrameStart' # } # ] exposure_time_medium = user_exposure print('Set up sequencer sets') sets_settings = [ { 'set_number': 0, 'exposure_time': min(ex_max, np.round(exposure_time_medium / user_ev_step, 3)), 'path_next_set': 1, 'trigger_source': 'FrameStart' }, { 'set_number': 1, 'exposure_time': min(ex_max, np.round(exposure_time_medium, 3)), 'path_next_set': 2, 'trigger_source': 'FrameStart' }, { 'set_number': 2, 'exposure_time': min(ex_max, np.round(exposure_time_medium * user_ev_step, 3)), 'path_next_set': 0, # Means it goes back to the set in index 0 'trigger_source': 'FrameStart' } ] for set_settings in sets_settings: set_sequencer_set(nodemap, **set_settings) # Sets the sequencer starting set to 0 print('Set stream to start from sequencer set 0') nodemap['SequencerSetStart'].value = 0 # Turn off configuration mode print('Turn \'SequencerConfigurationMode\' Off') nodemap['SequencerConfigurationMode'].value = 'Off' print(f'\t\'SequencerConfigurationMode\' is ' f'''{nodemap['SequencerConfigurationMode'].value} now''') # Turn on sequencer # When sequencer mode is on and the device is streaming it will # follow the sequencer sets according to their saved settings. print('Turn \'SequencerMode\' On') nodemap['SequencerMode'].value = 'On' print(f'''\t\'SequencerMode\' is {nodemap['SequencerMode'].value} now''') # Acquire and Save image buffers ------------------------------------------ # This function will start the stream, acquire a buffer in each set # of the sequencer using its corresponding settings, save each buffer # and then stop the stream. acquire_and_save_buffers(device) # Clean up ------------------------------------------------------------ # Turn sequencer mode off so the device is set to the original settings print('Turn \'SequencerMode\' Off') nodemap['SequencerMode'].value = 'Off' print(f'''\t\'SequencerMode\' is {nodemap['SequencerMode'].value} now''') # Destroy all created devices. This call is optional and will # automatically be called for any remaining devices when the system module # is unloading. system.destroy_device() print('Destroyed all created devices')