0

In my project, I use a 3D camera that makes me two .dat (pictures) files from a moving object (circuit board). A special program opens them as an image. The goal is to combine two different .dat files/pictures. Unfortunately, there`s no program that can do these things, so I have to write one by myself. I'm writing Python code to get these files merged/combined, but somehow my code doesn't work. What am I doing wrong? When I get these two pictures combined horizontally and vertically, I manage to give newly created file to special program for an analysis and therefore I can continue with my project.

Thank you!

from PIL import Image
img = Image.open("C:\Users\HP\Desktop\circuit_board1_1.dat")
img = img.resize((1280,1440))
img1 = image.open("C:\Users\HP\Desktop\circuit_board1_2.dat")
img1 = img.resize((1280,1440))
bi=Image.new('RGBA',(1280,2880),'white')
bi.show()
bi.paste(img,(0,0,1280,1440))
bi.show()
bi.paste(img1,(0,1440,1280,2880))
bi.show()
bi.save("C:\Users\HP\Desktop\combined_circuit_board1.dat")

Error message:

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\Users\HP> & C:/Users/HP/AppData/Local/Programs/Python/Python38-32/python.exe "c:/Users/HP/Desktop/Merge photos.py"
  File "c:/Users/HP/Desktop/Merge photos.py", line 2
    img = Image.open("C:\Users\HP\Desktop\circuit_board1_1.dat")
                     ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
PS C:\Users\HP>

mkrieger1
  • 19,194
  • 5
  • 54
  • 65

0 Answers0