I'm writing an script for cropping png images and I get the result, but I also ran into the error "TypeError: 'NoneType' object is not subscriptable"
import os
import cv2
path = "/content/image/"
dest_path = "/content/cropped/"
for f in os.listdir(path):
image = cv2.imread(os.path.join(path, f))
imgcropped = image[150:400, 250:600]
cv2.imwrite(os.path.join(dest_path, f), imgcropped)
Here is my error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-49-ea6eac11778b> in <module>
7 for f in os.listdir(path):
8 image = cv2.imread(os.path.join(path, f))
----> 9 imgcropped = image[150:400, 250:600]
10 cv2.imwrite(os.path.join(dest_path, f), imgcropped)
TypeError: 'NoneType' object is not subscriptable