Example #1
0
    def findallcams(self):
        """Find all cameras of this vendor

        Returns
        -------
        cams : dictionary
            Dictionary of all connected cameras where the key is the unique id
            that can be used to obtain a camera handle. The value is a
            description of the camera presented to the user.

        """
        err0, ndev = self.ueyeapi.is_GetNumberOfCameras()
        self._ce(err0)
        # ndev = int(ndev)

        cams = {}
        # get a device key for each camera and then the info on the camera
        err1, caminfo = self.ueyeapi.is_GetCameraList(camnum=ndev)
        self._ce(err1)

        camnum = int(getattr(caminfo, 'dwCount'))
        log.info('Found %i UEye cameras' % int(camnum))

        caminfolist = getattr(caminfo, 'uci[1]')

        for i in range(camnum):

            serial = getattr(caminfolist[i], 'SerNo[16]')
            manufacturer = 'IDS UEye'
            product = getattr(caminfolist[i], 'Model[16]')
            cams[serial] = '%s_%s_%s' % (manufacturer, product, serial)
            log.debug('Added camera %s_%s_%s' %
                      (manufacturer, product, serial))
        return cams
Example #2
0
    def open(self, camid):
        self._camid = camid
        self._handle = self._vimba.getCamera(camid)
        self._handle.openCamera()
        log.debug('Opened AVT camera %s' % camid)

        self.set_defaults()
Example #3
0
    def findallcams(self):
        """Find all cameras of this vendor

        Returns
        -------
        cams : dictionary
            Dictionary of all connected cameras where the key is the unique id
            that can be used to obtain a camera handle. The value is a
            description of the camera presented to the user.

        """
        self._ce(vrm.VRmUsbCamUpdateDeviceKeyList())
        ndev = vrm.VRmDWORD()
        self._ce(vrm.VRmUsbCamGetDeviceKeyListSize(byref(ndev)))
        ndev = int(ndev.value)
        log.info('Found %i VRM cameras' % ndev)
        cams = {}
        # get a device key for each camera and then the info on the camera
        for nn in range(ndev):
            devkey = vrm.POINTER(vrm.VRmDeviceKey)()
            self._ce(vrm.VRmUsbCamGetDeviceKeyListEntry(nn, byref(devkey)))
            serial = devkey.contents.m_serial
            manufacturer = devkey.contents.mp_manufacturer_str.data.decode(
                'utf-8')
            product = devkey.contents.mp_product_str.data.decode('utf-8')
            cams[serial] = '%s_%s_%s' % (manufacturer, product, serial)
            log.debug('Added camera %s_%s_%s' %
                      (manufacturer, product, serial))
        return cams
Example #4
0
    def getfitdata(self):
        """Fits image and returns vcenter, hcenter, vwidth, hwidth as well as the beam angle"""

        self.fitangle()
        self.fitprofiles()

        try:
            if self._hfitparams is not None and self._vfitparams is not None and self._lfitparams is not None and self._sfitparams is not None:
                if self.fitdataisrealistic():
                    vc = (self._vfitparams[1] +
                          self._roiposy) * self._pixelsize
                    hc = (self._hfitparams[1] +
                          self._roiposx) * self._pixelsize
                    lsa = 2 * np.abs(self._lfitparams[2]) * self._pixelsize
                    ssa = 2 * np.abs(self._sfitparams[2]) * self._pixelsize

                    data = []
                    data.append(hc)
                    data.append(vc)
                    data.append(lsa)
                    data.append(ssa)
                    data.append(self._fitangle)

                    return data
                else:
                    log.warn(
                        "Unrealistic fit data was acquired. Data export was supressed."
                    )
                    return None

            else:
                return None
        except:
            log.debug("Error in getfitdata()")
            return None
Example #5
0
 def stopcontacq(self):
     if self._acquiring:
         self._handle.runFeatureCommand('AcquisitionStop')
         self._handle.flushCaptureQueue()
         self._handle.endCapture()
         self._handle.revokeAllFrames()
         self._frame_pool = []
         log.debug('stoped acquisition')
     self._acquiring = False
Example #6
0
def keyboardInterruptHandler(signal, frame):
    guiint.thread.stop()
    log.debug('Thread stopped.')
    log.debug('Going to close all cams now.')
    guiint.sensormngr.closeallcams()
    log.debug('All cams were closed.')
    log.debug('Closing all temperature sensors.')
    guiint.sensormngr.closealltemp()
    log.debug('All temperature sensors closed.')
    log.info("Program was stopped. You can now close the Browser Tab".format(
        signal))
    exit(0)
