6 #include <schroedinger/schro.h>
7 #include <schroedinger/schromotion.h>
8 #include <schroedinger/schrodebug.h>
14 #define OIL_ENABLE_UNSTABLE_API
15 #include <liboil/liboilrandom.h>
19 test_full_field (int width
, int height
, double *a
, double *b
, int r
, int hole
)
22 SchroMotionVector
*mv
;
27 mf
= schro_motion_field_new (100, 80, 0);
29 printf("test_full_field: r=%d hole=%d\n"
30 "[%6.4f %6.4f %6.4f %6.4f] [%g %g]\n",
32 a
[0], a
[1], a
[2], a
[3], b
[0], b
[1]);
33 for(j
=0;j
<mf
->y_num_blocks
;j
++){
34 for(i
=0;i
<mf
->x_num_blocks
;i
++){
35 mv
= mf
->motion_vectors
+ j
*mf
->x_num_blocks
+ i
;
37 mv
->dx
[0] = rint((a
[0]-1)*8*i
+ a
[1]*8*j
+ b
[0] + r
* oil_rand_f64());
38 mv
->dy
[0] = rint(a
[2]*8*i
+ (a
[3]-1)*8*j
+ b
[1] + r
* oil_rand_f64());
39 if (hole
&& abs(mf
->y_num_blocks
/2 - j
) < 10 &&
40 abs(mf
->x_num_blocks
/2 - i
) < 10) {
46 schro_motion_field_global_estimation (mf
, &gm
, 0);
49 printf("[%6.4f %6.4f %6.4f %6.4f] [%d %d]\n", gm
.a00
/mult
, gm
.a01
/mult
,
50 gm
.a10
/mult
, gm
.a11
/mult
, gm
.b0
, gm
.b1
);
52 if (fabs(gm
.a00
/mult
- a
[0]) > 0.01) return 0;
53 if (fabs(gm
.a01
/mult
- a
[1]) > 0.01) return 0;
54 if (fabs(gm
.a10
/mult
- a
[2]) > 0.01) return 0;
55 if (fabs(gm
.a11
/mult
- a
[3]) > 0.01) return 0;
56 if (fabs(gm
.b0
- b
[0]) > 1) return 0;
57 if (fabs(gm
.b1
- b
[1]) > 1) return 0;
63 double matrices
[][6] = {
64 { 1.0, 0.0, 0.0, 1.0, 1.0, 0.0 },
65 { 1.0, 0.0, 0.0, 1.0, 0.0, 1.0 },
66 { 1.1, 0.0, 0.0, 1.0, 0.0, 0.0 },
67 { 1.0, 0.1, 0.0, 1.0, 0.0, 0.0 },
68 { 1.0, 0.0, 0.1, 1.0, 0.0, 0.0 },
69 { 1.0, 0.0, 0.0, 1.1, 0.0, 0.0 }
73 main (int argc
, char *argv
[])
80 test_full_field(720/8, 576/8, matrices
[i
], matrices
[i
] + 4, 0, 0);
81 test_full_field(720/8, 576/8, matrices
[i
], matrices
[i
] + 4, 1, 0);
82 test_full_field(720/8, 576/8, matrices
[i
], matrices
[i
] + 4, 0, 1);