I am working on a code to save an image. Instead of saving image cv2.imwrite function is returning false. I have reproduced the problem in the below code:
Uni_ID = 123
cam=cv2.VideoCapture(0)
rett, img = cam.read()
now = datetime.now()
dtString = now.strftime('%d-%m-%Y')
timeString = now.strftime('%H:%M:%S')
path = 'IMG'
name = path + '/' + dtString
# print(name)
if not os.path.exists(name):
os.makedirs(name)
imgName = name + '/'+ str(Uni_ID) + '_' + timeString + '.jpg'
print(imgName)
cv2.imwrite(imgName, img)
Instead of saving image, the cv2.imwrite function on the last line is returning false. The output of the code is :
IMG/03-09-2020/123_17:59:58.jpg
False
/or-, just change thenow.strftime('%H-%M-%S')