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

Pages: [1]
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.
5.) LOAD A CAMERA CALIBRATION FILE TO EACH CHUNK.
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.

Thanks!!

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 = PhotoScan.app.getExistingDirectory("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):
    os.makedirs(NewFolder)
NewPhotoScanProject = rawImages + r"\PhotoScanProject.psx"
projectedcrs = PhotoScan.app.getCoordinateSystem("Select Output CoordinateSystem") #User Parameter

#Define active document and save it
doc = PhotoScan.app.document
doc.save(NewPhotoScanProject)

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")
    doc.chunk.crs = 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)
    field.matchPhotos(accuracy=PhotoScan.HighAccuracy,preselection=PhotoScan.ReferencePreselection)
    doc.save()
    field.alignCameras()
    doc.save()
    PhotoScan.Calibration(rawImages + '\\CameralCal.xml',format='xml')
    doc.save()
    field.buildModel(surface=PhotoScan.HeightField)
    doc.save()
    field.buildOrthomosaic(surface=PhotoScan.DataSource.ModelData,blending=PhotoScan.BlendingMode.MosaicBlending,color_correction=False,projection=projectedcrs)
    doc.save()
    field.exportOrthomosaic(NewFolder + "\\" + ID + ".tif","tif",raster_transform=PhotoScan.RasterTransformNone,projection=projectedcrs)
    doc.save()

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

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

Thanks!


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

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.

So:

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.

Thanks!

4
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]