shutil
copies file objects directly. Specifically, copy2
will copy the contents of a file directly, which can be in string, bytes, or os.PathLike form. Since you are modifying the image with opencv, and you have the numpy form, it might be easier to just call imsave
:
cv2.imwrite(os.path.join("<dst_folder>", os.path.basename("<ROOT_PATH>")), crop_img)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…