while True:
if cv2.waitKey(10) == ord('w'):
file_path = 'log.txt'
sys.stdout = open(file_path, "a")
if cv2.waitKey(10) == ord('q'):
break
cv2.destroyAllWindows()
os.system('cls' if os.name == 'nt' else 'clear')
print("\nCoords x, y, ix, iy)
head, tail = os.path.split(path_to_1_output)
sys.stdout = open("#"+(b)+tail+str(scale)+".txt", "w"
...
head, tail = os.path.split(path_to_2_output)
sys.stdout = open("#"+(b)+tail+str(points)+".txt", "w"