Skip to content

Commit

Permalink
Avoid inplace modifyingimgs in LoadStreams (ultralytics#5850)
Browse files Browse the repository at this point in the history
When 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.
  • Loading branch information
passerbythesun authored Dec 2, 2021
1 parent 284a14d commit 526aaed
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion utils/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def update(self, i, cap, stream):
self.imgs[i] = im
else:
LOGGER.warning('WARNING: Video stream unresponsive, please check your IP camera connection.')
self.imgs[i] *= 0
self.imgs[i] = np.zeros_like(self.imgs[i])
cap.open(stream) # re-open stream if signal was lost
time.sleep(1 / self.fps[i]) # wait time

Expand Down

0 comments on commit 526aaed

Please sign in to comment.