1
Python and Java API / Loading camera extrinsics and intrinsics
« on: July 10, 2018, 03:38:55 PM »
Hi,
I'm trying to import camera's of which I know the location and orientation.
My camera calibration file "extrinsics.txt" contains X,Y,Z and Pitch,Yaw,Roll and looks like this:
Per camera I have a calibration file like this:
I Try to combine this information with the following script:
However, this results in an image size mismatch error.
Am I approaching this in the correct way?
What does the image size mismatch mean?
All my images have the same size.
Any help is much appreciated.
I'm trying to import camera's of which I know the location and orientation.
My camera calibration file "extrinsics.txt" contains X,Y,Z and Pitch,Yaw,Roll and looks like this:
Quote
160865296_0_0.png 202228 503600 1620.77 -4.71239e-05 -0.000553269 1.57166
160965118_0_0.png 202233 502477 1618.94 0.000794125 0.000572468 4.70667
160865298_0_0.png 202651 503600 1621.07 0.000101229 -0.00047473 1.57178
160965116_0_0.png 202657 502474 1618.79 0.00010821 0.000572468 4.70528
160865300_0_0.png 203067 503601 1620.81 0.000277507 -0.000298451 1.57371
160965114_0_0.png 203074 502472 1618.99 -0.000699877 0.000486947 4.70772
Per camera I have a calibration file like this:
Quote
<?xml version="1.0" encoding="UTF-8"?>
<calibration>
<projection>frame</projection>
<width>17310</width>
<height>11310</height>
<f>16750</f>
<cx>8655</cx>
<cy>5625</cy>
</calibration>
I Try to combine this information with the following script:
Code: [Select]
import os
import PhotoScan
from glob import glob
# settings for this project
ext_path = "camera_extrinsics/extrinsics.txt"
img_dir = "images_no_subs/"
int_dir = "camera_intrinsics/"
out_path = "photoscan_out/project.psx"
# new project
doc = PhotoScan.app.document
# new chunk
chunk = doc.addChunk()
# load extrinsics
# label used in file is equal to img_path
chunk.loadReference( ext_path )
# load images and intrinsics
img_list = os.listdir( img_dir )
int_list = os.listdir( int_dir )
for img_path, int_path in zip( img_list, int_list ):
# load image
# camera = chunk.AddCamera()
camera = chunk.addCamera()
camera.open( os.path.join( img_dir, img_path ) )
# link extrinsics to image by making the label equal
camera.label = img_path
# load intrinsics
calibration = PhotoScan.Calibration()
calibration.load( os.path.join( int_dir, int_path ) )
sensor = chunk.addSensor()
sensor.user_calib = calibration
# link intrinsics to image by setting label equal (perhaps not necessary?)
sensor.label = img_path
# link intrinsics to image by assigning to camera
camera.sensor = sensor
# now that we loaded all data,
# start processing
chunk.matchPhotos( accuracy=PhotoScan.HighAccuracy, generic_preselection=True, reference_preselection=False )
#chunk.alignCameras()
#chunk.optimizeCameras()
#chunk.buildDepthMaps( quality = PhotoScan.LowQuality, filter = PhotoScan.AggressiveFiltering )
#chunk.buildDenseCloud( point_colors = True )
# now that we're done processing,
# store the results
doc.save( out_path )
However, this results in an image size mismatch error.
Am I approaching this in the correct way?
What does the image size mismatch mean?
All my images have the same size.
Any help is much appreciated.