def main(): ''' Example usage''' initBPC() # initCam() # To save time, you can also set the gain and shutter directly initCam(False, False, -5, 0.05) print("Starting optimisation") X, Y = optimise() input( "Optimisation complete. Press enter to close the camera connection and BPC203 connection. This will not reset the positions" ) cam.close() bpc.closePort() input("Press enter to reset the system or terminate the programme now.") close()
d_polynomial, d_result) print("time of addition: ", time.time() - start) #copying device addition result memory to host h_result = d_result.copy_to_host() print("time of copying memory: ", time.time() - start) h_result = (np.reshape(h_result, (sizeX, sizeY))) % 1 print("time of wrapping: ", time.time() - start) cv2.moveWindow("SLM", 2140, -25) cv2.imshow("SLM", h_result) cv2.waitKey(1) print("time of display: ", time.time() - start) display = camera.capture() print("time of image acquisition:", time.time() - start) #np.save('D:\\zernike\\captured_images_for_training\\image_' + str(batch) + '_' + str(i) + '.npy', display) #cv2.imshow('display',display) #cv2.waitKey(1) gpu_time = time.time() - gpu_start print("Time elapsed for GPU is " + str(gpu_time) + "seconds") cv2.destroyAllWindows() camera.close() #cpu_start = time.time() #for i in range(0, 200): # h_result = np.zeros((sizeX * sizeY)) # for j in range(0, num_of_terms): # cpuadd(j, sizeY, sizeX, weights[i, j], h_polynomial, h_result) # #cpu_time = time.time() - cpu_start #print("Time elapsed for CPU is "+str(cpu_time)+"seconds")
def tearDown(): camera.close();
station_parameters = database.get_station_parameters(verbose=True) hourly_parameters = database.get_hourly_parameters(verbose=True) hardware_parameters = database.get_hardware_parameters(verbose=True) sys.exit() if flash_camera_settings: station_parameters = database.get_station_parameters(verbose=False) station_parameters['stationName'] = utils.get_station_name() if station_parameters['cameraType'].lower() == 'rpi': parameters = database.get_rpi_camera_parameters(station_parameters, verbose=True) elif station_parameters['cameraType'].lower() == 'gphoto2': parameters = database.get_gphoto2_camera_parameters(station_parameters, verbose=True) camera_parameters = camera.initialize(station_parameters, verbose=True) camera.close(station_parameters, camera_parameters, verbose=True) sys.exit() while True: # Pick up the latest parameters from the databases if verbose: msg = 'Picking up the latest parameters from the ' msg += 'configuration databases ...' msg += '\n' sys.stdout.write(msg) sys.stdout.flush() station_parameters = database.get_station_parameters() if station_parameters: station_parameters_pickup_successful = True previous_station_parameters = station_parameters
def initialize(station_parameters, verbose=False): if station_parameters['cameraType'].lower() == 'rpi': # Raspberry Pi camera parameters = \ camera.initialize_rpi_camera(station_parameters, verbose=verbose) elif station_parameters['cameraType'].lower() == 'gphoto2': # gPhoto2 camera parameters = \ camera.initialize_gphoto2_camera(station_parameters, verbose=verbose) else: msg = '*** ERROR *** Specified camera type not supported: ' msg += '{0}'.format(station_parameters['cameraType']) msg += '\n' sys.stderr.write(msg) sys.stderr.flush() sys.exit() return parameters if __name__ == '__main__': import camera station_parameters = {} station_parameters['cameraType'] = 'rpi' camera_parameters = camera.initialize(station_parameters, verbose=True) camera.close(station_parameters, camera_parameters)
def close(): """ This function terminates all connections and resets the system. To preserve the position of the controller, use bpc.closePort()""" bpc.close() cam.close()
# Example script to automatically set the shutter such that the brightest pixel is just below saturation import camera as cam cam.init() cam.autoAdjustShutter() # Finally cam.capture() cam.close()