Пример #1
0
    def openCam(self):
        '''open a camera with different way  
        '''

        if self.nbcam == "choose":  # create menu widget with all camera present

            self.nbcam = 'camDefault'
            try:
                import guppyCam
                self.itemsGuppy = guppyCam.camAvailable()
                # print(self.itemsGuppy)
                self.lenGuppy = len(self.itemsGuppy)

            except:
                print('No allied vision camera connected')
                self.itemsGuppy = []
                self.lenGuppy = 0
                pass
            try:
                import baslerCam
                self.itemsBasler = baslerCam.camAvailable()
                self.lenBasler = len(self.itemsBasler)

            except:
                print('No Basler camera connected')
                self.itemsBasler = []
                self.lenBasler = 0
                pass

            try:
                import ImgSourceCamCallBack
                self.itemsImgSource = ImgSourceCamCallBack.camAvailable()
                self.lenImgSource = len(self.itemsImgSource)

            except:
                print('No ImagingSource camera connected')
                self.itemsImgSource = []
                self.lenImgSource = 0
                pass

            try:
                import pixelinkCam
                self.itemsPixelink = pixelinkCam.PIXELINK.camAvailable()
                self.lenImgPixelink = len(self.itemsPixelink)

            except:
                print('No pixelink camera connected')
                self.itemsPixelink = []
                self.lenPixelink = 0
                pass

            items = self.itemsGuppy + list(
                self.itemsBasler) + self.itemsImgSource + self.itemsPixelink

            item, ok = QInputDialog.getItem(
                self,
                "Select a camera",
                "List of avaible camera",
                items,
                0,
                False,
                flags=QtCore.Qt.WindowStaysOnTopHint)

            if ok and item:

                indexItem = items.index(item)

                if indexItem < self.lenGuppy:
                    indexItem = indexItem
                    self.cameraType = "guppy"
                    self.camID = guppyCam.getCamID(indexItem)

                    self.CAM = guppyCam.GUPPY(cam=self.nbcam, conf=self.conf)
                    self.CAM.openCamByID(self.camID)
                    self.isConnected = self.CAM.isConnected
                    self.ccdName = self.camID
                elif indexItem >= self.lenGuppy and indexItem < self.lenBasler + self.lenGuppy:
                    indexItem = indexItem - self.lenGuppy
                    self.cameraType = "basler"
                    self.camID = baslerCam.getCamID(indexItem)
                    self.CAM = baslerCam.BASLER(cam=self.nbcam,
                                                conf=self.conf,
                                                **self.kwds)
                    self.CAM.openCamByID(self.camID)
                    self.isConnected = self.CAM.isConnected
                    self.ccdName = self.camID

                elif indexItem >= self.lenBasler + self.lenGuppy and indexItem < self.lenBasler + self.lenGuppy + self.lenImgSource:
                    indexItem = indexItem - self.lenGuppy - self.lenBasler
                    self.cameraType = "imgSource"
                    self.camID = ImgSourceCamCallBack.getCamID(indexItem)
                    self.camID = self.camID.decode()
                    self.CAM = ImgSourceCamCallBack.IMGSOURCE(cam=self.nbcam,
                                                              conf=self.conf,
                                                              **self.kwds)
                    self.CAM.openCamByID(self.camID)
                    self.isConnected = self.CAM.isConnected
                    self.ccdName = self.camID

                elif indexItem >= self.lenBasler + self.lenGuppy + self.lenImgSource and indexItem < self.lenBasler + self.lenGuppy + self.lenImgSource + self.lenPixelink:
                    indexItem = indexItem - self.lenGuppy - self.lenBasler - self.lenImgSource
                    self.cameraType = "pixelink"
                    self.camID = pixelinkCam.getCamID(indexItem)

                    self.CAM = pixelinkCam.PIXELINK(cam=self.nbcam,
                                                    conf=self.conf,
                                                    **self.kwds)
                    self.CAM.openCamByID(self.camID)
                    self.isConnected = self.CAM.isConnected
                    self.ccdName = self.camID

                else:
                    self.isconnected = False
                    print('No camera choosen')
                    self.ccdName = "no camera"
                    self.nbcam = 'camDefault'
            else:
                self.isconnected = False
                print('No camera choosen')
                self.ccdName = "no camera"
                self.cameraType = ""
                self.camID = ""
                self.nbcam = 'camDefault'

        elif self.nbcam == None:
            self.isconnected = False
            print('No camera')
            self.ccdName = "no camera"
            self.cameraType = ""
            self.camID = ""
            self.nbcam = 'camDefault'

        elif self.nbcam == "firstGuppy":  # open the first guppy cam in the list
            self.nbcam = 'camDefault'
            self.cameraType = "guppy"
            self.ccdName = 'First guppy Cam'
            import guppyCam
            self.CAM = guppyCam.GUPPY(cam=self.nbcam, conf=self.conf)
            self.CAM.openFirstCam()
            self.isConnected = self.CAM.isConnected

        elif self.nbcam == "firstBasler":  # open the first basler cam in the list
            self.ccdName = 'First basler Cam'
            self.nbcam = 'camDefault'
            self.cameraType = "basler"
            import baslerCam
            self.CAM = baslerCam.BASLER(cam=self.nbcam,
                                        conf=self.conf,
                                        **self.kwds)
            self.CAM.openFirstCam()
            self.isConnected = self.CAM.isConnected

        elif self.nbcam == "firstImgSource":  # open the first imgSource cam in the list
            self.ccdName = 'First ImSource Cam'
            self.nbcam = 'camDefault'
            self.cameraType = "imgSource"
            import ImgSourceCamCallBack
            self.CAM = ImgSourceCamCallBack.IMGSOURCE(cam=self.nbcam,
                                                      conf=self.conf,
                                                      **self.kwds)
            self.CAM.openFirstCam()
            self.isConnected = self.CAM.isConnected

        elif self.nbcam == "firstPixelink":  # open the first pixelink cam in the list
            self.ccdName = 'First Pixelink Cam'
            self.nbcam = 'camDefault'
            self.cameraType = "pixelink"
            import pixelinkCam
            self.CAM = pixelinkCam.PIXELINK(cam=self.nbcam,
                                            conf=self.conf,
                                            **self.kwds)
            self.CAM.openFirstCam()
            self.isConnected = self.CAM.isConnected

        elif self.nbcam == 'menu':  # Qdialog with a menu with all the camera name present in the inifile
            self.groupsName = []
            self.groups = self.conf.childGroups()
            for groups in self.groups:
                self.groupsName.append(self.conf.value(groups + "/nameCDD"))
            item, ok = QInputDialog.getItem(
                self,
                "Select a camera",
                "List of avaible camera",
                self.groupsName,
                0,
                False,
                flags=QtCore.Qt.WindowStaysOnTopHint)
            if ok and item:
                indexItem = self.groupsName.index(item)
                self.nbcam = self.groups[indexItem]
                self.openID()

        else:  #open the camera by ID : nbcam return ID of the ini file
            try:
                self.openID()
            except:
                self.isConnected = False
