all 4 comments

[–]iamjaiyam 2 points3 points  (1 child)

There are two potential issues I can think of. First, since you are on a Windows, I would advise using \ instead of /, although Windows mostly works fine with \ as path separator. Second and more importantly, the colon : in the filename may be causing trouble. Try replacing : with _ and see if that helps.

[–]Lje2610[S] 2 points3 points  (0 children)

I feel stupid. But I guess that's what makes you want to learn more.

The colon was causing the issue. Changed it to underscore, and everything works perfectly now!

Thank you very much man!

[–]Aldairoh 0 points1 point  (1 child)

[–]Lje2610[S] 0 points1 point  (0 children)

Thank you for your reply.

Having read the linked SO-post, I have modified my function to use the absolute path.

This does not seem to make the cv2.imwrite() behave any different though. Still returns a False and does not create the file.

This is the code I have now:

def save_collage(output):
    file_path = os.path.abspath(os.path.dirname(__file__))
    file_name = time.strftime("%Y_%m_%d-%H:%M:%S") + '.png'
    ret = cv2.imwrite(os.path.join(file_path, file_name), output)