Hello,
I've made a project using Python scripting that detect markers on photographs and then make photo alignment. Here is the code:
# Accessing photoscan objects
doc = PhotoScan.app.document
chunk = doc.chunk
chunk.crs = None
chunk.detectMarkers():
# Add scalebars
# I've cut code here as it's quite long. This part check if markers are available and create
# 3 scalebars
# Aliging photographs
print("Aligning photographs.")
chunk.matchPhotos(PhotoScan.HighAccuracy, PhotoScan.GenericPreselection, False, 40000, 1000)
chunk.alignCameras()
This code detect markers, creates 3 scalebars and run photograph alignment.
My problem is that when i run a code from a fresh chunk with 5 photos, the photos are not aligned and i obtain this log:
Detecting markers...
IMG_20150519_125227LRL.jpg: 100 markers
IMG_20150519_125232LRL.jpg: 100 markers
IMG_20150519_125237LRL.jpg: 100 markers
IMG_20150519_125245LRL.jpg: 100 markers
IMG_20150519_125252LRL.jpg: 100 markers
Detected 100 markers.
Creating grid scalebars
Added scalebar target 12 - target 87 (0.1835m).
Added scalebar target 2 - target 100 (0.1835m).
Added scalebar target 2 - target 12 (0.245m).
Aligning photographs.
Detecting points...
photo 1: 39990 points
photo 2: 39967 points
photo 3: 39993 points
photo 4: 39075 points
photo 5: 37071 points
points detected in 4.646 sec
Selecting pairs...
9232 matches found in 0.188 sec
matches combined in 0.002 sec
matches filtered in 0.152 sec
0 of 10 pairs selected in 0 sec
Matching points...
0 matches found in 0.956 sec
matches combined in 0 sec
matches filtered in 0 sec
setting point indices... 0 done in 0 sec
generated 0 tie points, -1.#IND average projections
finished matching in 5.944 sec
selected 0 tracks out of 0 in 0 sec
Finished processing in 5.95 sec (exit code 1)
Estimating camera locations...
processing block: 5 photos
Finished processing in 0.009 sec (exit code 0)
In this case, the photographs are not aligned.
If i modify my script by removing the 7 last lines (about photo matching and align), when i execute the script on a same new chunk and when i choose "Align photos..." from the GUI, the photographs are aligned. See the log:
Detected 100 markers.
Creating grid scalebars
Added scalebar target 12 - target 87 (0.1835m).
Added scalebar target 2 - target 100 (0.1835m).
Added scalebar target 2 - target 12 (0.245m).
Aligning photographs.
Detecting points...
photo 1: 39990 points
photo 2: 39967 points
photo 3: 39993 points
photo 4: 39075 points
photo 5: 37071 points
points detected in 4.668 sec
Selecting pairs...
9248 matches found in 0.19 sec
matches combined in 0.002 sec
matches filtered in 0.349 sec
10 of 10 pairs selected in 0 sec
Matching points...
21255 matches found in 4.237 sec
matches combined in 0.005 sec
matches filtered in 0.881 sec
setting point indices... 2114 done in 0.001 sec
generated 2114 tie points, 3.0965 average projections
removed 131 multiple indices
removed 9 tracks
finished matching in 10.334 sec
selected 1458 tracks out of 2105 in 0.001 sec
Estimating camera locations...
processing block: 5 photos
pair 0 and 2: 709 robust from 743
pair 0 and 1: 724 robust from 742
pair 0 and 4: 716 robust from 731
pair 0 and 3: 691 robust from 727
adding photos 0 and 1 (724 robust)
adding 724 points, 0 far (5.712 threshold), 0 inaccurate, 0 invisible, 0 weak
adjusting: xxxxxxxxxx 132.824 -> 113.061
adding 3 points, 320 far (5.712 threshold), 0 inaccurate, 0 invisible, 0 weak
optimized in 0.025 seconds
adding photo 4 (3 of 5), 100 of 100 used
adding photo 3 (4 of 5), 100 of 100 used
adding photo 2 (5 of 5), 100 of 100 used
adding 285 points, 431 far (5.712 threshold), 0 inaccurate, 0 invisible, 0 weak
adjusting: xxxxxxxxxx 358.254 -> 188.634
adding 774 points, 260 far (5.712 threshold), 0 inaccurate, 0 invisible, 0 weak
adjusting: xxxxxxxxxx 113.192 -> 112.846
adding 215 points, 227 far (5.712 threshold), 0 inaccurate, 0 invisible, 0 weak
optimized in 0.075 seconds
3 sigma filtering...
adjusting: xxxxxxxxxxxxxxxxxxxx 73.1146 -> 23.1223
point variance: 17.9403
adding 625 points, 5 far (53.8209 threshold), 1 inaccurate, 11 invisible, 0 weak
adjusting: xxxxxxxxx 6.9906 -> 6.45695
point variance: 4.59698
adding 7 points, 60 far (13.791 threshold), 0 inaccurate, 7 invisible, 0 weak
adjusting: xxxxxxxxxxxxxxxxxxxx 5.20477 -> 5.11005
point variance: 2.07277
adding 4 points, 78 far (6.21832 threshold), 0 inaccurate, 4 invisible, 0 weak
adjusting: xxxxxxxxxxxxxxx- 4.99117 -> 4.97316
point variance: 1.28841
adding 5 points, 65 far (3.86522 threshold), 0 inaccurate, 1 invisible, 0 weak
adjusting: xxxxxxxxxxx- 5.04302 -> 5.02462
point variance: 1.01485
adding 15 points, 65 far (3.04454 threshold), 0 inaccurate, 0 invisible, 0 weak
optimized in 0.541 seconds
fx 2207.76, fy 2207.76, cx 1315.48, cy 1628.36, k1 0.0158626, k2 -0.0358551, k3 0.0126521
finished sfm in 2.672 seconds
coordinates applied in 0 sec
Finished processing in 13.02 sec (exit code 1)
It seems that the script:
chunk.matchPhotos(PhotoScan.HighAccuracy, PhotoScan.GenericPreselection, False, 40000, 1000)
chunk.alignCameras()
does not make the same thing that the command "Align photos..." from the workflow menu (even if within the GUI i've the same parameters for the alignment)
Can you help me please ?