Replication code (Edit: probably works with imwrite() too, after discovering root problem):
import cv2
img = cv2.imread("valve.png")
With the image valve.png (source: Wikipedia, downscaled to 320x240)

Running the code above after a hard reset works fine. Can even run it multiple times without trouble.
After a soft reset, running the code again freezes after calling cv2.imread("valve.png")