Unfortunately I still can't get it to work. I have modified my code as follows:
Working code :
# photoscan doc doc = PhotoScan.app.document
# create a new chunk in the workspace chunk = PhotoScan.app.document.addChunk()
# add photos to the chunk
#this adds them one at a time
#need for loop to add 20 cameras at once chunk.addPhotos(["M:\TCL16\scans\D20\Session1\subject1\AU02_01\Captured_Photos\Tiff\FullColor\camera01_14.tif"])
# Match Photos with accuracy setting and preselection chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy, preselection=PhotoScan.GenericPreselection)
# Align Photos chunk.alignCameras()
#Build Dense Cloud chunk.buildDenseCloud(quality=PhotoScan.LowQuality)
#surface setting = Arbitrary setting is part of the Build Mesh processing in the old Batch Processing menu
#Interpolation is part of the advanced setting in Build Mesh job chunk.buildModel(surface=PhotoScan.Arbitrary, interpolation=PhotoScan.Extrapolated)
#Build Texture choice is blending mode and texture size (atlas height)
#buildUV is mapping mode choice chunk.buildUV(mapping=PhotoScan.GenericMapping)
chunk.buildTexture(blending=PhotoScan.MosaicBlending, size=1024)
# Export chunk.exportCameras("M:\TCL16\scans\D20\Session1\subject1\AU02_01\Scan_Data\subject1_01_ScanCameras.xml")
#Export Model files (.jpg, .mtl, .obj) chunk.exportModel("M:\TCL16\scans\D20\Session1\subject1\AU02_01\Scan_Data\subject1_01_ScanModel.obj")
After this code, I added:
#need for loop to add 20 cameras at once camera = chunk.cameras[0] #first camera
image = camera.photo.image()
for camera in chunk.cameras:
currentCameraImage = camera.photo.image()
calibration = camera.sensor.calibration()
undistortedCameraImage = currentCameraImage.undistort(calibration, center_principal_point=buildSettings.exportData.undistortedPhotos.centerPrincipalPoints, square_pixels=buildSetting.exportData.undistortedPhotos.squarePixels)
undistortedFullImageName = os.path.split(camera.photo.path) [-1]
undistortedImageName = oc.path.plitext(undistortedFullImageName)
undistortedCameraImage.save(os.path.join(outputUndistortedDirPath, undistortedImageName +”.jpg”))
I hit enter twice, it returns:
Traceback (most recent call last):
File "<console>", line 3, in <module>
TypeError: 'PhotoScan.Calibration' object is not callableI'm stuck at this point. It was suggested I can use the image.undistort() function after I have the image, with the arguments PhotoScan.Calibration() but I'm not sure what this should look like.
Thanks again for this help.
m