Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete an image in OpenCV using Python

I am trying to open and save an image in the local folder using cv2.imread and cv2.imwrite in OpenCV using Python. I want that the next time I run the code the previously saved images should be deleted. Is there any method in OpenCV which can delete an image from the specified folder. Please note that I want to delete the image, not overwrite on it.

Any kind of help will be appreciated. Thank you.

like image 836
Anuradha Avatar asked Dec 07 '22 01:12

Anuradha


1 Answers

import os
try: 
    os.remove("my.png")
except: pass
like image 67
berak Avatar answered Dec 08 '22 14:12

berak