16
Python and Java API / Import photos from a file list
« on: May 20, 2016, 07:10:06 PM »
Okay I admit I am new to python.
I have a 200,000 photo project (yes) and need to subdivide it. Many overlapping survey tracks and runs, file structure by time not by coordinate. I will choose portions of it using GIS software and it gives me a file list with lines like this:
Z:\some\path\000000_000999\20160322_212257_IMG_000001.JPG 20160322_212257_IMG_000001.JPG -15.00275855 -173.0095973 -455.4
How can I import photos from this list into photoscan? Everyone else on this forum lists the contents of a folder, which does not help me as they are spread across hundreds of folders.
This is what I tried but it terminates with a "cant load photos". I suspect I am parsing a line feed wrong.
import os
import PhotoScan
global doc
doc = PhotoScan.app.document
doc.addChunk()
chunk = doc.chunks[-1]
chunk.label = "toms chunk"
sourcepath = r"C:\Users\Arena\Desktop\test\list.txt"
sourcefile = open(sourcepath, 'r')
print (sourcefile)
files = sourcefile.readlines()
print (files)
chunk.addPhotos(files)
-end of code-
Many thanks!
Tom
I have a 200,000 photo project (yes) and need to subdivide it. Many overlapping survey tracks and runs, file structure by time not by coordinate. I will choose portions of it using GIS software and it gives me a file list with lines like this:
Z:\some\path\000000_000999\20160322_212257_IMG_000001.JPG 20160322_212257_IMG_000001.JPG -15.00275855 -173.0095973 -455.4
How can I import photos from this list into photoscan? Everyone else on this forum lists the contents of a folder, which does not help me as they are spread across hundreds of folders.
This is what I tried but it terminates with a "cant load photos". I suspect I am parsing a line feed wrong.
import os
import PhotoScan
global doc
doc = PhotoScan.app.document
doc.addChunk()
chunk = doc.chunks[-1]
chunk.label = "toms chunk"
sourcepath = r"C:\Users\Arena\Desktop\test\list.txt"
sourcefile = open(sourcepath, 'r')
print (sourcefile)
files = sourcefile.readlines()
print (files)
chunk.addPhotos(files)
-end of code-
Many thanks!
Tom