Example #7
0
 def _findconnectedcams(self):
     """Find all connected cameras and store them in _camdict"""
     self._camdict = {}
     for cam in self._cameras:
         try:
             self._camdict[cam.VENDOR] = cam.findallcams()
             log.debug('Found the following %s cameras: %s' %
                       (cam.VENDOR, self._camdict[cam.VENDOR]))
         except NameError:
             log.warning(
                 'Could not look for cameras from %s. Is the driver installed?'
                 % cam.VENDOR)
Example #8
0
    def __init__(self, queue, handle, parent):
        """Thread that gets images from the ueye camera

        """
        super(UEyeThread, self).__init__()
        self.isrunning = True
        self._timeout = 25  # in 10x ms
        self._queue = queue
        self._handle = handle
        self._parent = parent
        self.setDaemon(
            True)  # important to let the Thread exit at application close.
        log.debug('UEye thread started')
Example #9
0
 def findallcams(self):
     self._system.runFeatureCommand('GeVDiscoveryAllOnce')
     sleep(0.2)
     cams = self._vimba.getCameraIds()
     out = {}
     for cam in cams:
         c = self._vimba.getCamera(cam)
         info = c.getInfo()
         out[cam] = '{name} ({interface})'.format(
             name=info.modelName.decode(),
             interface=info.interfaceIdString.decode())
     log.debug(out)
     return out
Example #10
0
 def startcontacq(self):
     if not self._acquiring:
         # initialize a bunch of frames for later usage
         self._frame_pool = [self._handle.getFrame() for _ in range(10)]
         self._frame_funcs = {}
         for frame in self._frame_pool:
             frame.announceFrame()
             ff = partial(VimbaCamera.frame_callback, self)
             self._frame_funcs[frame] = ff
             frame.queueFrameCapture(ff)
         self._handle.startCapture()
         self._handle.runFeatureCommand('AcquisitionStart')
         self._acquiring = True
         log.debug('started acquisition')
Example #11
0
    def set_defaults(self):
        self._handle.PixelFormat = 'Mono12'
        self.dtype = np.uint16

        #self._handle.GainAuto = 'Off'
        #self._handle.ExposureAuto = 'Off'

        self._handle.AcquisitionMode = 'Continuous'
        self._handle.Height = self._handle.HeightMax
        self._handle.Width = self._handle.WidthMax
        #self._handle.AcquisitionFrameRateAbs \
        #    = self._handle.getFeatureRange('AcquisitionFrameRateAbs')[1]
        log.debug(self._handle.AcquisitionFrameRateAbs)
        self._handle.SyncOutSelector = 'SyncOut1'
        self._handle.SyncOutSource = 'Exposing'
        self._handle.TriggerSource = 'FixedRate'
        self._handle.ExposureTimeAbs = 10000
Example #12
0
    def fitprofiles(self):
        """Fit the horizontal and vertical profile, as well as the profiles along the long and short elliptical axis."""
        xx = np.arange(0, self.roiimgwidth)
        yy = np.arange(0, self.roiimgheight)
        try:
            fitres1 = opt.leastsq(
                self._gaussfitdiff,
                (self.roiimgheight / 10 * 100, self.roiimgheight / 2,
                 self.roiimgheight / 10, self.imageoffset * self.roiimgwidth),
                args=(yy, self.hroiprof))
            self._vfitparams = fitres1[0]
        except:
            log.debug("VFIT Error")
            self._vfitparams = None

        try:
            fitres2 = opt.leastsq(
                self._gaussfitdiff,
                (self.roiimgwidth / 10 * 100, self.roiimgwidth / 2,
                 self.roiimgwidth / 10, self.imageoffset * self.roiimgheight),
                args=(xx, self.vroiprof))
            self._hfitparams = fitres2[0]
        except:
            log.debug("HFIT Error")
            self._hfitparams = None

        try:
            fitres3 = opt.leastsq(
                self._gaussfitdiff,
                (self.roiimgheight / 10 * 100, self.roiimgheight / 2,
                 self.roiimgheight / 10, self.imageoffset * self.roiimgwidth),
                args=(yy, self.longroiprof))
            self._sfitparams = fitres3[0]
        except:
            log.debug("SFIT Error")
            self._sfitparams = None

        try:
            fitres4 = opt.leastsq(
                self._gaussfitdiff,
                (self.roiimgwidth / 10 * 100, self.roiimgwidth / 2,
                 self.roiimgwidth / 10, self.imageoffset * self.roiimgheight),
                args=(xx, self.shortroiprof))
            self._lfitparams = fitres4[0]
        except:
            log.debug("LFIT Error")
            self._lfitparams = None
Example #13
0
 def closeallcams(self):
     """Close all cams in self._connectedcamexp."""
     for cam in self._connectedcamexp.values():
         log.debug('Stopping the camera %s.' % cam.camstr())
         cam.stopcam()