Saving image problem(cp949 problem)

filename = 'C:\Users\Jun\Desktop\영상\캡쳐.png'
cv2.imwrite(filename, cv2.cvtColor(currentFrame, cv2.COLOR_RGB2BGR))

I wanted to capture image during video… but is didn’t work.
I found it why it didn’t work, because window’s encoding is Korean filename cp949, but pytcharm’s encoding is UTF-8…

This is solution that I found.

filename = 'C:\Users\Jun\Desktop\영상\캡쳐.png'
img = cv2.cvtColor(currentFrame, cv2.COLOR_RGB2BGR)
result, encoded_img = cv2.imencode('.png', img)
     if result:
          with open(filename, mode='w+b') as f:
               encoded_img.tofile(f)

Is it okay, to use this solution? (encode image and decode image??)
Doesn’t it make image damaged? Does it make it video slowly? Does it make memory capacity used lot?

if there any solution better than this (like only change filename only encode…) would you teach me ??

Thank you for your help!! :>

Obviously, you can test it, whether it damages the image and how it compares to the original image.

And you can of course time it and see how it petforms.

The extra memory used is practically nothing, considering what else you have loaded and what you do with the image.