Close stream loader and release resources.
(self)
| 126 | time.sleep(0.01) # wait until the buffer is empty |
| 127 | |
| 128 | def close(self): |
| 129 | """Close stream loader and release resources.""" |
| 130 | self.running = False # stop flag for Thread |
| 131 | for thread in self.threads: |
| 132 | if thread.is_alive(): |
| 133 | thread.join(timeout=5) # Add timeout |
| 134 | for cap in self.caps: # Iterate through the stored VideoCapture objects |
| 135 | try: |
| 136 | cap.release() # release video capture |
| 137 | except Exception as e: |
| 138 | LOGGER.warning(f'WARNING ⚠️ Could not release VideoCapture object: {e}') |
| 139 | cv2.destroyAllWindows() |
| 140 | |
| 141 | def __iter__(self): |
| 142 | """Iterates through YOLO image feed and re-opens unresponsive streams.""" |
no outgoing calls
no test coverage detected