-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathlhm.c
1397 lines (1234 loc) · 47.4 KB
/
lhm.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*////////////////////////////////////////////////////////////////////////////////
//
// Pose estimation using the algorithm of Lu, Hager and Mjolsness (LHM)
//
// Copyright (C) 2002-12 Manolis Lourakis (lourakis **at** ics.forth.gr)
// Institute of Computer Science, Foundation for Research & Technology - Hellas
// Heraklion, Crete, Greece.
//
//////////////////////////////////////////////////////////////////////////////// */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>
#include <time.h>
#include "compiler.h"
#include "sam.h"
#include "svd3.h"
#include "posest.h"
#define USE_LQS_FIT 1 // use LQS (LMedS) if 1
#define USE_RANSAC_FIT 0 // use RANSAC if 1
#define USE_PROSAC_FIT 0 // use PROSAC if 1
#if USE_LQS_FIT + USE_RANSAC_FIT + USE_PROSAC_FIT != 1
#error Exactly one of the USE_XXX_FIT macros should be defined as 1!
#endif
#define LHM_RANSAC_OUTL_THRESH 1E-03 // relevant to RANSAC/PROSAC only. This is in normalized coordinates!
#define LHM_TOLERANCE 1E-5 /* convergence tolerance */
#define LHM_EPSILON 1E-8 /* lower bound of objective function */
#define LHM_MAXITER 35 /* maximum number of iterations */
#define _SQR(x) ((x)*(x))
static int lhm_estPose(double (*proj2D)[2], double (*pts3D)[3], double (*wkpts3D)[3], int *ptsidx, int npts, double R[9], double t[3], int verbose);
static int lhm_calcRt(double (*pts0)[3], double (*pts1)[3], int *indx, int npts, double (*V)[9], double Tfact[9], double R[9], double t[3]);
static void lhm_tFromR(double (*pts3D)[3], int *ptsidx, int npts, double (*V)[9], double R[9], double Tfact[9], double t[3]);
static double lhm_objSpaceErr(double (*pts3D)[3], int *ptsidx, int npts, double (*V)[9]);
static double lhm_imgSpaceErr(double (*pts2D)[2], double (*pts3D)[3], int *ptsidx, int npts, double R[9], double t[3]);
/* estimate 3D pose based on the 3D - 2D correspondences specified by pts3D, proj2D.
* 2D points are assumed to be expressed in normalized coordinates, i.e. the effect of
* the camera intrinsics has been canceled out.
* wkpts3D is an auxiliary work array allocated by the caller
* R should contain an initial estimate for the rotation
*
* ptsidx is an index that defines the points that are to be used
* in the estimation. If ptsidx==NULL all points are employed
*
* Upon return, R and t contain the rotation & translation of the estimated
* rigid motion.
*
* The algorithm used for estimating R, t is that by Lu et al.
* Lu, Hager & Mjolsness "Fast and Globally Convergent Pose Estimation
* from Video Images", PAMI (22):6, 2000, pp.613
*
* returns 0 on success, nonzero otherwise
*
*/
static int lhm_estPose(double (*proj2D)[2], double (*pts3D)[3], double (*wkpts3D)[3], int *ptsidx, int npts, double R[9], double t[3], int verbose)
{
double (*V)[9]; /* holds the projection matrices of Eq.(18). Note that V does not use ptsidx for indexing! */
double Tfact[9], tmpm[9], tmpv[3];
register int i, j, k;
int niter;
register double *Vp, *p2, *p3, *wp3;
double mag;
double cur_err=DBL_MAX, old_err;
if((V=(double (*)[9])malloc(npts*sizeof(double[9])))==NULL){
fprintf(stderr, "memory allocation request failed in lhm_estPose()\n");
exit(1);
}
/* clear tmpm */
memset(tmpm, 0, 9*sizeof(double));
/* compute the Vi and tmpm as \sum_k Vk */
if(ptsidx==NULL){ /* no index, use all points */
for(i=0; i<npts; ++i){
p2=proj2D[i];
mag=_SQR(p2[0]) + _SQR(p2[1]) + 1.0;
mag=1.0/mag;
Vp=V[i];
tmpm[0]+=Vp[0]=p2[0]*p2[0]*mag;
tmpm[1]+=Vp[1]=p2[0]*p2[1]*mag;
tmpm[2]+=Vp[2]=p2[0]* 1.0 *mag;
tmpm[3]+=Vp[3]=p2[1]*p2[0]*mag;
tmpm[4]+=Vp[4]=p2[1]*p2[1]*mag;
tmpm[5]+=Vp[5]=p2[1]* 1.0 *mag;
tmpm[6]+=Vp[6]=p2[0]*mag;
tmpm[7]+=Vp[7]=p2[1]*mag;
tmpm[8]+=Vp[8]= 1.0 *mag;
}
}
else{
for(j=0; j<npts; ++j){
i=ptsidx[j];
p2=proj2D[i];
mag=_SQR(p2[0]) + _SQR(p2[1]) + 1.0;
mag=1.0/mag;
Vp=V[j];
tmpm[0]+=Vp[0]=p2[0]*p2[0]*mag;
tmpm[1]+=Vp[1]=p2[0]*p2[1]*mag;
tmpm[2]+=Vp[2]=p2[0]* 1.0 *mag;
tmpm[3]+=Vp[3]=p2[1]*p2[0]*mag;
tmpm[4]+=Vp[4]=p2[1]*p2[1]*mag;
tmpm[5]+=Vp[5]=p2[1]* 1.0 *mag;
tmpm[6]+=Vp[6]=p2[0]*mag;
tmpm[7]+=Vp[7]=p2[1]*mag;
tmpm[8]+=Vp[8]= 1.0 *mag;
}
}
/* compute the first coefficient of Eq.(20):
* 1/n (I - 1/n \sum_k Vk)^-1
*/
/* tmpm is multiplied by n so that its inverse (computed below) is
* implicitly multiplied by 1/n: tmpm = n*(I - 1/n \sum_k Vk)
*/
tmpm[0]=npts - tmpm[0]; tmpm[1]= - tmpm[1]; tmpm[2]= - tmpm[2];
tmpm[3]= - tmpm[3]; tmpm[4]=npts - tmpm[4]; tmpm[5]= - tmpm[5];
tmpm[6]= - tmpm[6]; tmpm[7]= - tmpm[7]; tmpm[8]=npts - tmpm[8];
/* Tfact = 1/n*(I - 1/n \sum_k Vk)^-1 */
sam_inv3x3(tmpm, Tfact);
/* compute the initial estimate of translation */
lhm_tFromR(pts3D, ptsidx, npts, V, R, Tfact, t);
niter=0;
do{
/* transform 3D points using current R, t: wkpts3D = R*pts3D + t */
if(ptsidx==NULL){
for(i=0; i<npts; ++i){
p3=pts3D[i]; wp3=wkpts3D[i];
wp3[0]=R[0]*p3[0] + R[1]*p3[1] + R[2]*p3[2] + t[0];
wp3[1]=R[3]*p3[0] + R[4]*p3[1] + R[5]*p3[2] + t[1];
wp3[2]=R[6]*p3[0] + R[7]*p3[1] + R[8]*p3[2] + t[2];
}
}
else{
for(j=0; j<npts; ++j){
i=ptsidx[j];
p3=pts3D[i]; wp3=wkpts3D[i];
wp3[0]=R[0]*p3[0] + R[1]*p3[1] + R[2]*p3[2] + t[0];
wp3[1]=R[3]*p3[0] + R[4]*p3[1] + R[5]*p3[2] + t[1];
wp3[2]=R[6]*p3[0] + R[7]*p3[1] + R[8]*p3[2] + t[2];
}
}
old_err=cur_err;
cur_err=lhm_objSpaceErr(wkpts3D, ptsidx, npts, V);
/* wkpts3D[k] = V[k] * (R*pts3D[k]+t) */
if(ptsidx==NULL){
for(k=0; k<npts; ++k){
/* tmpv = V[k] * wkpts3D[k] */
Vp=V[k]; wp3=wkpts3D[k];
tmpv[0]=Vp[0]*wp3[0] + Vp[1]*wp3[1] + Vp[2]*wp3[2];
tmpv[1]=Vp[3]*wp3[0] + Vp[4]*wp3[1] + Vp[5]*wp3[2];
tmpv[2]=Vp[6]*wp3[0] + Vp[7]*wp3[1] + Vp[8]*wp3[2];
wp3[0]=tmpv[0]; wp3[1]=tmpv[1]; wp3[2]=tmpv[2];
}
}
else{
for(j=0; j<npts; ++j){
k=ptsidx[j];
/* tmpv = V[j] * wkpts3D[k] */
Vp=V[j]; wp3=wkpts3D[k];
tmpv[0]=Vp[0]*wp3[0] + Vp[1]*wp3[1] + Vp[2]*wp3[2];
tmpv[1]=Vp[3]*wp3[0] + Vp[4]*wp3[1] + Vp[5]*wp3[2];
tmpv[2]=Vp[6]*wp3[0] + Vp[7]*wp3[1] + Vp[8]*wp3[2];
wp3[0]=tmpv[0]; wp3[1]=tmpv[1]; wp3[2]=tmpv[2];
}
}
/* update R,t */
lhm_calcRt(pts3D, wkpts3D, ptsidx, npts, V, Tfact, R, t);
niter++;
} while ((fabs((old_err-cur_err)/old_err) > LHM_TOLERANCE) && (cur_err > LHM_EPSILON) && niter<LHM_MAXITER);
if(verbose){
old_err=sqrt(lhm_imgSpaceErr(proj2D, pts3D, ptsidx, npts, R, t)/(double)npts);
fprintf(stderr, "\n%d iterations, obj space error %.8g -- img space error %.8g\n", niter, sqrt(cur_err/(double)npts), old_err);
}
free(V);
#if 0
if(npts==3){
double K[9]={
3252.33, 0, 650.247, 0, 3256.29, 414.877, 0, 0, 1
};
double x, y, Z, xx, yy;
printf("R, t\n");
printf("%g %g %g\n", R[0], R[1], R[2]);
printf("%g %g %g\n", R[3], R[4], R[5]);
printf("%g %g %g\n", R[6], R[7], R[8]);
printf(" %g %g %g\n\n", t[0], t[1], t[2]);
for(j=0; j<npts; ++j){
i=ptsidx[j];
printf("Point %d: %g %g %g\n", i, pts3D[i][0], pts3D[i][1], pts3D[i][2]);
/* transform point */
x=R[0]*pts3D[i][0] + R[1]*pts3D[i][1] + R[2]*pts3D[i][2] + t[0];
y=R[3]*pts3D[i][0] + R[4]*pts3D[i][1] + R[5]*pts3D[i][2] + t[1];
Z=R[6]*pts3D[i][0] + R[7]*pts3D[i][1] + R[8]*pts3D[i][2] + t[2];
x/=Z; y/=Z;
x=K[0]*x+K[1]*y+K[2];
y= K[4]*y+K[5];
xx=K[0]*proj2D[i][0]+K[1]*proj2D[i][1]+K[2];
yy= K[4]*proj2D[i][1]+K[5];
printf(" %g %g -- %g %g\n", xx, yy, x, y);
}
printf("\n");
}
#endif
return POSEST_OK;
}
/* Estimate the rigid transformation between two point sets using SVD
* If the resulting translation has a T.z<0, R,t are refined to ensure T.z>0
*
* See
* Arun, Huang & Blostein "Least-Squares Fitting of Two 3-D Point Sets",
* PAMI 9:(5), 1987, p. 698-700
* and
* Lu, Hager & Mjolsness "Fast and Globally Convergent Pose Estimation
* from Video Images", PAMI (22):6, 2000, pp.613
*
* An indx!=NULL specifies the indices of corresponding points that should be
* considered; all points are used otherwise (no mismatches are tolerated)
*
* returns 0 on success, nonzero otherwise
*/
static int lhm_calcRt(double (*pts0)[3], double (*pts1)[3], int *indx, int npts, double (*V)[9], double Tfact[9],
double R[9], double t[3])
{
register int i;
double pc[3], qc[3], p[3], q[3], M[3][3], *dptr, one_over_npts, dpsum, dqsum;
double S[3], U[3][3], Vt[3][3];
extern int F77_FUNC(dgesvd)(char *jobu, char *jobvt, int *m, int *n,
double *a, int *lda, double *s, double *u, int *ldu,
double *vt, int *ldvt, double *work, int *lwork, int *info);
if(npts<3){
fprintf(stderr, "At least 3 points are necessary for estimating R, t in lhm_calcRt()! [%d]\n", npts); fflush(stderr);
memset(R, 0, 9*sizeof(double));
memset(t, 0, 3*sizeof(double));
return 1;
}
pc[0]=pc[1]=pc[2]=
qc[0]=qc[1]=qc[2]=0.0;
one_over_npts=1.0/(double)(npts);
dpsum=dqsum=0.0;
M[0][0]=M[0][1]=M[0][2]=
M[1][0]=M[1][1]=M[1][2]=
M[2][0]=M[2][1]=M[2][2]=0.0;
/* Note: LHM erroneously define M in Eq.(13) as \sum_i q'_i*p't_i; the former is
* the transpose of M, M is actually \sum_i p'_i*q't_i. See also Arun et al.
*/
if(!indx){
/* compute centroids */
for(i=0; i<npts; i++){
dptr=pts0[i];
pc[0]+=*dptr++; pc[1]+=*dptr++; pc[2]+=*dptr;
dptr=pts1[i];
qc[0]+=*dptr++; qc[1]+=*dptr++; qc[2]+=*dptr;
}
pc[0]*=one_over_npts; pc[1]*=one_over_npts; pc[2]*=one_over_npts;
qc[0]*=one_over_npts; qc[1]*=one_over_npts; qc[2]*=one_over_npts;
/* compute M from p', q' */
for(i=0; i<npts; i++){
dptr=pts0[i];
p[0]=*dptr++ - pc[0];
p[1]=*dptr++ - pc[1];
p[2]=*dptr - pc[2];
dpsum+=p[0]*p[0] + p[1]*p[1] + p[2]*p[2];
dptr=pts1[i];
q[0]=*dptr++ - qc[0];
q[1]=*dptr++ - qc[1];
q[2]=*dptr - qc[2];
dqsum+=q[0]*q[0] + q[1]*q[1] + q[2]*q[2];
/* compute \sum_i q'_i*p't_i which is M in column major */
M[0][0]+=q[0]*p[0]; M[0][1]+=q[0]*p[1]; M[0][2]+=q[0]*p[2];
M[1][0]+=q[1]*p[0]; M[1][1]+=q[1]*p[1]; M[1][2]+=q[1]*p[2];
M[2][0]+=q[2]*p[0]; M[2][1]+=q[2]*p[1]; M[2][2]+=q[2]*p[2];
}
}
else{
/* compute centroids */
for(i=0; i<npts; i++){
dptr=pts0[indx[i]];
pc[0]+=*dptr++; pc[1]+=*dptr++; pc[2]+=*dptr;
dptr=pts1[indx[i]];
qc[0]+=*dptr++; qc[1]+=*dptr++; qc[2]+=*dptr;
}
pc[0]*=one_over_npts; pc[1]*=one_over_npts; pc[2]*=one_over_npts;
qc[0]*=one_over_npts; qc[1]*=one_over_npts; qc[2]*=one_over_npts;
/* compute M from p', q' */
for(i=0; i<npts; i++){
dptr=pts0[indx[i]];
p[0]=*dptr++ - pc[0];
p[1]=*dptr++ - pc[1];
p[2]=*dptr - pc[2];
dpsum+=p[0]*p[0] + p[1]*p[1] + p[2]*p[2];
dptr=pts1[indx[i]];
q[0]=*dptr++ - qc[0];
q[1]=*dptr++ - qc[1];
q[2]=*dptr - qc[2];
dqsum+=q[0]*q[0] + q[1]*q[1] + q[2]*q[2];
/* compute \sum_i q'_i*p't_i which is M in column major */
M[0][0]+=q[0]*p[0]; M[0][1]+=q[0]*p[1]; M[0][2]+=q[0]*p[2];
M[1][0]+=q[1]*p[0]; M[1][1]+=q[1]*p[1]; M[1][2]+=q[1]*p[2];
M[2][0]+=q[2]*p[0]; M[2][1]+=q[2]*p[1]; M[2][2]+=q[2]*p[2];
}
}
//printf("lhm_calcRt() scale: %g\n", sqrt(dqsum/dpsum)); // see also Eq.(39) in Lu et al.
/* note that M has been computed above in column-major order */
#if 1 // use custom 3x3 SVD
svd3(U[0], S, Vt[0], M[0]);
/* svd3 actually returns V; for compatibility with LAPACK which returns V^T,
* the computed Vt is transposed in place to yield the true Vt
*/
{ double tmp;
tmp=Vt[0][1]; Vt[0][1]=Vt[1][0]; Vt[1][0]=tmp;
tmp=Vt[0][2]; Vt[0][2]=Vt[2][0]; Vt[2][0]=tmp;
tmp=Vt[1][2]; Vt[1][2]=Vt[2][1]; Vt[2][1]=tmp;
}
#else // use generic SVD
{
double work[32]; /* SVD stuff */
int info, three=3, lwork=32; /* probably too much here...*/
F77_FUNC(dgesvd)("A", "A", &three, &three, M[0], &three, S, U[0], &three, Vt[0], &three, work, &lwork, &info);
if(info<0){
fprintf(stderr, "LAPACK error: illegal value for argument %d of dgesvd in lhm_calcRt()\n", -info);
exit(1);
}
else if(info>0){
fprintf(stderr, "LAPACK error: dbdsqr failed to converge in lhm_calcRt();\n%d %s", info,
"superdiagonals of an intermediate bidiagonal form did not converge to zero\n");
memset(R, 0, 9*sizeof(double));
memset(t, 0, 3*sizeof(double));
return 1;
}
}
#endif
/* compute R as V * U^t. Remember that Vt & U are in column major */
R[0]=Vt[0][0]*U[0][0] + Vt[0][1]*U[1][0] + Vt[0][2]*U[2][0];
R[1]=Vt[0][0]*U[0][1] + Vt[0][1]*U[1][1] + Vt[0][2]*U[2][1];
R[2]=Vt[0][0]*U[0][2] + Vt[0][1]*U[1][2] + Vt[0][2]*U[2][2];
R[3]=Vt[1][0]*U[0][0] + Vt[1][1]*U[1][0] + Vt[1][2]*U[2][0];
R[4]=Vt[1][0]*U[0][1] + Vt[1][1]*U[1][1] + Vt[1][2]*U[2][1];
R[5]=Vt[1][0]*U[0][2] + Vt[1][1]*U[1][2] + Vt[1][2]*U[2][2];
R[6]=Vt[2][0]*U[0][0] + Vt[2][1]*U[1][0] + Vt[2][2]*U[2][0];
R[7]=Vt[2][0]*U[0][1] + Vt[2][1]*U[1][1] + Vt[2][2]*U[2][1];
R[8]=Vt[2][0]*U[0][2] + Vt[2][1]*U[1][2] + Vt[2][2]*U[2][2];
/* currently no collinearity check for the p, q. They are collinear
* when two of the singular values are equal
*/
if(sam_det3x3(R)<0){ // R is a reflection, see p. 699 in Arun et al.
if(S[2]>S[0]*1E-3){ // case b): smallest singular value (S[2]) is nonzero
memset(R, 0, 9*sizeof(double));
memset(t, 0, 3*sizeof(double));
return 2;
}
/* case a): change the sign of V's 3rd colun and recompute R */
// R = [V(:, 1:2) -V(:, 3)] * U^t
Vt[0][2]=-Vt[0][2]; Vt[1][2]=-Vt[1][2]; Vt[2][2]=-Vt[2][2];
R[0]=Vt[0][0]*U[0][0] + Vt[0][1]*U[1][0] + Vt[0][2]*U[2][0];
R[1]=Vt[0][0]*U[0][1] + Vt[0][1]*U[1][1] + Vt[0][2]*U[2][1];
R[2]=Vt[0][0]*U[0][2] + Vt[0][1]*U[1][2] + Vt[0][2]*U[2][2];
R[3]=Vt[1][0]*U[0][0] + Vt[1][1]*U[1][0] + Vt[1][2]*U[2][0];
R[4]=Vt[1][0]*U[0][1] + Vt[1][1]*U[1][1] + Vt[1][2]*U[2][1];
R[5]=Vt[1][0]*U[0][2] + Vt[1][1]*U[1][2] + Vt[1][2]*U[2][2];
R[6]=Vt[2][0]*U[0][0] + Vt[2][1]*U[1][0] + Vt[2][2]*U[2][0];
R[7]=Vt[2][0]*U[0][1] + Vt[2][1]*U[1][1] + Vt[2][2]*U[2][1];
R[8]=Vt[2][0]*U[0][2] + Vt[2][1]*U[1][2] + Vt[2][2]*U[2][2];
}
compute_trans:
lhm_tFromR(pts0, indx, npts, V, R, Tfact, t);
if(t[2]<0.0){ // t should be inverted so that object is in front of the camera
// R = -[V(:, 1:2) -V(:, 3)] * U^t
Vt[0][2]=-Vt[0][2]; Vt[1][2]=-Vt[1][2]; Vt[2][2]=-Vt[2][2];
R[0]=-(Vt[0][0]*U[0][0] + Vt[0][1]*U[1][0] + Vt[0][2]*U[2][0]);
R[1]=-(Vt[0][0]*U[0][1] + Vt[0][1]*U[1][1] + Vt[0][2]*U[2][1]);
R[2]=-(Vt[0][0]*U[0][2] + Vt[0][1]*U[1][2] + Vt[0][2]*U[2][2]);
R[3]=-(Vt[1][0]*U[0][0] + Vt[1][1]*U[1][0] + Vt[1][2]*U[2][0]);
R[4]=-(Vt[1][0]*U[0][1] + Vt[1][1]*U[1][1] + Vt[1][2]*U[2][1]);
R[5]=-(Vt[1][0]*U[0][2] + Vt[1][1]*U[1][2] + Vt[1][2]*U[2][2]);
R[6]=-(Vt[2][0]*U[0][0] + Vt[2][1]*U[1][0] + Vt[2][2]*U[2][0]);
R[7]=-(Vt[2][0]*U[0][1] + Vt[2][1]*U[1][1] + Vt[2][2]*U[2][1]);
R[8]=-(Vt[2][0]*U[0][2] + Vt[2][1]*U[1][2] + Vt[2][2]*U[2][2]);
/* recompute t */
goto compute_trans; // new t[2]>0 so goto will not return to this branch
}
return 0;
}
/* compute t given R -- see Eq.(20)
* The first part of this equation is given by Tfact
*/
static void lhm_tFromR(double (*pts3D)[3], int *ptsidx, int npts, double (*V)[9], double R[9], double Tfact[9], double t[3])
{
double sumv[3], tmpv1[3], tmpv2[3], tmpm[9];
register int k, i;
register double *p3, *Vp;
sumv[0]=sumv[1]=sumv[2]=0.0;
/* sumv = \sum_k (Vk - I)*R*pk */
if(ptsidx==NULL){
for(k=0; k<npts; ++k){
/* tmpv1 = R*pk */
p3=pts3D[k];
tmpv1[0]=R[0]*p3[0] + R[1]*p3[1] + R[2]*p3[2];
tmpv1[1]=R[3]*p3[0] + R[4]*p3[1] + R[5]*p3[2];
tmpv1[2]=R[6]*p3[0] + R[7]*p3[1] + R[8]*p3[2];
/* tmpm = (Vk - I) */
Vp=V[k];
tmpm[0]=Vp[0] - 1.0; tmpm[1]=Vp[1] ; tmpm[2]=Vp[2] ;
tmpm[3]=Vp[3] ; tmpm[4]=Vp[4] - 1.0; tmpm[5]=Vp[5] ;
tmpm[6]=Vp[6] ; tmpm[7]=Vp[7] ; tmpm[8]=Vp[8] - 1.0;
/* tmpv2 = tmpm*tmpv1 = (Vk - I)*R*pk */
tmpv2[0]=tmpm[0]*tmpv1[0] + tmpm[1]*tmpv1[1] + tmpm[2]*tmpv1[2];
tmpv2[1]=tmpm[3]*tmpv1[0] + tmpm[4]*tmpv1[1] + tmpm[5]*tmpv1[2];
tmpv2[2]=tmpm[6]*tmpv1[0] + tmpm[7]*tmpv1[1] + tmpm[8]*tmpv1[2];
sumv[0]+=tmpv2[0]; sumv[1]+=tmpv2[1]; sumv[2]+=tmpv2[2];
}
}
else{
for(i=0; i<npts; i++){
k=ptsidx[i];
/* tmpv1 = R*pk */
p3=pts3D[k];
tmpv1[0]=R[0]*p3[0] + R[1]*p3[1] + R[2]*p3[2];
tmpv1[1]=R[3]*p3[0] + R[4]*p3[1] + R[5]*p3[2];
tmpv1[2]=R[6]*p3[0] + R[7]*p3[1] + R[8]*p3[2];
/* tmpm = (Vi - I) */
Vp=V[i];
tmpm[0]=Vp[0] - 1.0; tmpm[1]=Vp[1] ; tmpm[2]=Vp[2] ;
tmpm[3]=Vp[3] ; tmpm[4]=Vp[4] - 1.0; tmpm[5]=Vp[5] ;
tmpm[6]=Vp[6] ; tmpm[7]=Vp[7] ; tmpm[8]=Vp[8] - 1.0;
/* tmpv2 = tmpm*tmpv1 = (Vi - I)*R*pk */
tmpv2[0]=tmpm[0]*tmpv1[0] + tmpm[1]*tmpv1[1] + tmpm[2]*tmpv1[2];
tmpv2[1]=tmpm[3]*tmpv1[0] + tmpm[4]*tmpv1[1] + tmpm[5]*tmpv1[2];
tmpv2[2]=tmpm[6]*tmpv1[0] + tmpm[7]*tmpv1[1] + tmpm[8]*tmpv1[2];
sumv[0]+=tmpv2[0]; sumv[1]+=tmpv2[1]; sumv[2]+=tmpv2[2];
}
}
/* t=Tfact*sumv */
t[0]=Tfact[0]*sumv[0] + Tfact[1]*sumv[1] + Tfact[2]*sumv[2];
t[1]=Tfact[3]*sumv[0] + Tfact[4]*sumv[1] + Tfact[5]*sumv[2];
t[2]=Tfact[6]*sumv[0] + Tfact[7]*sumv[1] + Tfact[8]*sumv[2];
}
/* calculate the object-space collinearity error of Eqs.(17) - (19)
* The 3D points in pts3D are assumed to have been rigidly transformed
* with R, t
*/
static double lhm_objSpaceErr(double (*pts3D)[3], int *ptsidx, int npts, double (*V)[9])
{
double tmpv[3], tmpm[9];
double sum;
register int i, j;
register double *p3, *Vp;
if(ptsidx==NULL){
for(i=0, sum=0.0; i<npts; ++i){
/* tmpm = (I - Vi) */
Vp=V[i];
tmpm[0]=1.0 - Vp[0]; tmpm[1]= - Vp[1]; tmpm[2]= - Vp[2];
tmpm[3]= - Vp[3]; tmpm[4]=1.0 - Vp[4]; tmpm[5]= - Vp[5];
tmpm[6]= - Vp[6]; tmpm[7]= - Vp[7]; tmpm[8]=1.0 - Vp[8];
/* tmpv = (I - Vi)*Pi */
p3=pts3D[i];
tmpv[0]=tmpm[0]*p3[0] + tmpm[1]*p3[1] + tmpm[2]*p3[2];
tmpv[1]=tmpm[3]*p3[0] + tmpm[4]*p3[1] + tmpm[5]*p3[2];
tmpv[2]=tmpm[6]*p3[0] + tmpm[7]*p3[1] + tmpm[8]*p3[2];
sum+=_SQR(tmpv[0]) + _SQR(tmpv[1]) + _SQR(tmpv[2]);
}
}
else{
for(j=0, sum=0.0; j<npts; j++){
i=ptsidx[j];
/* tmpm = (I - Vj) */
Vp=V[j];
tmpm[0]=1.0 - Vp[0]; tmpm[1]= - Vp[1]; tmpm[2]= - Vp[2];
tmpm[3]= - Vp[3]; tmpm[4]=1.0 - Vp[4]; tmpm[5]= - Vp[5];
tmpm[6]= - Vp[6]; tmpm[7]= - Vp[7]; tmpm[8]=1.0 - Vp[8];
/* tmpv = (I - Vj)*Pi */
p3=pts3D[i];
tmpv[0]=tmpm[0]*p3[0] + tmpm[1]*p3[1] + tmpm[2]*p3[2];
tmpv[1]=tmpm[3]*p3[0] + tmpm[4]*p3[1] + tmpm[5]*p3[2];
tmpv[2]=tmpm[6]*p3[0] + tmpm[7]*p3[1] + tmpm[8]*p3[2];
sum+=_SQR(tmpv[0]) + _SQR(tmpv[1]) + _SQR(tmpv[2]);
}
}
return sum;
}
/* calculate the image-space error of Eq.(8)
* The 3D points in pts3D should be first
* rigidly transformed with R, t. Recall that
* pts2D are normalized
*/
static double lhm_imgSpaceErr(double (*pts2D)[2], double (*pts3D)[3], int *ptsidx, int npts, double R[9], double t[3])
{
register int i, j;
register double sum, x, y, Z;
register double *p3, *p2;
sum=0.0;
if(ptsidx==NULL){
for(i=0; i<npts; ++i){
/* transform 3D point */
p3=pts3D[i];
x=R[0]*p3[0] + R[1]*p3[1] + R[2]*p3[2] + t[0];
y=R[3]*p3[0] + R[4]*p3[1] + R[5]*p3[2] + t[1];
Z=R[6]*p3[0] + R[7]*p3[1] + R[8]*p3[2] + t[2];
/* project 3D point */
x/=Z;
y/=Z;
p2=pts2D[i];
x-=p2[0];
y-=p2[1];
sum+=_SQR(x) + _SQR(y);
}
}
else{
for(j=0; j<npts; ++j){
i=ptsidx[j];
/* transform 3D point */
p3=pts3D[i];
x=R[0]*p3[0] + R[1]*p3[1] + R[2]*p3[2] + t[0];
y=R[3]*p3[0] + R[4]*p3[1] + R[5]*p3[2] + t[1];
Z=R[6]*p3[0] + R[7]*p3[1] + R[8]*p3[2] + t[2];
/* project 3D point */
x/=Z;
y/=Z;
p2=pts2D[i];
x-=p2[0];
y-=p2[1];
/* this converts the error to pixels:
x=K[0]*x + K[1]*y;
y= K[4]*y;
*/
sum+=_SQR(x) + _SQR(y);
}
}
return sum;
}
/*********************************** Robust pose estimation with the LHM algorithm ***************************************/
#include "lqs.h"
#include "ransac.h"
#include "prosac.h"
/* variables used by various estimation routines */
struct LHMPoseData {
double (*pts2D)[2], (*pts3D)[3], (*wrk)[3];
double R0[9]; // initial estimate for rotation, used only if supplied externally
int *inliersidx, numInliers, howtoinit;
};
/* estimate pose. p2=K[R t]*P3, with p2, P3 specified by ptsidx */
static int estLHMPose(double *Rt, int npts, int *ptsidx, void *adata)
{
register int i, j;
int n, verb=0;
struct LHMPoseData *dat=(struct LHMPoseData *)adata;
double (*pts2D)[2]=dat->pts2D, (*pts3D)[3]=dat->pts3D, (*wrk)[3]=dat->wrk;
register double *p2;
double dummy;
switch(dat->howtoinit){
case LHM_INITR_WEAKP:
/* initialize rotation using the weak perspective approximation:
* consider the set of image points as coplanar 3D points
*/
if(ptsidx==NULL){ /* no index, use all points */
for(i=0; i<npts; ++i){
p2=pts2D[i];
wrk[i][0]=p2[0];
wrk[i][1]=p2[1];
wrk[i][2]=1.0;
}
}
else{
for(j=0; j<npts; ++j){
i=ptsidx[j];
p2=pts2D[i];
wrk[i][0]=p2[0];
wrk[i][1]=p2[1];
wrk[i][2]=1.0;
}
}
n=sam_absorq(pts3D, wrk, ptsidx, npts, Rt, NULL, &dummy); // t need not be estimated here, use of "dummy" avoids scale warnings
if(n) return 0; // could not initialize
break;
case LHM_INITR_IDENT:
default:
/* trivial initialization: eye(3) */
Rt[0]=1.0; Rt[1]=0.0; Rt[2]=0.0;
Rt[3]=0.0; Rt[4]=1.0; Rt[5]=0.0;
Rt[6]=0.0; Rt[7]=0.0; Rt[8]=1.0;
break;
case LHM_INITR_SUPPLIED:
/* use supplied R */
memcpy(Rt, dat->R0, 9*sizeof(double));
break;
}
n=lhm_estPose(pts2D, pts3D, wrk, ptsidx, npts, Rt, Rt+9, verb);
return n==POSEST_OK;
}
/* compute the geometric residuals corresponding to Rt as the (squared) reprojection error */
static void poseRT_LHM_ResidualsGeom(double *Rt, int numres, void *adata, double *resid)
{
register int i;
double *R, *t, X, Y, Z, dx, dy;
struct LHMPoseData *dat=(struct LHMPoseData *)adata;
double (*pts2D)[2]=dat->pts2D, (*pts3D)[3]=dat->pts3D;
register double *pt; // pts3D[i] or pts2D[i]
R=Rt; t=R+9;
for(i=0; i<numres; ++i){
/* transform point */
pt=pts3D[i];
X=(R[0]*pt[0] + R[1]*pt[1]) + (R[2]*pt[2] + t[0]);
Y=(R[3]*pt[0] + R[4]*pt[1]) + (R[5]*pt[2] + t[1]);
Z=(R[6]*pt[0] + R[7]*pt[1]) + (R[8]*pt[2] + t[2]);
/* note that K is not needed below since pts2D have been normalized! */
pt=pts2D[i];
dx=pt[0] - X/Z;
dy=pt[1] - Y/Z;
resid[i]=_SQR(dx) + _SQR(dy);
}
}
/* Robust pose estimation from "nmatches" matched 2D-3D point correspondences, possibly
* including outliers, using the LHM algorithm. "pts2D", "pts3D" contain the matched 2D-3D
* point coordinates, "inlPcent" is the expected percentage of inliers (>=0.5),
* "p" contains the estimated parameters upon return, idxOutliers" points to sufficiently
* large memory which upon return is set to the indices of the detected outlying points (pass
* NULL if don't care), "nbOutliers" contains the number of outliers, "verbose" specifies the
* verbosity level
*
* Returns 1 in case of error, 0 if successfull
*
*/
int posestRT_LHM(double (*pts2D)[2], double (*pts3D)[3], int nmatches, double inlPcent, double K[9],
int howtoinit, double p[NUM_RTPARAMS], int *idxOutliers, int *nbOutliers, int verbose)
{
register int i;
const int min_nmatches=3;
int ret;
struct LHMPoseData dat;
double Rt[9+3]; // layout is R (3x3), t (1x3)
double (*wrk)[3], K1[9], *p2;
if(nmatches<min_nmatches) return 1; // too few matches
/* invert K in K1 */
K1[0]=1.0/K[0]; K1[1]=-K[1]/K[0]/K[4]; K1[2]=(K[1]*K[5]-K[2]*K[4])/K[0]/K[4];
K1[3]=0.0; K1[4]=1.0/K[4]; K1[5]=-K[5]/K[4];
//K1[6]=0.0; K1[7]=0.0; K1[8]=1.0; // last row of K assumed [0 0 1]
/* use K^-1 to convert the supplied pixel coordinates to normalized ones.
* Note that the input 2D points are overwritten (and restored before return)
*/
for(i=0; i<nmatches; ++i){
p2=pts2D[i];
p2[0]=K1[0]*p2[0] + K1[1]*p2[1] + K1[2];
p2[1]= K1[4]*p2[1] + K1[5]; // K1[3]==0
}
/* working memory */
if((wrk=(double (*)[3])malloc(nmatches*sizeof(double[3])))==NULL){
fprintf(stderr, "memory allocation request failed in posestRT_LHM()\n");
exit(1);
}
dat.pts2D=pts2D; dat.pts3D=pts3D;
dat.wrk=wrk;
dat.inliersidx=NULL;
dat.howtoinit=howtoinit;
if(howtoinit==LHM_INITR_SUPPLIED) sam_vec2rotmat(p, dat.R0); // store supplied initial R
if(inlPcent!=1.0){ // robust version
register int j;
double gate=2.0, premResid=-1.0, outlierThresh=LHM_RANSAC_OUTL_THRESH; // outlierThresh: distance threshold for outliers (RANSAC/PROSAC only)
int *outliersMap, **sets=NULL, nbSets=0;
const int isSqr=1, maxNbSol=1, nparams=9+3;
int (*estimator)(double *Rt, int npts, int *ptsidx, void *adata);
void (*residuals)(double *Rt, int numres, void *adata, double *resid);
estimator=estLHMPose;
residuals=poseRT_LHM_ResidualsGeom;
if(!(outliersMap=(int *)malloc(nmatches*sizeof(int)))){
fprintf(stderr, "Error: not enough memory for 'outliersMap' in posestRT_LHM()\n");
exit(1);
}
verbose=verbose>1;
#if USE_LQS_FIT==1
j=lqsfit(nmatches, min_nmatches, sets, nbSets, residuals, estimator,
isSqr, verbose, maxNbSol, gate, premResid, nparams, inlPcent, (void *)&dat,
Rt, NULL, outliersMap, nbOutliers, &outlierThresh);
#elif (USE_RANSAC_FIT==1) || (USE_PROSAC_FIT==1)
gate=premResid=0; /* -Wall */
#if USE_RANSAC_FIT==1
j=ransacfit(nmatches, min_nmatches, sets, nbSets, residuals, estimator,
isSqr, verbose, maxNbSol, outlierThresh, 0, nparams, inlPcent, (void *)&dat,
Rt, NULL, outliersMap, nbOutliers);
#else
j=prosacfit(nmatches, min_nmatches, residuals, estimator,
isSqr, verbose, maxNbSol, outlierThresh, 0, nparams, inlPcent, (void *)&dat,
Rt, NULL, outliersMap, nbOutliers);
#endif
#endif /* USE_LQS_FIT */
if(verbose){
fprintf(stderr, "Outlier threshold: %g\n", outlierThresh);
fprintf(stderr, "posestRT_LHM(): robust fit returned %d, %d outliers [out of %d]\n", j, *nbOutliers, nmatches);
}
if(sets) lqs_freesets(sets);
dat.numInliers=nmatches - *nbOutliers;
if(j!=0){
dat.inliersidx=(int *)malloc(dat.numInliers*sizeof(int));
if(!dat.inliersidx){
fprintf(stderr, "Error: not enough memory for 'dat.inliersidx' in posestRT_LHM()\n");
exit(1);
}
for(i=j=0; i<nmatches; ++i)
if(!outliersMap[i]) dat.inliersidx[j++]=i;
/* LS estimation on inliers */
estimator(Rt, dat.numInliers, dat.inliersidx, (void *)&dat);
/* expose outliers */
if(idxOutliers!=NULL)
for(i=j=0; i<nmatches; ++i)
if(outliersMap[i]) idxOutliers[j++]=i;
#if 0
if(verbose){
fputs("Outliers: ", stderr);
for(i=j=0; i<nmatches; ++i)
if(outliersMap[i]) fprintf(stderr, "%d ", i);
fputc('\n', stderr);
}
#endif
ret=POSEST_OK;
#if 0
/* include the following code fragment to print the matching 3D-2D point pairs found to be inlying */
for(i=0; i<dat.numInliers; ++i){
printf("%.6lf %.6lf %.6lf %.4lf %.4lf\n", pts3D[dat.inliersidx[i]][0], pts3D[dat.inliersidx[i]][1], pts3D[dat.inliersidx[i]][2],
pts2D[dat.inliersidx[i]][0], pts2D[dat.inliersidx[i]][1]);
}
#endif
}
else{ /* robust fit failed */
memset(Rt, 0, nparams*sizeof(double));
*nbOutliers=nmatches;
dat.numInliers=0;
ret=POSEST_ERR;
}
if(dat.inliersidx) free(dat.inliersidx);
free(outliersMap);
}
else{ // use all matches
*nbOutliers=0;
//ret=lhm_estPose(pts2D, pts3D, wrk, NULL, nmatches, Rt, Rt+9, verbose);
ret=(estLHMPose(Rt, nmatches, NULL, (void *)&dat)==1)? POSEST_OK : POSEST_ERR; // as above plus R initialization
}
#if 0
if(sam_det3x3(Rt)<0.0) // R is a reflection, negate Rt
for(i=0; i<12; ++i) Rt[i]=-Rt[i];
#endif
/* convert to rotation vector and copy */
sam_rotmat2vec(Rt, p); // R
p[3]=Rt[9]; p[4]=Rt[10]; p[5]=Rt[11]; // t
/* undo the normalization with K^-1 and restore input points */
for(i=0; i<nmatches; ++i){
p2=pts2D[i];
p2[0]=K[0]*p2[0] + K[1]*p2[1] + K[2];
p2[1]= K[4]*p2[1] + K[5]; // K[3]==0
}
free(wrk);
return ret;
}
/*********************************** Robust pose estimation with the LHM algorithm ***************************************/
#if 0
main()
{
clock_t start_time, end_time;
#if 0
#define N 25
double pts2D[N][2]={
-695.433721377876, 1105.9792763002,
206.524561488808, 666.245576686066,
206.458530505325, 917.498753384862,
228.891354266207, 489.747375125415,
-798.53305274582, 1663.78347211428,
-536.235256193386, 923.334023406567,
-167.273389130415, 201.303060501723,
105.985487441951, 349.326654443714,
22.326819944374, 482.104332456162,
126.15302427832, 902.198507139287,
-44.6299914800215, 392.744863236346,
-26.9224900580949, 405.723119735403,
-30194.2108405043, 10681.3215715422,
-785.692461363758, 824.649666201522,
133.155015689277, 227.772052062493,
39.3948648858497, 102.023493766942,
95.1366349699194, 477.304114250089,
142.125057435593, 737.190443614491,
-403.188742015687, 474.272676732881,
-162.183920738888, 222.638796949274,
-115.049703946065, 92.3402791937369,
-288.603106211099, 580.862649144927,
192.009174920585, 883.094665293152,
-450.283861419754, 117.802601486909,
-426.03173907901, 784.028945507316,
};
double pts3D[N][3]={
{68.1335, 66.5823, 13.4718},
{2.2493, 26.2199, 11.6515},
{6.9318, 85.2930, 18.0331},
{3.2419, 73.3926, 53.6517},
{27.6030, 36.8458, 1.2886},
{88.9206, 86.6021, 25.4247},
{56.9481, 15.9265, 59.4364},
{33.1100, 65.8613, 86.3634},
{56.7623, 98.0481, 79.1832},
{15.2594, 83.3027, 19.1863},
{63.8987, 66.9000, 77.2088},
{37.9818, 44.1585, 48.3060},
{60.8106, 17.5996, 0.2026},
{79.0224, 51.3609, 21.3229},
{10.3450, 15.7337, 40.7515},
{40.7757, 5.2693, 94.1815},
{14.9972, 38.4374, 31.1059},
{16.8534, 89.6648, 32.2724},
{73.3996, 41.0904, 39.9794},
{50.5522, 16.9306, 52.4745},
{64.1203, 1.6197, 83.6852},
{80.3462, 69.7785, 46.1888},
{8.2613, 82.0717, 19.3020},
{44.5355, 1.2958, 30.8742},
{87.5351, 83.5259, 33.3095},
};
double K[9]={
394.2054307, 0, 256,
0, 394.2054307, 192,
0, 0, 1};
#endif
#if 1
// outliers included
#define N 195
double pts2D[N][2]={
{3.2042383e+02, 6.2678540e+02},
{3.1401236e+02, 6.3092230e+02},
{3.1171075e+02, 6.4624512e+02},
{3.3232681e+02, 6.4502295e+02},
{3.3020486e+02, 6.9652472e+02},
{3.2563989e+02, 6.7685614e+02},
{2.9381891e+02, 6.4272961e+02},
{3.5625665e+02, 6.8932257e+02},
{3.4925406e+02, 6.6554376e+02},
{3.2724851e+02, 6.1521417e+02},
{3.3409604e+02, 6.7707788e+02},
{3.2529886e+02, 6.5170502e+02},
{3.4318426e+02, 6.6778339e+02},
{3.3701782e+02, 6.5472070e+02},
{3.0310031e+02, 6.3624560e+02},
{3.0657693e+02, 6.7567895e+02},
{3.1699576e+02, 6.9266046e+02},
{3.3685211e+02, 6.0570935e+02},
{3.4216580e+02, 6.1189099e+02},
{3.2025241e+02, 6.1559100e+02},
{3.1345343e+02, 6.1299756e+02},
{3.3054767e+02, 6.5632629e+02},
{3.1545798e+02, 6.6174536e+02},
{3.0293677e+02, 6.4467120e+02},
{3.3008374e+02, 6.0739557e+02},
{3.3409604e+02, 6.7707788e+02},
{3.0862061e+02, 7.0099652e+02},