def connect(self): print "-s-----------------" print "connect" print unicap.enumerate_devices() if not self.device_id: self.device_id = unicap.enumerate_devices()[1]['identifier'] self.device = unicap.Device( self.device_id ) print self.device.enumerate_formats() if self.filetype == 'jpg': self.filetype = 'jpeg' props = self.device.enumerate_properties() print "----", props for prop in props: print prop['identifier'], ">>", prop try: prop = self.device.get_property( 'frame rate' ) prop['value'] = 5.0 self.device.set_property( prop ) except Exception, e: print e
def connect(self): print "-----start-----------------" if not self.device_id: self.device_id = unicap.enumerate_devices()[0] print self.device_id self.device = unicap.Device( self.device_id ) if self.filetype == 'jpg': self.filetype = 'jpeg' fmts = self.device.enumerate_formats() print fmts fmt = fmts[0] fmt['size'] = fmt['max_size'] self.device.set_format( fmt ) self.device.start_capture() props = self.device.enumerate_properties() for prop in props: print prop['identifier'], ">>", prop self.setGain(10) self.setFramerate(5) self.setExposure(1.0) props = self.device.enumerate_properties() for prop in props: print prop['identifier'], ">>", prop
def __init__(self): gtk.Window.__init__(self) self.connect( 'delete-event', gtk.main_quit ) self.do_save = False vbox = gtk.VBox() self.add( vbox ) hbox = gtk.HBox() vbox.pack_start( hbox, False, True ) capture_button = gtk.ToggleButton( label = "Capture" ) hbox.pack_start( capture_button, False, False ) capture_button.connect( 'toggled', self.__on_capture_toggled ) button = gtk.Button( stock = gtk.STOCK_SAVE ) hbox.pack_start( button, False, False ) button.connect( 'clicked', self.__on_save_clicked ) prop_button = gtk.Button( label = "Properties" ) hbox.pack_start( prop_button, False, False ) self.fmt_sel = unicapgtk.VideoFormatSelection() hbox.pack_end( self.fmt_sel, False, False ) self.dev_sel = unicapgtk.DeviceSelection() self.dev_sel.rescan() self.dev_sel.connect( 'unicapgtk_device_selection_changed', self.__on_device_changed ) hbox.pack_end( self.dev_sel, False, False ) self.display = unicapgtk.VideoDisplay() self.display.connect( 'unicapgtk_video_display_predisplay', self.__on_new_frame ) self.display.set_property( "scale-to-fit", True ) vbox.pack_start( self.display, True, True ) self.property_dialog = unicapgtk.PropertyDialog() self.property_dialog.connect( 'delete-event', self.property_dialog.hide_on_delete ) prop_button.connect( 'clicked', lambda(x): self.property_dialog.present() ) self.property_dialog.hide() dev = unicap.enumerate_devices()[0] self.dev_sel.set_device( dev ) self.fmt_sel.set_device( dev ) vbox.show_all() self.set_default_size( 640, 480 ) capture_button.set_active( True )
def open(self): """ Find if a DML41AU02.AS USB camera is connected and set it up. """ devices = unicap.enumerate_devices() print devices nb_cam = len(devices) if nb_cam == 0: # No device managed by Unicap connected raise IOError("No Unicap managed device connected.") # Looking for the camera in the device list for i in range(0, nb_cam): if 'DMx' in devices[i]['identifier']: dmk = devices[i] # To implement # Open it self.device = unicap.Device(dmk) # to change # Set it up # Get a list of supported video formats self.fmts = self.device.enumerate_formats() # Set the first video format in the list at maximum resolution self.fmt = self.fmts[0] self.fmt['size'] = self.fmt['max_size'] self.device.set_format(self.fmt) # set the exposure time mode auto_exposure_mode = self.device.get_property({'identifier': 'Exposure, Auto'}) self.device.set_property({'identifier': 'Exposure, Auto', 'value': 1}) # exposure = int(self.device.get_property({'identifier': 'Exposure (Absolute)'})) self.device.set_property({'identifier': 'Exposure (Absolute)', 'value': self.default_expo_int})
elif ( o == "--numframes" ) or ( o == "-n" ): numframes = int( a ) elif ( o == "--type" ) or ( o == "-t" ): filetype = a elif ( o == "--size" ) or ( o == "-s" ): width, height = [int(x) for x in a.split('x')] vidformat['size'] = (width,height) elif ( o == "--fourcc" ) or ( o == '-c' ): vidformat['fourcc'] = a elif ( o == "--skip" ) or ( o == "-k" ): skip = int(a) elif ( o == "--memory" ) or ( o == "-m" ): memorycapture = True elif ( o == "--list" ) or ( o == "-l" ): print "Available Devices:" for dev in unicap.enumerate_devices(): print '"'+dev['identifier']+'"' sys.exit(0) if not filename: print_usage() # If no device_id was specified on the command line, use the first device if not device_id: device_id = unicap.enumerate_devices()[0]['identifier'] device = unicap.Device( device_id ) if vidformat: device.set_format( vidformat )
# # This example demonstrates how to # # - Create a device object # - Get and set video formats # - Get and set device properties # - Capture a video image # - Convert an image buffer to a different color space # import unicap # Create a device object with the first video capture device found dev = unicap.Device( unicap.enumerate_devices()[0] ) # Get a list of supported video formats fmts = dev.enumerate_formats() # Set the first video format in the list at maximum resolution fmt = fmts[0] fmt['size'] = fmt['max_size'] dev.set_format( fmt ) # Get a list of supported device properties # The properties in this list are set to their default values props = dev.enumerate_properties() # Get the current state of the first property prop = dev.get_property( props[0] )
image = Image.open(inputfilename) frameRateValue = get_user_input('Frame Rate', frameRateDefault, frameRateAllowedValues) exposureAutoValue = get_user_input('Exposure Auto', exposureAutoDefault, exposureAutoAllowedValues) exposureAbsoluteValue = get_user_input('Exposure Absolute', exposureAbsoluteDefault, exposureAbsoluteAllowedValues) gainValue = get_user_input('Gain', gainDefault, gainAllowedValues) brightnessValue = get_user_input('Brightness', brightnessDefault, brightnessAllowedValues) gammaValue = get_user_input('Gamma', gammaDefault, gammaAllowedValues) * 100 dev = unicap.Device(unicap.enumerate_devices()[0]) fmts = dev.enumerate_formats() props = dev.enumerate_properties() prop = dev.get_property('frame rate') prop['value'] = float(frameRateValue) print float(frameRateValue) dev.set_property(prop) prop = dev.get_property('Exposure, Auto') prop['value'] = int(exposureAutoValue) #default should be 1 dev.set_property(prop) prop = dev.get_property('Exposure (Absolute)')