Avoid inplace modifying`imgs` in `LoadStreams` (#5850)
Browse filesWhen OpenCV retrieving image fail, original code would modify source images **inplace**, which may result in plotting bounding boxes on a black image. That is, before inference, source image `im0s[i]` is OK, but after inference before `Process predictions`, `im0s[i]` may have been changed.
- utils/datasets.py +1 -1
utils/datasets.py
CHANGED
@@ -337,7 +337,7 @@ class LoadStreams:
|
|
337 |
self.imgs[i] = im
|
338 |
else:
|
339 |
LOGGER.warning('WARNING: Video stream unresponsive, please check your IP camera connection.')
|
340 |
-
self.imgs[i]
|
341 |
cap.open(stream) # re-open stream if signal was lost
|
342 |
time.sleep(1 / self.fps[i]) # wait time
|
343 |
|
|
|
337 |
self.imgs[i] = im
|
338 |
else:
|
339 |
LOGGER.warning('WARNING: Video stream unresponsive, please check your IP camera connection.')
|
340 |
+
self.imgs[i] = np.zeros_like(self.imgs[i])
|
341 |
cap.open(stream) # re-open stream if signal was lost
|
342 |
time.sleep(1 / self.fps[i]) # wait time
|
343 |
|