def updateMasking(self): boxStart = self.model.rect[0:2] boxEnd = self.model.rect[2:4] tempFrame = self.model.maskedFrame.copy() cv2.rectangle(tempFrame,boxStart,boxEnd,(0,255,0),3) tempFrame[self.model.drawnMask==cv2.GC_FGD] = (0,255,0) tempFrame[self.model.drawnMask==cv2.GC_BGD] = (0,0,255) numpyToVtkImage(tempFrame,self.model.bgImage) self.VTK_updated.emit(1)
def updateVideo(self): if (self.model.cap.isOpened()): ret, frame = self.model.cap.read() self.model.videoFrame = frame.copy() self.model.maskedFrame = frame.copy() else: frame = self.model.videoFrame.copy() font = cv2.FONT_HERSHEY_SIMPLEX cv2.putText(frame,'No Video',(20,20), font, 1,(255,255,255)) numpyToVtkImage(frame,self.model.bgImage) time.sleep(0.001*self.checkVideoRateMS) self.model.cap = cv2.VideoCapture(0) self.model.cap.set(3,self.model.imgDims[0]) self.model.cap.set(4,self.model.imgDims[1]) numpyToVtkImage(frame,self.model.bgImage) self.VTK_updated.emit(1)