Since I really needed to correct this I fiddle a bit and found a workaround, I’m posting it here in case someone have the same problem.
The way it work is modifying the generated PDF and correcting the /C2W and /CO lines with correct value (the result is not the same as what PhotoScan do in gui mode but for my use its sufficient).
import os
import math
import PhotoScan
def correct_pdf(in_file):
chunk = PhotoScan.app.document.chunk
# Matrice de transformation
T = chunk.transform.matrix
# take the center of the region as the center of rotation
view_center = list(T.mulp(chunk.region.center))
# take the bigest size au the box as the view space
max_size = max(T.mulp(chunk.region.size))
# calculate de viewpoint distance with 30° fov (PDF default)
CO = (max_size / 2) / math.tan(math.radians(30/2))
# calculate the center of the viewpoint
C2W = view_center
view_center[2] += CO
# open the saved PDF and create a new one PDF
old_file = open(in_file, 'rb')
new_file = open(in_file + '.newpdf', 'wb')
for line in old_file:
# line for C2W
if line.startswith(b'/C2W'):
new_file.write(('/C2W [ -1 0 0 0 1 0 0 0 -1 ' +
str(round(C2W[0], 5)) + ' ' +
str(round(C2W[1], 5)) + ' ' +
str(round(C2W[2], 5)) + ' ]\n').encode('utf-8'))
# Line for CO
elif line.startswith(b'/CO'):
new_file.write(('/CO ' + str(round(CO, 5)) + '\n').encode('utf-8'))
# rest of the file
else:
new_file.write(line)
old_file.close()
new_file.close()
# Replace old pdf by new one
os.remove(in_file)
os.rename(in_file + '.newpdf', in_file)