Пример #2
0
    def __init__(self):
        
        
        super(NEWCAM, self).__init__()
        
        try :
            import alliedCam
            self.itemsGuppy=alliedCam.camAvailable()
            # print(self.itemsGuppy)
            self.lenGuppy=len(self.itemsGuppy)
            
        except:
            print('No allied vision camera connected')
            self.itemsGuppy=[]
            self.lenGuppy=0
            pass
        try :
            import baslerCam
            self.itemsBasler=baslerCam.camAvailable()
            self.lenBasler=len(self.itemsBasler)
            
        except:
            print('No Basler camera connected')
            self.itemsBasler=[]
            self.lenBasler=0
            pass 
        
        try :
            import ImgSourceCamCallBack
            self.itemsImgSource=ImgSourceCamCallBack.camAvailable()
            self.lenImgSource=len(self.itemsImgSource)
            
        except:
            print('No ImagingSource camera connected')
            self.itemsImgSource=[]
            self.lenImgSource=0
            pass 
        
        try :
            import pixelinkCam
            self.itemsPixelink=pixelinkCam.PIXELINK.camAvailable()
            self.lenImgPixelink=len(self.itemsPixelink)
            
        except:
            print('No pixelink camera connected')
            self.itemsPixelink=[]
            self.lenPixelink=0
            pass 
        
        items=self.itemsGuppy+list(self.itemsBasler)+self.itemsImgSource+self.itemsPixelink
        
        item, ok = QInputDialog.getItem(self, "Select a camera","List of avaible camera", items, 0, False,flags=QtCore.Qt.WindowStaysOnTopHint)
        
        if ok and item:
            
            indexItem = items.index(item)
        
            if indexItem<self.lenGuppy:
                indexItem=indexItem
                self.cameraType="allied"
                self.camID=alliedCam.getCamID(indexItem)
                self.isConnected=True
            elif indexItem>=self.lenGuppy  and indexItem<self.lenBasler+self.lenGuppy:
                indexItem=indexItem-self.lenGuppy
                self.cameraType="basler"
                self.camID=baslerCam.getCamID(indexItem)
               
                self.isConnected=True
                
                
            elif indexItem>=self.lenBasler+self.lenGuppy  and indexItem<self.lenBasler+self.lenGuppy+self.lenImgSource:
                indexItem=indexItem-self.lenGuppy-self.lenBasler
                self.cameraType="imgSource"
                self.camID=ImgSourceCamCallBack.getCamID(indexItem)
                self.camID=self.camID.decode()
                
                self.isConnected=True
                
                
            elif indexItem>=self.lenBasler+self.lenGuppy+ self.lenImgSource and indexItem<self.lenBasler+self.lenGuppy+self.lenImgSource+self.lenPixelink:
                indexItem=indexItem-self.lenGuppy-self.lenBasler-self.lenImgSource
                self.cameraType="pixelink"
                self.camID=pixelinkCam.getCamID(indexItem)
                
                self.isConnected=True

            
            else:
                 self.isconnected=False
                 print('No camera choosen')
                 self.ccdName="no camera"
                 self.nbcam='camDefault'
        else :
            self.isconnected=False
            print('No camera choosen')
            self.ccdName="no camera"
            self.cameraType=""
            self.camID=""
            self.nbcam='camDefault'
            
            
        if self.isConnected==True:
            item, ok = QInputDialog.getText(self, "Chose a name","Name ?: ",flags=QtCore.Qt.WindowStaysOnTopHint)
            p = pathlib.Path(__file__)
            self.nbcam=item
            self.confpath=str(p.parent / 'confCamera.ini') # ini file with global path
        
            self.conf=QtCore.QSettings(self.confpath, QtCore.QSettings.IniFormat) # ini file 
        
           
            self.conf.setValue(self.nbcam+"/LineTrigger","InputLines")
            self.conf.setValue(self.nbcam+"/bgPath","C:/Users/loa/Dropbox (LOA)/Programmes Python/acquisitionPrinceton/data")
            self.conf.setValue(self.nbcam+"/bloqKeyboard","true")
            self.conf.setValue(self.nbcam+"/camId",self.camID)
            self.conf.setValue(self.nbcam+"/camType",self.cameraType)
            self.conf.setValue(self.nbcam+"/gain",float(0))
            self.conf.setValue(self.nbcam+"/lastFichier"," ")
            self.conf.setValue(self.nbcam+"/loqKeyboard","false")

            self.conf.setValue(self.nbcam+"/nameBg","bg")
            
            self.conf.setValue(self.nbcam+"/nameCDD",self.nbcam)
            
            self.conf.setValue(self.nbcam+"/nameFile","Tir")
            self.conf.setValue(self.nbcam+"/pathAutoSave"," ")
                               
            self.conf.setValue(self.nbcam+"/pathBg","")



            self.conf.setValue(self.nbcam+"/rotation",0)
            self.conf.setValue(self.nbcam+"/rx",50)
            self.conf.setValue(self.nbcam+"/ry",50)
            self.conf.setValue(self.nbcam+"/shutter",10)
            self.conf.setValue(self.nbcam+"/stepX",1)
            self.conf.setValue(self.nbcam+"/stepY",1)
            self.conf.setValue(self.nbcam+"/tirNumber",1)
            self.conf.setValue(self.nbcam+"/xc",1)
            self.conf.setValue(self.nbcam+"/yc",2)
            
            
            self.conf.setValue(self.nbcam+"/r1x",10)
            self.conf.setValue(self.nbcam+"/r1y",11)
            self.conf.setValue(self.nbcam+"/r2x",20)
            self.conf.setValue(self.nbcam+"/r2y",20)
            
            self.conf.setValue(self.nbcam+"/xec",10)
            
            self.conf.setValue(self.nbcam+"/yec",10)
            self.conf.sync()