Forum

Author Topic: python script get killed  (Read 2454 times)

wangyuqing

  • Newbie
  • *
  • Posts: 2
    • View Profile
python script get killed
« on: November 02, 2017, 10:57:42 AM »
Please help!!! when I run python script , it always get killed by terminal. How can I figure out why it got killed ?

And when I set densecloud to be lowquality , it can finish processing?!

it's that a problem of memory? But I really need high quality reconstruction.

thanks !

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14851
    • View Profile
Re: python script get killed
« Reply #1 on: November 02, 2017, 11:01:20 AM »
Hello wangyuqing,

Can you provide the processing log and, if possible, the script?
Best regards,
Alexey Pasumansky,
Agisoft LLC

wangyuqing

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: python script get killed
« Reply #2 on: November 02, 2017, 11:17:56 AM »
where can I find the processing log file, as when it got killed, the UI is closed , so I can not see the log from "console"

and here is the script:


import glob
import os
from time import time
import PhotoScan

def build3D():
  start = time()

  index_id = 0
  prefix = []
  prefix.append("/home/Documents/wangyuqing2/1")
  for dirs in os.listdir(str(prefix[0])):
    dir_sub = dirs
    if dir_sub[-4:].lower() != ".psz" and dir_sub != "."  and dir_sub != ".." :

      dir = glob.glob(str(prefix[0]) + '/' + dir_sub + '/*.JPG')
      dir_choice = []
      count = 0
 
      num = len(dir)

      for dir_sub in dir:
        count = count + 1
        fout.write("count:" + str(count) + '\n')
        dir_choice.append(dir_sub)
        fout.write("Image file:" + dir_sub + '\n')       
        if count > num:
          break
        if count == num:
          index_id = index_id + 1

          PhotoScan.app.gpu_mask = 3
          doc = PhotoScan.app.document
          chunk = doc.addChunk()
          chunk.addPhotos(dir_choice)

          camera = chunk.cameras[0]
          camera.photo.meta["Exif/FocalLength"]

          for frame in chunk.frames:
            frame.matchPhotos(accuracy = PhotoScan.HighAccuracy,preselection=PhotoScan.GenericPreselection)
 
          chunk.alignCameras()
          stop1 = time()
          fout.write("Finish read and alignment: " + str(stop1 - start) + "s\n")

          chunk.buildDenseCloud(quality = PhotoScan.HighQuality,filter=PhotoScan.FilterMode.AggressiveFiltering)
          stop2 = time()
          fout.write("Finish build dense cloud: " + str(stop2 - stop1) + "s\n")

          chunk.buildModel(surface = PhotoScan.Arbitrary, interpolation = PhotoScan.EnabledInterpolation)
          stop3 = time()
          fout.write("Finish build model: " + str(stop3 - stop2) + "s\n")

          chunk.buildUV(mapping = PhotoScan.GenericMapping)
          stop4 = time()
          fout.write("Finish build UV: " + str(stop4 - stop3) + "s\n")

          chunk.buildTexture(blending = PhotoScan.MosaicBlending,size = 4096)
          stop5 = time()
          fout.write("Finish build texture: " + str(stop5 - stop4) + "s\n")

          stop = time()
          fout.write("Finish all: " + str(stop-start) + "s\n")
 
          chunk.exportModel("/home/Documents/wangyuqing2/result_1/",texture_format='jpg')
          project_path = ("/home/Documents/wangyuqing2/result_1/"+str(index_id)+".psz")
          if project_path[-4:].lower() != ".psz":
            project_path += ".psz"
          print(project_path)
          fout.write("Saving to:" + project_path + '\n')
          try:
            doc.save(project_path)
          except:
            PhotoScan.app.messageBox("Can't save project")
          doc.clear()

def main():
  build3D()

if __name__ == '__main__':
  main()

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14851
    • View Profile
Re: python script get killed
« Reply #3 on: November 02, 2017, 11:29:53 AM »
Hello wangyuqing,

In PhotoScan Preferences window you can specify the redirection of the log to the file. After using this option I suggest to re-start PhotoScan Pro instance and then run script.
Best regards,
Alexey Pasumansky,
Agisoft LLC