Re: [問題] PyQT GUI Line CCD抓data問題

看板Python作者 (走自己的路)時間12年前 (2013/12/22 20:18), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/3 (看更多)
: : def read_frame(self): : : try: frame = self.ccd.get_frame() #self.ccd是前面initialize過的camera.py : : except: return None : : if frame is not None: : : return frame.image - np.mean(frame.dark) : : else: : : return None : 這個read_frame函式 的回傳值 : 可以是 None 或是 "有用的值" : 但是下面的函式在使用時 並沒有做判斷 : : 這個部份的live數據的讀取會是 (我是用一個100ms的counter,到時後就call下面) : : def updateposition(self): : : self.ccd.set_exposure_time(self.ui.ExpSlide.value()) #把快門設成使用者所要的 : : self.data = self.read_frame() #讀取data : : x = np.arange(len(self.data)) #取得data長度 : 讀取後就直接用了?? 是None怎麼辨?? 感謝K大, 我現在把read_frame改寫成這樣 def read_frame(self): frame = None while not frame: try: frame = self.ccd.get_frame() except: time.sleep(self.ui.ExpSlide.value()/100000) #讓他等一下 return frame is None print(frame) #從print看一下它有沒有正確抓 return frame.image-np.mean(frame.dark) 是不會抓到None了,但是因為把它寫成只要不是none就是持續的try (還是我誤解這樣寫的意思) 現在的問題是卡在exposure time長一點的時候它程式應該就是一直在while的迴圈裡 整個ui就會很卡 不過這個好像沒有辦法解決吼. 因為整個ui基本上還是同一個thread...multithread的部份對我好深奧. 感謝! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.109.214.4
文章代碼(AID): #1IjjYQes (Python)
文章代碼(AID): #1IjjYQes (Python)