Greetings,
I am working with images form and RGB and an NIR camera and I need to process them in individual chunks in the same project.
I cant seem to add multiple chunks in the script, the second added chunk overwrites the first.. Can anyone point me in the direction of a solution to this?
Here is an example framework of the script where I try to add a second chunk.
# start new project and save as specific unique project name
import os
import PhotoScan as ps
doc = ps.app.document
chunk = doc.addChunk()
project_path = ps.app.getSaveFileName("Specify project filename for saving: ")
if not project_path:
print("Script aborted")
if project_path[-4:].lower() != ".psz":
project_path += ".psz"
doc.save(project_path)
ps.app.update()
# get folder of RGB photos
path_photos_rgb = ps.app.getExistingDirectory("Specify folder with RGB photos: ")
path_photos_rgb += "/"
# get folder of NIR photos
path_photos_nir = ps.app.getExistingDirectory("Specify folder with NIR photos: ")
path_photos_nir += "/"
# create 'RGB' chunk and add photos
chunk.label = "RGB"
image_list = os.listdir(path_photos_rgb)
photo_list = list()
for photo in image_list:
if photo.rsplit(".",1)[1].upper() in ["JPG", "JPEG", "TIF", "PNG", "TIFF"]:
photo_list.append(path_photos_rgb + photo)
print(photo)
else:
print("No photo available.")
print(photo_list)
chunk.addPhotos(photo_list)
doc.save(project_path)
ps.app.update()
# create 'NIR' chunk and add photos
chunk.label = "NIR"
image_list = os.listdir(path_photos_nir)
photo_list = list()
for photo in image_list:
if photo.rsplit(".",1)[1].upper() in ["JPG", "JPEG", "TIF", "PNG", "TIFF"]:
photo_list.append(path_photos_nir + photo)
print(photo)
else:
print("No photo available.")
print(photo_list)
chunk.addPhotos(photo_list)
doc.save(project_path)
ps.app.update()
print("step finished")
at this point I have a single chunk labeled "NIR" that contains all the RGB and NIR photos. Any suggestions?
Thank you for your time,