def export_ortho(): global path_to_project print(path_to_project['ProjectPath']) export_filename = os.path.basename(path_to_project['ProjectPath']).replace( '.psz', '.tif') export_path = os.path.join(export_folder, export_filename) try: project = PhotoScan.app.document project.open(path_to_project['ProjectPath']) dx, dy = mosaic.get_resolution(path_to_project['Flight_id'], path_to_project['Field'], path_to_project['Camera']) if dx is not None and dy is not None: status = project.activeChunk.exportOrthophoto( export_path, format="tif", color_correction=False, blending='average', dx=dx, dy=dy, projection=project.activeChunk.projection) else: status = project.activeChunk.exportOrthophoto( export_path, format="tif", color_correction=False, blending='average', projection=project.activeChunk.projection) if status is True: app = PhotoScan.Application() app.quit() except Exception as e: print(e) return
def setup_application(self): app = PhotoScan.Application() # Use all available GPUs, needs a bit mask number_of_gpus = len(PhotoScan.app.enumGPUDevices()) mask = int(str('1' * number_of_gpus).rjust(8, '0'), 2) app.gpu_mask = mask # Allow usage of CPU and GPU app.cpu_enable = True settings = PhotoScan.Application.Settings() # Logging settings.log_enable = True settings.log_path = self.project_file_name + '_agisoft.log' settings.save()
import argparse import csv import PhotoScan # construct the argument parse and parse the arguments ap = argparse.ArgumentParser() ap.add_argument("-wp", "--wpath", required=True, help="workingPath") ap.add_argument("-mf", "--mfile", required=True, help="markerFile") args = vars(ap.parse_args()) workingPath = args["wpath"] + "\\" markerFile = args["mfile"] print("Working path is: %s" % workingPath) project = workingPath + "ortho_dem_process.psx" app = PhotoScan.Application() doc = PhotoScan.app.document doc.open(project) PhotoScan.app.gpu_mask = 1 # PhotoScan.app.cpu_enable = 8 chunk = doc.chunk chunk.crs = PhotoScan.CoordinateSystem("EPSG::4326") # Assign GCPs markerList = open(markerFile, "rt") # print(markerList) eof = False line = markerList.readline() #reading the line in input file # print(line)
# The parameters used to build the dense point cloud build_dense_cloud_config = {'quality': PhotoScan.HighQuality} # The parameters used to build the model build_model_config = { 'surface': PhotoScan.Arbitrary, 'interpolation': PhotoScan.EnabledInterpolation } ################################################# # Processing # This is the where the work happens! log("--- Starting workflow ---") log("Photoscan version " + PhotoScan.Application().version) log("Home directory: " + HomeDirectory) log_time() chunk_dirs = get_subdirectories(HomeDirectory) log("Found {} project directories".format(len(chunk_dirs))) doc = make_project(HomeDirectory, chunk_dirs) for chunk in doc.chunks: log("Processing chunk") # Here's where you process the chunk # Some examples of what you can do, uncomment as needed.