Agisoft Metashape

Agisoft Metashape => General => Topic started by: chehroma on January 16, 2018, 12:27:39 PM

Title: Change photo
Post by: chehroma on January 16, 2018, 12:27:39 PM
In 1.3.4 i use script for change photo
Code: [Select]
for i in range(len(chunk.cameras)):
camera = chunk.cameras[i]
photo = camera.photo.copy()
photo.path = firstdir + camera.label
camera.photo = photo
Now in 1.4 I have an error:
Quote
Error: Can't open file: No such file or directory (2): d:/FTP/1516031537175/firstdir/1

Can you help me?
Title: Re: Change photo
Post by: Alexey Pasumansky on January 16, 2018, 12:34:47 PM
Hello chehroma,

In the version 1.4.0 there's an option in the Advanced preferences dialog that allows to exclude the filename extension from the camera labels when the photos are added to the project. If the option is turned on in your case, you can uncheck it, re-load the photos to the new chunk and try the script again.
Title: Re: Change photo
Post by: chehroma on January 16, 2018, 12:46:35 PM
Thank, but I have the same problem. This is my advanced preferences dialog. What are items I need to off/on.
Title: Re: Change photo
Post by: Alexey Pasumansky on January 16, 2018, 12:48:53 PM
Hello chehroma:

Preferences -> Advanced -> Export / Import -> Strip file extensions from camera labels.
Title: Re: Change photo
Post by: chehroma on January 16, 2018, 12:54:42 PM
Dont work, the same error.
Quote
Error: Can't open file: No such file or directory (2): d:/FTP/1516031537175/first/1
Title: Re: Change photo
Post by: chehroma on January 16, 2018, 12:55:52 PM
This is my preference.
Title: Re: Change photo
Post by: Alexey Pasumansky on January 16, 2018, 01:05:12 PM
Hello chehroma,

Can you please post the screenshot of the camera list from the Workspace pane?
Title: Re: Change photo
Post by: chehroma on January 16, 2018, 01:48:12 PM
Please)
Title: Re: Change photo
Post by: Alexey Pasumansky on January 16, 2018, 01:58:52 PM
Hello chehroma,

So the images were added to the project before "strip file extensions" option was disabled?

The option has effect only on the photos added to the project after it's status has been modified. It wouldn't make any changes to already created and existing projects.
Title: Re: Change photo
Post by: chehroma on January 16, 2018, 02:26:39 PM
I turn off "strip file extensions", restart agisoft, add photo by script (it added). Than try change to another and have the same problem.
Title: Re: Change photo
Post by: chehroma on January 16, 2018, 03:17:33 PM
Help me add + ".jpg", but i dont understund why it?

Code: [Select]
for i in range(len(chunk.cameras)):
camera = chunk.cameras[i]
photo = camera.photo.copy()
photo.path = firstdir + camera.label + ".jpg"
camera.photo = photo
Title: Re: Change photo
Post by: Alexey Pasumansky on January 16, 2018, 07:47:20 PM
Hello chehroma,

It seems that Preference setting in 1.4.0 doesn't have any effect on Python .addPhotos() operation and the extension is always stripped. So you can add it back to the labels using the following code:
Code: [Select]
for camera in chunk.cameras:
   camera.label += "." + camera.photo.path.rsplit(".", 1)[1]
Thus you'll be able to import XML with the cameras from the older versions (where the camera labels contain the image extension).