def __init__(self): """ Initialize the input and reset the input description if necessary. Throw an error if this input is not available """ from qcam import QCam, QCamUtil # save our working directory cwd = os.getcwd() # attempt to load the driver QCam.LoadDriver() # load our working directory os.chdir(cwd) # try releasing it QCam.ReleaseDriver()
def get_input(self, parent): """ Display an input selection dialog if necessary and return an OpenedInput Any exceptions raised would cause an error box to pop up """ from qcam import QCam, QCamUtil cwd = os.getcwd() QCam.ReleaseDriver() QCam.LoadDriver() os.chdir(cwd) # list the cameras the camera cameraList = QCam.ListCameras() if 0 >= len(cameraList): raise Error('No cameras found.') # open the camera camera = QCam.OpenCamera(cameraList[0]) # set a default exposure, format, etc. camera.settings.exposure = 25000 camera.settings.imageFormat = 'mono16' camera.settings.Flush() # set up camera queue queue = QCamUtil.CameraQueue(camera) # create a settings widget widget = CameraSettings(camera, queue, parent.settings) widget.loadSettings() widget.updateFromCamera() # return an opened input return inputs.OpenedInput(queue, widget)
import struct import numpy if len(sys.argv) != 4: print >> sys.stderr, "Usage: %s <exposure in microseconds> <output file name format> <number of frames>" % sys.argv[ 0] sys.exit(-1) exposure_ms = int(sys.argv[1]) output_file_format = sys.argv[2] num_frames = int(sys.argv[3]) # set up the camera QCam.ReleaseDriver() QCam.LoadDriver() # open the camera cam = QCam.OpenCamera(QCam.ListCameras()[0]) # set the exposure print >> sys.stderr, "Setting exposure to %d microsecond(s)" % exposure_ms cam.settings.exposure = exposure_ms cam.settings.imageFormat = 'mono16' cam.settings.Flush() # unused code # create a camera queue queue = QCamUtil.CameraQueue(cam) # start capturing