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 - akasch

Pages: [1]
Hi all,

I am trying to run a workflow that has been discussed in previous threads but I am having trouble with one aspect. I have The camera calibration file saved as an xml. My workflow is:

1.) Create a new chunk based on the name of the image file.
2.) Label the chunk based on the name of the image file.
3.) Add photos to the chunk based on the name of the image file.
4.) Load a reference file to enter roll, pitch yaw data.
6.) Align photos in each chunk.
7.) Build Mesh (based on sparse point cloud)
8.) Build Ortho
9.) Export Ortho and name based on name of image file.

My problem is:
1.) The camera calibration file does not seem to be able to be read. When I load the images into the chunk, a sensor is automatically created, but I do not know how to access it with the code.


Here is my script (apart from the line about camera calibration file loading, it works great):

Code: [Select]
import os, PhotoScan, fnmatch

#file path where raw images exist: User Parameter
rawImages ="Choose Location of Raw Unmosaicked Tifs")

#Create Output Folder, set output workspace, save .psx photoscan project, set output coordinate system
NewFolder = rawImages + "\\OutputOrthos"
if not os.path.isdir(NewFolder):
NewPhotoScanProject = rawImages + r"\PhotoScanProject.psx"
projectedcrs ="Select Output CoordinateSystem") #User Parameter

#Define active document and save it
doc =

outputcsv = "\IMUData.csv"

#Put files in rawImages folder in a list
ListTifs = os.listdir(rawImages)

#Search through files in ListTifs by ID and put them into sets of tifs based on the ID
allFields = [rasterName[0:8] for rasterName in ListTifs if rasterName[-3:] == "tif"]
uniqueFields = set(allFields)

#For each set, create chunk, define its coordinate system, align photos, build mesh, build orthomosaic, and export orthomosaic
for ID in uniqueFields:
    field = doc.addChunk()
    field.label = ID
    matchingIDs = fnmatch.filter(ListTifs, ID + "*.tif") = PhotoScan.CoordinateSystem("EPSG::4326")
    for match in matchingIDs:
        field.addPhotos([rawImages + "\\" + match])
    doc.chunk.loadReference(outputcsv,'csv',' nxyzabc',delimiter=',',group_delimiters=False,skip_rows=1)
    PhotoScan.Calibration(rawImages + '\\CameralCal.xml',format='xml')
    field.exportOrthomosaic(NewFolder + "\\" + ID + ".tif","tif",raster_transform=PhotoScan.RasterTransformNone,projection=projectedcrs)

Python and Java API / Using Python IDE and PhotoScan Modules
« on: June 09, 2016, 10:42:35 PM »

I like using to use PyScripter to write my code, but it does not recognize the PhotoScan module. Does anyone know how to make this site package functional??


Python and Java API / Importing images by looping through multiple folders
« on: September 17, 2015, 08:31:05 PM »

Has anyone written a Python script that accesses images stored in different folders? I want the images in each folder to be placed into its own chunk.


Folder A (with images 1, 2, 3) translates to Chunk A containing images 1, 2, 3
Folder B (with images 4, 5, 6) translates to Chunk B containing images 4, 5, 6

Does anyone have script that accomplishes this? Any help would be amazing.


Python and Java API / Automated Batch Processing Script
« on: September 17, 2015, 12:00:28 AM »
Hi there,

So I have read through many posts trying to figure out exactly how to build the script I would like to build, but I have been unsuccessful at finding just what I want. Here is what I would like to accomplish in the batch processing script:

1.) import images in .tif format (which will be in different folders based on their subject) with each set of images in its own chunk. (I would like to be able to select a different path for the image location each time).
2.) align images within chunk.
3.) build mesh based on sparse cloud.
4.) export orthophoto as a tif with a specific geographic projection. (I would like to select a different path for the saved output each time).

Thanks for any input!

Pages: [1]