Forum

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - bennymicheal

Pages: [1]
1
Python and Java API / batch python script
« on: October 05, 2018, 06:01:20 PM »
my batch script keeps failing with "Error: module 'PySide2.QtGui' has no attribute 'QApplication'"
How can I fix this?
Here is the script:

import os,re,sys
import PhotoScan
from PySide2 import QtWidgets
from PySide2 import QtGui




def main():

   global doc
   doc = PhotoScan.app.document

   app = QtGui.QApplication.instance()
   parent = app.activeWindow()
   
   #prompting for path to photos
   path_photos = PhotoScan.app.getExistingDirectory("Specify input photo folder:")
   path_export = PhotoScan.app.getExistingDirectory("Specify EXPORT folder:")
   
   #processing parameters
   accuracy = PhotoScan.Accuracy.HighAccuracy  #align photos accuracy
   preselection = PhotoScan.Preselection.NoPreselection
   keypoints = 0 #align photos key point limit
   tiepoints = 0 #align photos tie point limit
   source = PhotoScan.PointsSource.DensePoints #build mesh source
   surface = PhotoScan.SurfaceType.Arbitrary #build mesh surface type
   quality = PhotoScan.Quality.HighQuality #build dense cloud quality
   filtering = PhotoScan.FilterMode.ModerateFiltering #depth filtering
   interpolation = PhotoScan.Interpolation.EnabledInterpolation #build mesh interpolation
   face_num = PhotoScan.FaceCount.HighFaceCount #build mesh polygon count
   mapping = PhotoScan.MappingMode.GenericMapping #build texture mapping
   atlas_size = 8196
   blending = PhotoScan.BlendingMode.MosaicBlending #blending mode
   color_corr = False


   print("Script started")

   #creating new chunk
   doc.addChunk()
   chunk = doc.chunks[-1]
   chunk.label = "New Chunk"

   #loading images
   image_list = os.listdir(path_photos)
   photo_list = list()
   for photo in image_list:
      if ("jpg" or "jpeg" or "JPG" or "JPEG") in photo.lower():
         photo_list.append(path_photos + "\\" + photo)
   chunk.addPhotos(photo_list)

   #align photos
   chunk.matchPhotos(accuracy = accuracy, preselection = preselection, filter_mask = False, keypoint_limit = keypoints,    tiepoint_limit = tiepoints)
   chunk.alignCameras()
   
   chunk.optimizeCameras()
   doc.save()

   #building dense cloud
   #PhotoScan.app.gpu_mask = 1  #GPU devices binary mask
   PhotoScan.app.cpu_enable = True  #CPU enable
   chunk.buildDenseCloud(quality = quality, filter = filtering)
   doc.save()

   #building mesh
   chunk.buildModel(surface = surface, source = source, interpolation = interpolation, face_count = face_num)
   doc.save()

   #build texture
   chunk.buildUV(mapping = mapping, count = 2)
   chunk.buildTexture(blending = blending , color_correction = color_corr, size = atlas_size)
   doc.save()

   PhotoScan.app.update()

   #export
   
   chunk.exportModel(path_export + "\\model.obj", format = "obj", texture_format='jpg')

   print("Script finished")


PhotoScan.app.addMenuItem("Custom menu/batch process", main)   

Pages: [1]