A piece of code is shown below
image_name = 'demo'
folder_path = os.path.join("data","example",'gemini2_io')
print(folder_path)
print(os.path.join(folder_path, f"{image_name}.png"))
The code below is as follows
data\example\gemini2_io
data\example\gemini2_io\demo.png
ospath mainly plays the role of splicing, splicing two paragraphs of text to form a path name
path='C:/yyy/yyy_data/'
>>> print(os.path.join(path,'/abc'))
C:/abc
>>> print(os.path.join(path,'abc'))
C:/yyy/yyy_data/abc
If you add '/' to the right of the text, all the '/' on the left will be cleared, so be careful
The following is an example in my code to save the file where the current code is located
image_name = 'demo'
folder_path = os.path.join('./gemini2_io')
# print(folder_path)
# print(os.path.join(folder_path, f"{image_name}.png"))
cv2.imwrite(os.path.join(folder_path, f"{image_name}.png"), color_image)
np.save(os.path.join(folder_path, f"/{image_name}.npy"), depth_image)