| 53 | self.root.wm_protocol("WM_DELETE_WINDOW", self.onClose) |
| 54 | |
| 55 | def videoLoop(self): |
| 56 | # DISCLAIMER: |
| 57 | # I'm not a GUI developer, nor do I even pretend to be. This |
| 58 | # try/except statement is a pretty ugly hack to get around |
| 59 | # a RunTime error that throws due to threading |
| 60 | try: |
| 61 | # keep looping over frames until we are instructed to stop |
| 62 | while not self.stopEvent.is_set(): |
| 63 | # grab the frame from the video stream and resize it to |
| 64 | # have a maximum width of 300 pixels |
| 65 | self.frame = self.vs.read() |
| 66 | self.frame = imutils.resize(self.frame, width=300) |
| 67 | |
| 68 | # represents images in BGR order; however PIL |
| 69 | # represents images in RGB order, so we need to swap |
| 70 | # the channels, then convert to PIL and ImageTk format |
| 71 | image = cv2.cvtColor(self.frame, cv2.COLOR_BGR2RGB) |
| 72 | image = Image.fromarray(image) |
| 73 | image = ImageTk.PhotoImage(image) |
| 74 | |
| 75 | # if the panel is not None, we need to initialize it |
| 76 | if self.panel is None: |
| 77 | self.panel = tki.Label(image=image) |
| 78 | self.panel.image = image |
| 79 | self.panel.pack(side="left", padx=10, pady=10) |
| 80 | |
| 81 | # otherwise, simply update the panel |
| 82 | else: |
| 83 | self.panel.configure(image=image) |
| 84 | self.panel.image = image |
| 85 | |
| 86 | except RuntimeError as e: |
| 87 | print("[INFO] caught a RuntimeError") |
| 88 | |
| 89 | def takeSnapshot(self): |
| 90 | # grab the current timestamp and use it to construct the |