1
Python and Java API / Re: Messages stop from command prompt; python experiences from command prompt?
« on: November 27, 2018, 07:21:30 PM »
Hi Alexey,
Your comments were very helpful. Thanks! I now have my script running and based on your suggestion to use command line arguments, figured out how to batch process through my folder set.
For anyone else who comes along, I'll leave my code here
note this creates the photoscan file (.psx) in the directory folder with the full set of photos
I set up a .bat file with this basic outline
"C:\Progam Files\Agisoft\PhotoScan Pro\photoscan.exe" -r "D:\photoscan_batch.py" "D:\photo_set1" %*
ECHO Set 1 Run
"C:\Progam Files\Agisoft\PhotoScan Pro\photoscan.exe" -r "D:\photoscan_batch.py" "D:\photos_set2" %*
ECHO Set 2 Run
Then run it from command line using
Your comments were very helpful. Thanks! I now have my script running and based on your suggestion to use command line arguments, figured out how to batch process through my folder set.
For anyone else who comes along, I'll leave my code here
note this creates the photoscan file (.psx) in the directory folder with the full set of photos
I set up a .bat file with this basic outline
"C:\Progam Files\Agisoft\PhotoScan Pro\photoscan.exe" -r "D:\photoscan_batch.py" "D:\photo_set1" %*
ECHO Set 1 Run
"C:\Progam Files\Agisoft\PhotoScan Pro\photoscan.exe" -r "D:\photoscan_batch.py" "D:\photos_set2" %*
ECHO Set 2 Run
Then run it from command line using
Code: [Select]
C:\Program Files\Agisoft\PhotoScan Pro>photoscan.exe -r "D:\UAV_2018\photoscan_draft.py" "D:/image_folder/"
Code: [Select]
#! python3
import os
import PhotoScan, sys
path_photos = sys.argv[1]
# Define: AlignPhotosAccuracy ["high", "medium", "low"]
AlignPhotosAccuracy = "medium"
# set new working directory to be in working folder set in command line
os.chdir(path_photos)
print("Home directory: " + path_photos)
# Define: PhotoScan Project File
PhotoScanProjectFile = ".\\PhotoScan_Project.psz"
# get main app objects
doc = PhotoScan.Document() #instead of doc = PhotoScan.app.document
doc.save(PhotoScanProjectFile)
app = PhotoScan.Application()
# create chunk
chunk = doc.addChunk()
# 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)
# SAVE PROJECT
doc.save()
print("---Saving project...")
############################################################################
print("File: " + PhotoScanProjectFile)
# if not (doc.save(PhotoScanProjectFile)):
# app.messageBox("Saving project failed!")
# Set up all GPUs to work (not sure if this is necessary)
# from http://www.agisoft.com/forum/index.php?topic=9874.0
# Enable two GPUs
PhotoScan.app.gpu_mask = 3
# ALIGN PHOTOS
print("---Aligning photos ...")
chunk.matchPhotos(PhotoScan.LowAccuracy, PhotoScan.GenericPreselection, False, 40000, 1000)
chunk.alignCameras()
doc.save()
print("saved, now to dense cloud")
#Build dense cloud
chunk.buildDepthMaps(quality=PhotoScan.MediumQuality, filter=PhotoScan.AggressiveFiltering)
chunk.buildDenseCloud()
doc.save()
print("SAVED DENSE CLOUD")
############################################################################
#this is where I ended as I needed to manually add GCPs.