Return the next frame, and increment internal counter. Returns image: Next H x W image. status: True or False depending whether image was loaded.
(self)
| 173 | return grayim |
| 174 | |
| 175 | def next_frame(self): |
| 176 | """ Return the next frame, and increment internal counter. |
| 177 | Returns |
| 178 | image: Next H x W image. |
| 179 | status: True or False depending whether image was loaded. |
| 180 | """ |
| 181 | |
| 182 | if self.i == self.max_length: |
| 183 | return (None, False) |
| 184 | if self.camera: |
| 185 | |
| 186 | if self._ip_camera: |
| 187 | #Wait for first image, making sure we haven't exited |
| 188 | while self._ip_grabbed is False and self._ip_exited is False: |
| 189 | time.sleep(.001) |
| 190 | |
| 191 | ret, image = self._ip_grabbed, self._ip_image.copy() |
| 192 | if ret is False: |
| 193 | self._ip_running = False |
| 194 | else: |
| 195 | ret, image = self.cap.read() |
| 196 | if ret is False: |
| 197 | print('VideoStreamer: Cannot get image from camera') |
| 198 | return (None, False) |
| 199 | w, h = image.shape[1], image.shape[0] |
| 200 | if self.video_file: |
| 201 | self.cap.set(cv2.CAP_PROP_POS_FRAMES, self.listing[self.i]) |
| 202 | |
| 203 | w_new, h_new = process_resize(w, h, self.resize) |
| 204 | image = cv2.resize(image, (w_new, h_new), |
| 205 | interpolation=self.interp) |
| 206 | image = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY) |
| 207 | else: |
| 208 | image_file = str(self.listing[self.i]) |
| 209 | image = self.load_image(image_file) |
| 210 | self.i = self.i + 1 |
| 211 | return (image, True) |
| 212 | |
| 213 | def start_ip_camera_thread(self): |
| 214 | self._ip_thread = Thread(target=self.update_ip_camera, args=()) |
no test coverage detected