From: <bru...@us...> - 2009-02-04 22:33:46
|
Revision: 937 http://panotools.svn.sourceforge.net/panotools/?rev=937&view=rev Author: brunopostle Date: 2009-02-04 22:33:39 +0000 (Wed, 04 Feb 2009) Log Message: ----------- Existing implementation of WriteResults function uses two intermediate buffers for sprintf(3) and a considerable quantity of strcat(3) calls for copying data in the target buffer. This patch removes all strcat(3) calls and fulfils sprintf(3) in the target buffer directly. Patch #2118807 (Iouri Ivliev) Modified Paths: -------------- trunk/libpano/parser.c Modified: trunk/libpano/parser.c =================================================================== --- trunk/libpano/parser.c 2009-02-02 21:55:32 UTC (rev 936) +++ trunk/libpano/parser.c 2009-02-04 22:33:39 UTC (rev 937) @@ -630,7 +630,7 @@ void WriteResults( char* script, fullPath *sfile, AlignInfo *g, double ds( int i), int launch) { - char *res, **hres, line[LINE_LENGTH], cmd[LINE_LENGTH]; + char *res, **hres, *line; int optHfov; // Has hfov being optimized? int opta,optb,optc; // same for a,b,c - the polynomial corrections int format; @@ -644,17 +644,15 @@ PrintError("Not enough memory to create resultfile"); return; } - res = *hres; - *res = 0; - strcat( res, script ); - sprintf( line, "\n*\n\n" ); strcat( res, line ); - sprintf( line, "# ====================================================================\n");strcat( res, line ); - sprintf( line, "# Output generated by Panorama Tools\n\n" );strcat( res, line ); + line = res = *hres; + line += sprintf( line, "%s", script ); + line += sprintf( line, "\n*\n\n" ); + line += sprintf( line, "# ====================================================================\n"); + line += sprintf( line, "# Output generated by Panorama Tools\n\n" ); if( g->data != NULL ) - strcat( res, (char*) g->data ); - - - sprintf( line, "\n# Panorama description\n" );strcat( res, line ); + line += sprintf( line, "%s", (char*) g->data ); + + line += sprintf( line, "\n# Panorama description\n" ); switch( g->pano.format ) { case _rectilinear: format = PANO_FORMAT_RECTILINEAR; break; @@ -678,14 +676,12 @@ case _triplane: format = PANO_FORMAT_TRIPLANE; break; default: format = -1; break; } - - sprintf( line, "# p f%d w"FMT_INT32" h"FMT_INT32" v%g n\"%s\"\n\n", format, g->pano.width, g->pano.height, g->pano.hfov, g->pano.name );strcat( res, line ); - - - - sprintf( line, "# Parameters for Each Input Image:\n" );strcat( res, line ); - sprintf( line, "# (*) - optimized (p) - preset \n\n");strcat( res, line ); - + + line += sprintf( line, "# p f%d w"FMT_INT32" h"FMT_INT32" v%g n\"%s\"\n\n", format, g->pano.width, g->pano.height, g->pano.hfov, g->pano.name ); + + line += sprintf( line, "# Parameters for Each Input Image:\n" ); + line += sprintf( line, "# (*) - optimized (p) - preset \n\n"); + for( i=0; i<g->numIm; i++ ) { switch( g->im[i].format ) @@ -701,7 +697,6 @@ case _equisolid: format = IMAGE_FORMAT_FISHEYE_EQUISOLID; break; default: format = -1; break; } - sprintf( cmd, "o f%d ", format ); if( g->opt[i].hfov == 1 || ( g->opt[i].hfov > 1 && g->opt[g->opt[i].hfov-2].hfov == 1 )) @@ -727,8 +722,8 @@ else optc = 0; - sprintf( line, "# Image No %d:\n", i );strcat( res, line ); - sprintf( line, "# Yaw: %g deg (%c) Pitch: %g deg (%c) \n# Roll: %g deg (%c) HFov: %g deg (%c)\n# Polynomial Coefficients: a %f (%c); b %f (%c); c %f (%c)\n# Horizontal Shift: %f (%c) Vertical Shift: %f (%c)\n", + line += sprintf( line, "# Image No %d:\n", i ); + line += sprintf( line, "# Yaw: %g deg (%c) Pitch: %g deg (%c) \n# Roll: %g deg (%c) HFov: %g deg (%c)\n# Polynomial Coefficients: a %f (%c); b %f (%c); c %f (%c)\n# Horizontal Shift: %f (%c) Vertical Shift: %f (%c)\n", g->im[i].yaw, ( g->opt[i].yaw ? '*' : 'p' ), g->im[i].pitch, ( g->opt[i].pitch ? '*' : 'p' ), g->im[i].roll, ( g->opt[i].roll ? '*' : 'p' ), @@ -739,80 +734,74 @@ g->im[i].cP.horizontal_params[0], (g->opt[i].d ? '*':'p'), g->im[i].cP.vertical_params[0], (g->opt[i].e ? '*':'p') ); - strcat( res, line ); - sprintf( line, "r%g p%g y%g v%g ", g->im[i].roll,g->im[i].pitch,g->im[i].yaw,g->im[i].hfov); - strcat( cmd, line ); + if( opta || optb || optc ) + { + line += sprintf(line,"# 4th polynomial coefficient: %g\n", 1.0 - ( g->im[i].cP.radial_params[0][3] + + g->im[i].cP.radial_params[0][2] + + g->im[i].cP.radial_params[0][1] ) ); + } + line += sprintf(line, "# Command for Panorama Creation: \n" ); + line += sprintf( line, "o f%d r%g p%g y%g v%g ", format, g->im[i].roll,g->im[i].pitch,g->im[i].yaw,g->im[i].hfov); if( g->im[i].cP.radial ) { - sprintf( line, "a%f b%f c%f ", g->im[i].cP.radial_params[0][3], g->im[i].cP.radial_params[0][2], g->im[i].cP.radial_params[0][1]); - strcat( cmd, line ); + line += sprintf( line, "a%f b%f c%f ", g->im[i].cP.radial_params[0][3], g->im[i].cP.radial_params[0][2], g->im[i].cP.radial_params[0][1]); } if( g->im[i].cP.shear ) { - sprintf( line, "g%f t%f ", g->im[i].cP.shear_x, g->im[i].cP.shear_y); - strcat( cmd, line ); + line += sprintf( line, "g%f t%f ", g->im[i].cP.shear_x, g->im[i].cP.shear_y); } if( g->im[i].cP.cutFrame && !( g->im[i].selection.bottom != 0 || g->im[i].selection.right != 0 )) // g->im[i].format != _fisheye_circ && g->im[i].cP.cutFrame ) { if( g->im[i].cP.frame != 0 ) { - sprintf( line, "m%d ",g->im[i].cP.frame ); + line += sprintf( line, "m%d ",g->im[i].cP.frame ); } else { - sprintf( line, "mx%d my%d ",g->im[i].cP.fwidth, g->im[i].cP.fheight ); + line += sprintf( line, "mx%d my%d ",g->im[i].cP.fwidth, g->im[i].cP.fheight ); } - strcat( cmd, line ); } -// sprintf( line, "d%f e%f ", g->prefs[i]->c_prefs.horizontal_params[0], g->prefs[i]->c_prefs.vertical_params[0]); -// strcat( cmd, line ); +// line += sprintf( line, "d%f e%f ", g->prefs[i]->c_prefs.horizontal_params[0], g->prefs[i]->c_prefs.vertical_params[0]); #if 0 if( g->prefs[i]->colCorrect ) { - sprintf( line, "t%f,%f,%f,%f,%f,%f ", g->prefs[i]->ColCoeff[0][0], + line += sprintf( line, "t%f,%f,%f,%f,%f,%f ", g->prefs[i]->ColCoeff[0][0], g->prefs[i]->ColCoeff[0][1], g->prefs[i]->ColCoeff[1][0], g->prefs[i]->ColCoeff[1][1], g->prefs[i]->ColCoeff[2][0], g->prefs[i]->ColCoeff[2][1]); - strcat( cmd, line ); } #endif if( g->im[i].cP.horizontal ) { - sprintf( line, "d%f ",g->im[i].cP.horizontal_params[0]); - strcat( cmd, line ); + line += sprintf( line, "d%f ",g->im[i].cP.horizontal_params[0]); } if( g->im[i].cP.vertical ) { - sprintf( line, "e%f ",g->im[i].cP.vertical_params[0]); - strcat( cmd, line ); + line += sprintf( line, "e%f ",g->im[i].cP.vertical_params[0]); } if( g->im[i].cP.correction_mode & correction_mode_morph ) { - strcat( cmd, "o " ); + line += sprintf( line, "o " ); } if( g->im[i].selection.bottom != 0 || g->im[i].selection.right != 0 ){ if( g->im[i].cP.cutFrame ){ - sprintf( line, " C"FMT_INT32","FMT_INT32","FMT_INT32","FMT_INT32" ",g->im[i].selection.left, g->im[i].selection.right, + line += sprintf( line, " C"FMT_INT32","FMT_INT32","FMT_INT32","FMT_INT32" ",g->im[i].selection.left, g->im[i].selection.right, g->im[i].selection.top, g->im[i].selection.bottom ); }else{ - sprintf( line, " S"FMT_INT32","FMT_INT32","FMT_INT32","FMT_INT32" ",g->im[i].selection.left, g->im[i].selection.right, + line += sprintf( line, " S"FMT_INT32","FMT_INT32","FMT_INT32","FMT_INT32" ",g->im[i].selection.left, g->im[i].selection.right, g->im[i].selection.top, g->im[i].selection.bottom ); } - strcat( cmd, line ); } - - sprintf(line, "u%d ", g->st.feather); - strcat( cmd, line ); + line += sprintf(line, "u%d ", g->st.feather); #if 0 // Print filename if( g->im[i].name != NULL && strlen( g->im[i].name != 0 ) ){ - sprintf(line, " n\"%s\" ", g->im[i].name); - strcat( cmd, line ); + line += sprintf(line, " n\"%s\" ", g->im[i].name); } #endif @@ -821,48 +810,32 @@ // else add stitch commands if( !*(g->st.destName) ) { - if( i== 0 ) { - sprintf(line, "-%s ", g->st.srcName); - strcat( cmd, line ); + line += sprintf(line, "-%s ", g->st.srcName); } else if( i == g->numIm-1 ) { - sprintf(line, "+%s ", g->st.srcName); - strcat( cmd, line ); + line += sprintf(line, "+%s ", g->st.srcName); } else { - sprintf(line, "+%s -%s ", g->st.srcName, g->st.srcName); - strcat( cmd, line ); + line += sprintf(line, "+%s -%s ", g->st.srcName, g->st.srcName); } // Print Feather commands } - - - - if( opta || optb || optc ) - { - sprintf(line,"# 4th polynomial coefficient: %g\n", 1.0 - ( g->im[i].cP.radial_params[0][3] - + g->im[i].cP.radial_params[0][2] - + g->im[i].cP.radial_params[0][1] ) ); - strcat( res, line ); - } - sprintf(line, "# Command for Panorama Creation: \n%s\n", cmd ); - strcat( res, line ); - sprintf(line, "\n");strcat( res, line ); + line += sprintf(line, "\n\n"); } // numIm if( g->numPts > 0 ) // Display Controlpoint distances { - sprintf(line, "\n");strcat( res, line ); - sprintf( line, "# ==========================================================================\n");strcat( res, line ); - sprintf( line, "# Control Points: Distance between desired and fitted Position (in \"Pixels\")\n\n");strcat( res, line ); - + line += sprintf(line, "\n"); + line += sprintf( line, "# ==========================================================================\n"); + line += sprintf( line, "# Control Points: Distance between desired and fitted Position (in \"Pixels\")\n\n"); + for( i=0; i<g->numPts; i++ ) { - sprintf( line, "# Control Point No %d: %g\n", i , sqrt ( ds(i)) );strcat( res, line ); + line += sprintf( line, "# Control Point No %d: %g\n", i , sqrt ( ds(i)) ); } // Print optimum positions for points in panorama for( i=0; i<g->numPts; i++ ) @@ -879,8 +852,8 @@ { xd = (x[0]+x[1]) / 2.0; yd = (y[0]+y[1]) / 2.0; - sprintf( line, "C i%d x%g y%g X%g Y%g\n", g->cpt[i].num[0] , x[0], y[0], xd, yd );strcat( res, line ); - sprintf( line, "C i%d x%g y%g X%g Y%g\n", g->cpt[i].num[1] , x[1], y[1], xd, yd );strcat( res, line ); + line += sprintf( line, "C i%d x%g y%g X%g Y%g\n", g->cpt[i].num[0] , x[0], y[0], xd, yd ); + line += sprintf( line, "C i%d x%g y%g X%g Y%g\n", g->cpt[i].num[1] , x[1], y[1], xd, yd ); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bru...@us...> - 2009-02-04 23:02:22
|
Revision: 938 http://panotools.svn.sourceforge.net/panotools/?rev=938&view=rev Author: brunopostle Date: 2009-02-04 23:02:13 +0000 (Wed, 04 Feb 2009) Log Message: ----------- four variables have been added to "C" lines: * c - control point number; * D, Dx, Dy - a control point error (value and orthogonal components). It is useful for the analysis of results of PToptimizer operation and the subsequent removal of "bad" control points. Patch #2118807 (Iouri Ivliev) Modified Paths: -------------- trunk/libpano/parser.c Modified: trunk/libpano/parser.c =================================================================== --- trunk/libpano/parser.c 2009-02-04 22:33:39 UTC (rev 937) +++ trunk/libpano/parser.c 2009-02-04 23:02:13 UTC (rev 938) @@ -840,8 +840,9 @@ // Print optimum positions for points in panorama for( i=0; i<g->numPts; i++ ) { - double x[2],y[2],xd,yd; - + double x[2],y[2],xd,yd,d,D[2]; + + EvaluateControlPointErrorAndComponents(i,&d,D); // write only normal control points, not horizontals, verticals, or lines if (g->cpt[i].type == 0) { @@ -852,8 +853,8 @@ { xd = (x[0]+x[1]) / 2.0; yd = (y[0]+y[1]) / 2.0; - line += sprintf( line, "C i%d x%g y%g X%g Y%g\n", g->cpt[i].num[0] , x[0], y[0], xd, yd ); - line += sprintf( line, "C i%d x%g y%g X%g Y%g\n", g->cpt[i].num[1] , x[1], y[1], xd, yd ); + line += sprintf( line, "C i%d c%d x%g y%g X%g Y%g D%g Dx%g Dy%g\n", g->cpt[i].num[0], i, x[0], y[0], xd, yd, d, D[0], D[1] ); + line += sprintf( line, "C i%d c%d x%g y%g X%g Y%g D%g Dx%g Dy%g\n", g->cpt[i].num[1], i, x[1], y[1], xd, yd, d, D[0], D[1] ); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jim...@us...> - 2009-02-10 00:47:19
|
Revision: 948 http://panotools.svn.sourceforge.net/panotools/?rev=948&view=rev Author: jim0watters Date: 2009-02-10 00:47:12 +0000 (Tue, 10 Feb 2009) Log Message: ----------- add missing case statements Modified Paths: -------------- trunk/libpano/parser.c Modified: trunk/libpano/parser.c =================================================================== --- trunk/libpano/parser.c 2009-02-09 22:03:45 UTC (rev 947) +++ trunk/libpano/parser.c 2009-02-10 00:47:12 UTC (rev 948) @@ -504,6 +504,12 @@ case PANO_FORMAT_ARCHITECTURAL: gl->pano.format = _architectural; break; + case PANO_FORMAT_ORTHOGRAPHIC: + gl->pano.format = _orthographic; + break; + case PANO_FORMAT_EQUISOLID: + gl->pano.format = _equisolid; + break; case PANO_FORMAT_BIPLANE: gl->pano.format = _biplane; break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dm...@us...> - 2009-08-18 17:26:56
|
Revision: 1036 http://panotools.svn.sourceforge.net/panotools/?rev=1036&view=rev Author: dmg Date: 2009-08-18 17:26:49 +0000 (Tue, 18 Aug 2009) Log Message: ----------- Tried to fix the setlocale thing Modified Paths: -------------- trunk/libpano/parser.c Modified: trunk/libpano/parser.c =================================================================== --- trunk/libpano/parser.c 2009-08-15 12:14:32 UTC (rev 1035) +++ trunk/libpano/parser.c 2009-08-18 17:26:49 UTC (rev 1036) @@ -93,8 +93,7 @@ #define LINE_LENGTH 65536 -static char *oldLocale = NULL; - +/* void panoLocaleSave(void) { char *p; @@ -102,13 +101,13 @@ oldLocale=strdup(p); setlocale(LC_ALL, "C"); } -void panoLocaleRestore(void) -{ - setlocale(LC_ALL,oldLocale); - free(oldLocale); -} +*/ +#define panoLocaleSave char *oldLocale;oldLocale=strdup(setlocale(LC_ALL, NULL));setlocale(LC_ALL, "C") +#define panoLocaleRestore (oldLocale != NULL? (setlocale(LC_ALL,oldLocale),free(oldLocale)):0) + + // Optimizer Script parser; fill global info structure int ParseScript( char* script, AlignInfo *gl ) @@ -127,7 +126,7 @@ int n=0; // Number of parameters to optimize int numIm,numPts,nt; - panoLocaleSave(); + panoLocaleSave; gl->im = NULL; gl->opt = NULL; @@ -644,11 +643,11 @@ } - panoLocaleRestore(); + panoLocaleRestore; return 0; fail: - panoLocaleRestore(); + panoLocaleRestore; return -1; } @@ -663,7 +662,7 @@ int format; int i; - panoLocaleSave(); + panoLocaleSave; hres = (char**) mymalloc( strlen(script) + g->numIm * 600 + g->numPts * 200 + 10000 ); // Do we ever need more? if( hres == NULL ) @@ -892,11 +891,11 @@ } if( hres ) myfree( (void**)hres ); - panoLocaleRestore(); + panoLocaleRestore; return; fail: - panoLocaleRestore(); + panoLocaleRestore; } @@ -916,7 +915,7 @@ int seti; - panoLocaleSave(); + panoLocaleSave; // Set prefs and sBuf to defaults @@ -1140,13 +1139,13 @@ } free( script); - panoLocaleRestore(); + panoLocaleRestore; return 0; fail: if (script != NULL) free(script); - panoLocaleRestore(); + panoLocaleRestore; return -1; @@ -1167,7 +1166,7 @@ int numPts; - panoLocaleSave(); + panoLocaleSave; defCn.num[0] = defCn.num[1] = -1; defCn.type = 0; @@ -1691,7 +1690,7 @@ double sigma = 0; int n; - panoLocaleSave(); + panoLocaleSave; memcpy( &theSprefs, sP, sizeof(sPrefs) ); @@ -1733,11 +1732,11 @@ // appears ok memcpy( sP, &theSprefs, sizeof(sPrefs) ); - panoLocaleRestore(); + panoLocaleRestore; return 0; fail: - panoLocaleRestore(); + panoLocaleRestore; return -1; } @@ -1750,7 +1749,7 @@ char buf[LINE_LENGTH]; VRPanoOptions VRopt; - panoLocaleSave(); + panoLocaleSave; memcpy( &VRopt, v, sizeof( VRPanoOptions ) ); @@ -1779,7 +1778,7 @@ } } memcpy( v, &VRopt, sizeof( VRPanoOptions ) ); - panoLocaleRestore(); + panoLocaleRestore; return 0; } @@ -1797,7 +1796,7 @@ int nr=0,np=0; - panoLocaleSave(); + panoLocaleSave; // Determine number of images and control points @@ -1852,12 +1851,12 @@ default: break; } } - panoLocaleRestore(); + panoLocaleRestore; return 0; fail: - panoLocaleRestore(); + panoLocaleRestore; return -1; @@ -1915,7 +1914,7 @@ void *tmp; - panoLocaleSave(); + panoLocaleSave; // Determine number of morph control points @@ -1977,11 +1976,11 @@ gl->numPts=np; gl->cpt = (controlPoint*)tmp; success: - panoLocaleRestore(); + panoLocaleRestore; return np; fail: - panoLocaleRestore(); + panoLocaleRestore; return -1; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dm...@us...> - 2009-09-26 05:59:21
|
Revision: 1082 http://panotools.svn.sourceforge.net/panotools/?rev=1082&view=rev Author: dmg Date: 2009-09-26 05:59:08 +0000 (Sat, 26 Sep 2009) Log Message: ----------- commented debugging Modified Paths: -------------- trunk/libpano/parser.c Modified: trunk/libpano/parser.c =================================================================== --- trunk/libpano/parser.c 2009-09-26 05:57:07 UTC (rev 1081) +++ trunk/libpano/parser.c 2009-09-26 05:59:08 UTC (rev 1082) @@ -1650,7 +1650,7 @@ memcpy( &im, imPtr, sizeof(Image) ); memcpy( &sBuf, sPtr, sizeof(stBuf )); - panoPrintImage("Before read image", imPtr); + // panoPrintImage("Before read image", imPtr); // printf("************************************* Before Cut Frame %d \n", im.cP.cutFrame); while( *ch != 0) { switch(*ch) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <da...@us...> - 2009-10-11 21:48:11
|
Revision: 1104 http://panotools.svn.sourceforge.net/panotools/?rev=1104&view=rev Author: dangelo Date: 2009-10-11 21:48:04 +0000 (Sun, 11 Oct 2009) Log Message: ----------- fixed a typo Modified Paths: -------------- trunk/libpano/parser.c Modified: trunk/libpano/parser.c =================================================================== --- trunk/libpano/parser.c 2009-10-11 21:45:33 UTC (rev 1103) +++ trunk/libpano/parser.c 2009-10-11 21:48:04 UTC (rev 1104) @@ -419,7 +419,7 @@ li = panoParseVariable(buf, li, lineNum, &(opt->testP2opt), &(im->cP.test_p2)); break; case '3': - li = panoParseVariable(buf, li, lineNum, &(opt->testP2opt), &(im->cP.test_p3)); + li = panoParseVariable(buf, li, lineNum, &(opt->testP3opt), &(im->cP.test_p3)); break; default: PrintError("Unknown Test parameter Te%c in script: Line %d", *li, lineNum); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <da...@us...> - 2010-01-03 18:01:10
|
Revision: 1206 http://panotools.svn.sourceforge.net/panotools/?rev=1206&view=rev Author: dangelo Date: 2010-01-03 18:00:53 +0000 (Sun, 03 Jan 2010) Log Message: ----------- Only use Tr(XYZ) if the are nonzero. Modified Paths: -------------- trunk/libpano/parser.c Modified: trunk/libpano/parser.c =================================================================== --- trunk/libpano/parser.c 2010-01-01 21:47:46 UTC (rev 1205) +++ trunk/libpano/parser.c 2010-01-03 18:00:53 UTC (rev 1206) @@ -404,7 +404,12 @@ return -1; } if (li == NULL) return -1; - im->cP.trans = TRUE; + if (im->cP.trans_x != 0.0 || + im->cP.trans_y != 0.0 || + im->cP.trans_z != 0.0) + { + im->cP.trans = TRUE; + } break; case 'e': // test parameters li++; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |