From: <pan...@li...> - 2013-03-17 07:08:26
|
branch: details: http://panotools.hg.sourceforge.net/hgweb/panotools/panotools/hgroot/panotools/libpano/rev/4b93725a1f29 changeset: 781:4b93725a1f29 user: tmodes date: Sun Mar 17 08:08:09 2013 +0100 description: Moved test parameter 0 and 1 to Tpy and Tpr diffstat: PTcommon.c | 2 ++ adjust.c | 32 ++++++++++++++++++++++++++++---- correct.c | 4 +++- dump.c | 2 ++ filter.h | 4 +++- math.c | 12 ++++++------ panorama.h | 3 ++- parser.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 8 files changed, 98 insertions(+), 14 deletions(-) diffs (308 lines): diff -r 253c1bcde35e -r 4b93725a1f29 PTcommon.c --- a/PTcommon.c Sun Mar 17 08:06:20 2013 +0100 +++ b/PTcommon.c Sun Mar 17 08:08:09 2013 +0100 @@ -1956,6 +1956,8 @@ printf(">>>im->cP.trans_x %f\n", im->cP.trans_x); printf(">>>im->cP.trans_y %f\n", im->cP.trans_y); printf(">>>im->cP.trans_z %f\n", im->cP.trans_z); + printf(">>>im->cP.trans_yaw %n", im->cP.trans_yaw); + printf(">>>im->cP.trans_pitch %f\n", im->cP.trans_pitch); printf(">>>im->cP.test %d\n", im->cP.test); printf(">>>im->cP.test parm1 %f\n", im->cP.test_p0); diff -r 253c1bcde35e -r 4b93725a1f29 adjust.c --- a/adjust.c Sun Mar 17 08:06:20 2013 +0100 +++ b/adjust.c Sun Mar 17 08:08:09 2013 +0100 @@ -87,6 +87,8 @@ printf("trans[0] %f\n", mp->trans[0]); printf("trans[1] %f\n", mp->trans[1]); printf("trans[2] %f\n", mp->trans[2]); + printf("trans[3] %f\n", mp->trans[3]); + printf("trans[4] %f\n", mp->trans[4]); printf("test[0] %f\n", mp->test[0]); printf("test[1] %f\n", mp->test[1]); @@ -853,7 +855,8 @@ mp->trans[0] = im->cP.trans_x; mp->trans[1] = im->cP.trans_y; mp->trans[2] = im->cP.trans_z; - + mp->trans[3] = DEG_TO_RAD(im->cP.trans_yaw); + mp->trans[4] = DEG_TO_RAD(im->cP.trans_pitch); mp->test[0] = im->cP.test_p0; mp->test[1] = im->cP.test_p1; @@ -1309,6 +1312,8 @@ mp->trans[0] = im->cP.trans_x; mp->trans[1] = im->cP.trans_y; mp->trans[2] = im->cP.trans_z; + mp->trans[3] = DEG_TO_RAD(im->cP.trans_yaw); + mp->trans[4] = DEG_TO_RAD(im->cP.trans_pitch); mp->test[0] = im->cP.test_p0; mp->test[1] = im->cP.test_p1; @@ -2677,6 +2682,18 @@ if( k == 1 ){ optInfo->im[i].cP.trans_z = x[j++]; }else{ optInfo->im[i].cP.trans_z = optInfo->im[k-2].cP.trans_z;} } + if( (k = optInfo->opt[i].transYawOpt) > 0 ){ + if( k == 1 ) { optInfo->im[i].cP.trans_yaw = x[j++]; //NORM_ANGLE(optInfo->im[i].cP.trans_yaw); + while( optInfo->im[i].cP.trans_yaw > optInfo->im[i].yaw + 80) optInfo->im[i].cP.trans_yaw -= 180.0; + while( optInfo->im[i].cP.trans_yaw < optInfo->im[i].yaw - 80) optInfo->im[i].cP.trans_yaw += 180.0; + } else { optInfo->im[i].cP.trans_yaw = optInfo->im[k-2].cP.trans_yaw;} + } + if( (k = optInfo->opt[i].transPitchOpt) > 0 ){ + if( k == 1 ){ optInfo->im[i].cP.trans_pitch = x[j++]; //NORM_ANGLE(optInfo->im[i].cP.trans_pitch); + while( optInfo->im[i].cP.trans_pitch > optInfo->im[i].pitch + 80) optInfo->im[i].cP.trans_pitch -= 180.0; + while( optInfo->im[i].cP.trans_pitch < optInfo->im[i].pitch - 80) optInfo->im[i].cP.trans_pitch += 180.0; + }else{ optInfo->im[i].cP.trans_pitch = optInfo->im[k-2].cP.trans_pitch;} + } // test if( (k = optInfo->opt[i].testP0opt) > 0 ){ if( k == 1 ){ optInfo->im[i].cP.test_p0 = x[j++]; @@ -2775,12 +2792,19 @@ if(optInfo->opt[i].transXopt == 1) { // optimize trans_x? 0-no 1-yes x[j++] = optInfo->im[i].cP.trans_x ; } - if(optInfo->opt[i].transYopt == 1) // optimize trans_y? 0-no 1-yes + if(optInfo->opt[i].transYopt == 1) { // optimize trans_y? 0-no 1-yes x[j++] = optInfo->im[i].cP.trans_y ; - + } if(optInfo->opt[i].transZopt == 1) { // optimize trans_Z? 0-no 1-yes x[j++] = optInfo->im[i].cP.trans_z ; } + if(optInfo->opt[i].transYawOpt == 1) { // optimize trans_yaw? 0-no 1-yes + x[j++] = optInfo->im[i].cP.trans_yaw ; + } + if(optInfo->opt[i].transPitchOpt == 1) { // optimize trans_pitch? 0-no 1-yes + x[j++] = optInfo->im[i].cP.trans_pitch ; + } + // Test if(optInfo->opt[i].testP0opt == 1) { x[j++] = optInfo->im[i].cP.test_p0; ; @@ -2935,7 +2959,7 @@ opt->hfov = opt->yaw = opt->pitch = opt->roll = 0; opt->a = opt->b = opt->c = opt->d = opt->e = 0; opt->tiltXopt = opt->tiltYopt = opt->tiltZopt = opt->tiltScaleOpt = 0; - opt->transXopt = opt->transYopt = opt->transZopt = 0; + opt->transXopt = opt->transYopt = opt->transZopt = opt->transYawOpt = opt->transPitchOpt = 0; opt->testP0opt = opt->testP1opt = opt->testP2opt = opt->testP3opt = 0; opt->shear_x = opt->shear_y = 0; } diff -r 253c1bcde35e -r 4b93725a1f29 correct.c --- a/correct.c Sun Mar 17 08:06:20 2013 +0100 +++ b/correct.c Sun Mar 17 08:08:09 2013 +0100 @@ -915,7 +915,9 @@ prefs->trans_x = 0; prefs->trans_y = 0; prefs->trans_z = 0; - + prefs->trans_yaw = 0; + prefs->trans_pitch = 0; + prefs->test = FALSE; prefs->test_p0 = 0; prefs->test_p1 = 0; diff -r 253c1bcde35e -r 4b93725a1f29 dump.c --- a/dump.c Sun Mar 17 08:06:20 2013 +0100 +++ b/dump.c Sun Mar 17 08:08:09 2013 +0100 @@ -134,6 +134,8 @@ PRINT_F(trans_x); PRINT_F(trans_y); PRINT_F(trans_z); + PRINT_F(trans_yaw); + PRINT_F(trans_pitch); } if (cP->test) { diff -r 253c1bcde35e -r 4b93725a1f29 filter.h --- a/filter.h Sun Mar 17 08:06:20 2013 +0100 +++ b/filter.h Sun Mar 17 08:08:09 2013 +0100 @@ -187,6 +187,8 @@ int transXopt; int transYopt; int transZopt; + int transYawOpt; + int transPitchOpt; int testP0opt; int testP1opt; @@ -370,7 +372,7 @@ // Tilt double tilt[4]; // 0 around x, 1 around y, 2 around z, 3 scaling factor // Translation of camera plane - double trans[3]; + double trans[5]; // 0 x, 1 y, 2 z, 3 yaw, 4 pitch // For testing new projections double test[4]; diff -r 253c1bcde35e -r 4b93725a1f29 math.c --- a/math.c Sun Mar 17 08:06:20 2013 +0100 +++ b/math.c Sun Mar 17 08:08:09 2013 +0100 @@ -2133,7 +2133,7 @@ cart_erect(x_dest, y_dest, &p2[0], mp->distance); // compute plane description - cart_erect(DEG_TO_RAD(mp->test[0]), -DEG_TO_RAD(mp->test[1]), + cart_erect(mp->trans[3], -mp->trans[4], &plane_coeff[0], 1.0); // plane_coeff[0..2] is both the normal and a point @@ -2144,7 +2144,7 @@ /* printf("Plane: y:%f p:%f coefficients: %f %f %f %f, ray direction: %f %f %f\n", - mp->test[0], mp->test[1], plane_coeff[0], plane_coeff[1], plane_coeff[2], plane_coeff[3], + mp->trans[3], mp->trans[4], plane_coeff[0], plane_coeff[1], plane_coeff[2], plane_coeff[3], p2[0],p2[1],p2[2]); */ @@ -2165,7 +2165,7 @@ /* printf("pano->plane->cam(%.1f, %.1f, %.1f, y:%1f,p:%1f): %8.5f %8.5f -> %8.5f %8.5f %8.5f -> %8.5f %8.5f\n", - mp->trans[0], mp->trans[1], mp->trans[2], mp->test[0], mp->test[1], + mp->trans[0], mp->trans[1], mp->trans[2], mp->trans[3], mp->trans[4], x_dest, y_dest, intersection[0], intersection[1], intersection[2], *x_src, *y_src); @@ -2202,7 +2202,7 @@ // compute plane description - cart_erect(DEG_TO_RAD(mp->test[0]), -DEG_TO_RAD(mp->test[1]), + cart_erect(mp->trans[3], -mp->trans[4], &plane_coeff[0], 1.0); // plane_coeff[0..2] is both the normal and a point @@ -2213,7 +2213,7 @@ /* printf("Plane: y:%f p:%f coefficients: %f %f %f %f, ray direction: %f %f %f\n", - mp->test[0], mp->test[1], plane_coeff[0], plane_coeff[1], plane_coeff[2], plane_coeff[3], + mp->trans[3], mp->trans[4], plane_coeff[0], plane_coeff[1], plane_coeff[2], plane_coeff[3], p2[0],p2[1],p2[2]); */ @@ -2232,7 +2232,7 @@ /* printf("cam->plane->pano(%.1f, %.1f, %.1f, y:%1f,p:%1f): %8.5f %8.5f -> %8.5f %8.5f %8.5f -> %8.5f %8.5f\n", - mp->trans[0], mp->trans[1], mp->trans[2], mp->test[0], mp->test[1], + mp->trans[0], mp->trans[1], mp->trans[2], mp->trans[3], mp->trans[4], x_dest, y_dest, intersection[0], intersection[1], intersection[2], *x_src, *y_src); diff -r 253c1bcde35e -r 4b93725a1f29 panorama.h --- a/panorama.h Sun Mar 17 08:06:20 2013 +0100 +++ b/panorama.h Sun Mar 17 08:08:09 2013 +0100 @@ -190,7 +190,8 @@ double trans_x; // x component of translation vector double trans_y; // y component of translation vector double trans_z; // z component of translation vector - + double trans_yaw; // yaw of remapping plane for translation + double trans_pitch; // pitch of remapping plane for translation int test; // these parameters are for testing new projections double test_p0; // and make it easier for others to experiment diff -r 253c1bcde35e -r 4b93725a1f29 parser.c --- a/parser.c Sun Mar 17 08:06:20 2013 +0100 +++ b/parser.c Sun Mar 17 08:08:09 2013 +0100 @@ -415,6 +415,21 @@ im->cP.trans = TRUE; } break; + case 'p': // Translation remap plane + li++; + switch (*li) { + case 'y': + li = panoParseVariable(buf, li, lineNum, &(opt->transYawOpt), &(im->cP.trans_yaw)); + break; + case 'p': + li = panoParseVariable(buf, li, lineNum, &(opt->transPitchOpt), &(im->cP.trans_pitch)); + break; + default: + PrintError("Unknown translation parameter Tp%c in script: Line %d", *li, lineNum); + return -1; + } + if (li == NULL) return -1; + break; case 'e': // test parameters li++; switch (*li) { @@ -606,6 +621,20 @@ return -1; } break; + case 'p': + li++; + switch (*li) { + case 'y': + READ_OPT_VAR(transYawOpt); + break; + case 'p': + READ_OPT_VAR(transPitchOpt); + break; + default: + PrintError("Unknown variable name to optimize Tp%c in script: Line %d", *li, lineNum); + return -1; + } + break; case 'e': li++; switch (*li) { @@ -852,6 +881,12 @@ k = gl->opt[i].transZopt - 2; if( k >= 0 ) gl->im[i].cP.trans_z = gl->im[ k ].cP.trans_z; + k = gl->opt[i].transYawOpt - 2; + if( k >= 0 ) gl->im[i].cP.trans_yaw = gl->im[ k ].cP.trans_yaw; + + k = gl->opt[i].transPitchOpt - 2; + if( k >= 0 ) gl->im[i].cP.trans_pitch = gl->im[ k ].cP.trans_pitch; + // test variables ---------------------------------------------------------------------- k = gl->opt[i].testP0opt - 2; @@ -1013,6 +1048,8 @@ g->im[i].cP.trans_x, (g->opt[i].transXopt ? '*':'p'), g->im[i].cP.trans_y, (g->opt[i].transYopt ? '*':'p'), g->im[i].cP.trans_z, (g->opt[i].transZopt ? '*':'p'), + g->im[i].cP.trans_yaw, (g->opt[i].transYawOpt ? '*':'p'), + g->im[i].cP.trans_pitch, (g->opt[i].transPitchOpt ? '*':'p'), // test parameters g->im[i].cP.test_p0, (g->opt[i].testP0opt ? '*':'p'), g->im[i].cP.test_p1, (g->opt[i].testP1opt ? '*':'p'), @@ -1040,7 +1077,7 @@ line += sprintf( line, "TiX%f TiY%f TiZ%f TiS%f ", g->im[i].cP.tilt_x, g->im[i].cP.tilt_y, g->im[i].cP.tilt_z, g->im[i].cP.tilt_scale); } if( g->im[i].cP.trans ) { - line += sprintf( line, "TrX%f TrY%f TrZ%f ", g->im[i].cP.trans_x, g->im[i].cP.trans_y, g->im[i].cP.trans_z); + line += sprintf( line, "TrX%f TrY%f TrZ%f Tpy%f Tpp%f", g->im[i].cP.trans_x, g->im[i].cP.trans_y, g->im[i].cP.trans_z, g->im[i].cP.trans_yaw, g->im[i].cP.trans_pitch); } if( g->im[i].cP.test ) { line += sprintf( line, "Te0%f Te1%f Te2%f Te3%f ", g->im[i].cP.test_p0, g->im[i].cP.test_p1, g->im[i].cP.test_p2, g->im[i].cP.test_p3 ); @@ -1775,6 +1812,20 @@ im.cP.trans = TRUE; } break; + case 'p': + ch++; + switch (*ch) { + case 'y': + READ_VAR("%lf",&(im.cP.trans_yaw)); + break; + case 'p': + READ_VAR("%lf",&(im.cP.trans_pitch)); + break; + default: + PrintError("Unknown variable name Tp%c in script", *ch); + return -1; + } + break; case 'e': ch++; switch (*ch) { |