def data_gen(*args): fret = llt.get_actual_profile(hLLT, profile_buffer, len(profile_buffer), llt.TProfileConfig.PARTIAL_PROFILE, ct.byref(lost_profiles)) if fret != len(profile_buffer): print("Error get profile buffer data: " + str(ret)) fret = llt.convert_part_profile_2_values(profile_buffer, len(profile_buffer), ct.byref(partial_profile_struct), scanner_type, 0, null_ptr_short, null_ptr_short, null_ptr_short, x_p, z_p, null_ptr_int, null_ptr_int) if fret & llt.CONVERT_X is 0 or fret & llt.CONVERT_Z is 0: raise ValueError("Error converting data: " + str(ret)) for i in range(16): timestamp[i] = profile_buffer[resolution * data_width - 16 + i] llt.timestamp_2_time_and_count(timestamp, ct.byref(shutter_opened), ct.byref(shutter_closed), ct.byref(profile_count), null_ptr_short) # Adjust ROI to area with circle x_roi = x[(x > lower_x_limit) & (x < upper_x_limit) & (z > lower_z_limit) & (z < upper_z_limit)] z_roi = z[(x > lower_x_limit) & (x < upper_x_limit) & (z > lower_z_limit) & (z < upper_z_limit)] # Fitting xc, zc, r, residuals = leastsq_circle(x_roi, z_roi) theta_fit = np.linspace(-np.pi, np.pi, 90) print(r) print(xc, zc) # Prepare draw data x_fit = xc + r*np.cos(theta_fit) z_fit = zc + r*np.sin(theta_fit) time.sleep(0.1) # yield iterator yield x, z, xc, zc, x_fit, z_fit
raise ValueError("Error setting rearrangement: " + str(ret)) # Set container size ret = llt.set_profile_container_size(hLLT, resolution, container_size) if ret < 1: raise ValueError("Error setting profile container size: " + str(ret)) # Start transfer ret = llt.transfer_profiles(hLLT, llt.TTransferProfileType.NORMAL_CONTAINER_MODE, 1) if ret < 1: raise ValueError("Error starting transfer profiles: " + str(ret)) # Warm-up time time.sleep(2) ret = llt.get_actual_profile(hLLT, profile_buffer, len(profile_buffer), llt.TProfileConfig.CONTAINER, ct.byref(lost_profiles)) if ret != len(profile_buffer): raise ValueError("Error get profile buffer data: " + str(ret)) # Stop transmission ret = llt.transfer_profiles(hLLT, llt.TTransferProfileType.NORMAL_CONTAINER_MODE, 0) if ret < 1: raise ValueError("Error stopping transfer profiles: " + str(ret)) # Disconnect ret = llt.disconnect(hLLT) if ret < 1: raise ConnectionAbortedError("Error while disconnect: " + str(ret)) ret = llt.del_device(hLLT) if ret < 1:
# Set profile config ret = llt.set_profile_config(hLLT, llt.TProfileConfig.PROFILE) if ret < 1: raise ValueError("Error setting profile config: " + str(ret)) # Start transfer ret = llt.transfer_profiles(hLLT, llt.TTransferProfileType.NORMAL_TRANSFER, 1) if ret < 1: raise ValueError("Error starting transfer profiles: " + str(ret)) # Warm-up time time.sleep(0.2) ret = llt.get_actual_profile(hLLT, profile_buffer, len(profile_buffer), llt.TProfileConfig.PROFILE, ct.byref(lost_profiles)) if ret != len(profile_buffer): raise ValueError("Error get profile buffer data: " + str(ret)) ret = llt.convert_profile_2_values(profile_buffer, len(profile_buffer), resolution, llt.TProfileConfig.PROFILE, scanner_type, 0, null_ptr_short, intensities, null_ptr_short, x, z, null_ptr_int, null_ptr_int) if ret & llt.CONVERT_X is 0 or ret & llt.CONVERT_Z is 0 or ret & llt.CONVERT_MAXIMUM is 0: raise ValueError("Error converting data: " + str(ret)) for i in range(16): timestamp[i] = profile_buffer[resolution * 64 - 16 + i]
# Set profile config ret = llt.set_profile_config(hLLT, llt.TProfileConfig.VIDEO_IMAGE) if ret < 1: raise ValueError("Error setting profile config: " + str(ret)) # Start transfer ret = llt.transfer_profiles(hLLT, llt.TTransferProfileType.NORMAL_TRANSFER, 1) if ret < 1: raise ValueError("Error starting transfer profiles: " + str(ret)) # Warm-up time time.sleep(0.2) ret = llt.get_actual_profile(hLLT, profile_buffer, len(profile_buffer), llt.TProfileConfig.VIDEO_IMAGE, ct.byref(lost_profiles)) if ret != len(profile_buffer): raise ValueError("Error get profile buffer data: " + str(ret)) # Stop Video Stream ret = llt.transfer_profiles(hLLT, llt.TTransferProfileType.NORMAL_TRANSFER, 0) if ret < 1: raise ValueError("Error stopping transfer profiles: " + str(ret)) # Disconnect ret = llt.disconnect(hLLT) if ret < 1: raise ConnectionAbortedError("Error while disconnect: " + str(ret)) # Disconnect