[Solved] Win10 and Linux address reading format is different (CV2. Error: opencv (4.2.0)/Io/opencv…)

img = cv2.resize(img, (512, 1024))
cv2.error: OpenCV(4.2.0) /io/opencv/modules/imgproc/src/resize. cpp:4045 : error: (-215:Assertion failed) ! ssize.empty() in function ‘resize’

The code can run normally in win10, but the above error is reported in Linux. My analysis is due to the different address reading formats between win10 and Linux.

img   = cv2.imread(item['path'])
#item['path']:'./data/TuSimple/LaneDetection\clips/0313-2/42120/20.jpg'

There is a ‘\’ in the address of item [‘path ‘], which results in an error in Linux operation
so change the’ \ ‘in the address of item [‘path’] to ‘/’

item['path']=item['path'].replace('\\', '/')#Add this code
img   = cv2.imread(item['path'])


Read More: