Forum

Author Topic: Python from 1.2.X to 1.3.0  (Read 2522 times)

Shepah

  • Newbie
  • *
  • Posts: 9
    • View Profile
Python from 1.2.X to 1.3.0
« on: June 14, 2017, 04:35:40 PM »
Hi all,

I'm currently facing a problem with my python script with Photoscan 1.3.0

This script was used with 1.2 version and worked fine. We just updated to 1.3.0 on our rigs but since the process can't run anymore.

I've isolated the problem to this part:
Code: [Select]
def loadCamera(chunk, path, name):
 
  prepareSensor(chunk)
 
  c = chunk.addCamera()
  c.sensor = chunk.sensors[chunk.sensors.__len__()-1]
 
  oky = c.open(path)

  c.label = name
 
  c.sensor.label = name
 
  img = c.photo.image()
 
  if img is not None:
   
    c.sensor.width = img.width
   
    c.sensor.height = img.height
   
 
  return oky

this part loads our photo, but oky is returned in NoneType.

Any idea ? Maybe Python lib change use others functions.

I've tried to follow up with http://www.agisoft.com/pdf/photoscan_python_api_1_3_0.pdf but i can't find any solutions.

Lemme know if you need more code.

Thanks in advance

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14855
    • View Profile
Re: Python from 1.2.X to 1.3.0
« Reply #1 on: June 14, 2017, 05:58:20 PM »
Hello Shepah,

If you use chunk.addPhotos([path]) function - it will load the image and automatically assign the sensor (calibration group) to the camera according to the image resolution, focal length and camera make. 
Best regards,
Alexey Pasumansky,
Agisoft LLC

Shepah

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Python from 1.2.X to 1.3.0
« Reply #2 on: June 14, 2017, 06:18:29 PM »
Hello, thanks for the answer, I tried updating code to
Code: [Select]
def loadCamera(chunk, path, name):
 
  prepareSensor(chunk)
 
  # c = chunk.addCamera()
  # c.sensor = chunk.sensors[chunk.sensors.__len__()-1]
 
  # oky = c.open(path)

  # c.label = name
 
  # c.sensor.label = name
 
  # img = c.photo.image()
 
  # if img is not None:
   
    # c.sensor.width = img.width
   
    # c.sensor.height = img.height
  oky = chunk.addPhotos(path)
 
  return oky

But i get :

Code: [Select]
2017-06-14 08:16:59     oky = chunk.addPhotos(path)
2017-06-14 08:16:59 RuntimeError: Can't load photos


Maybe i skipped something :/

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14855
    • View Profile
Re: Python from 1.2.X to 1.3.0
« Reply #3 on: June 14, 2017, 06:25:13 PM »
Hello Shepah,

addPhotos() takes the list of paths as an argument, so if your "path" variable is a single string, you need to use it as chunk.addPhotos([path]). So as you can see, here's the single element list is used.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Shepah

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Python from 1.2.X to 1.3.0
« Reply #4 on: June 14, 2017, 06:32:00 PM »
Thanks, that seems to do the trick, now i see other parts that fails, i'll look into it and post here if any.

Again thanks a lot Alexey Pasumansky

Shepah

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Python from 1.2.X to 1.3.0
« Reply #5 on: June 15, 2017, 12:30:41 AM »
All problem were fixed next, for other to read, take care of using PhotoScan.<function> rather than string
I have encountered this on loading markers ('xml' is replaced by ReferenceFormatXML )

A last question for agisoft staff, is there a max GPU that agisoft can operate ? I can set rig with 2x to 20x GPU, but if it can't operate more than 4 or 5 i'm not bothering building such servers.