From: <dm...@us...> - 2007-06-28 00:10:55
|
Revision: 2174 http://hugin.svn.sourceforge.net/hugin/?rev=2174&view=rev Author: dmg Date: 2007-06-27 17:10:53 -0700 (Wed, 27 Jun 2007) Log Message: ----------- 2007-06-27 dmg <dm...@uv...> * parser.y: Improved error handling in case of unrecognized lines. Previously it was stopping at the first line it did not recognized, but returned no error. * parser.y, tparser.c, tparser.h (struct): Added parameters outputPixelType and photometricHuberSigma. Added feather size (u) in images lines * scanner.l: Added token for #-hugin variables. Modified Paths: -------------- libpanorama/trunk/src/parser/ChangeLog libpanorama/trunk/src/parser/parser.y libpanorama/trunk/src/parser/scanner.l libpanorama/trunk/src/parser/tparser.c libpanorama/trunk/src/parser/tparser.h Modified: libpanorama/trunk/src/parser/ChangeLog =================================================================== --- libpanorama/trunk/src/parser/ChangeLog 2007-06-27 20:44:20 UTC (rev 2173) +++ libpanorama/trunk/src/parser/ChangeLog 2007-06-28 00:10:53 UTC (rev 2174) @@ -1,3 +1,15 @@ +2007-06-27 dmg <dm...@uv...> + + * parser.y: Improved error handling in case of unrecognized + lines. Previously it was stopping at the first line it did not + recognized, but returned no error. + + * parser.y, tparser.c, tparser.h (struct): Added parameters + outputPixelType and photometricHuberSigma. Added feather size (u) + in images lines + + * scanner.l: Added token for #-hugin variables. + 2007-06-14 dmg <dm...@uv...> * parser.y (PT_TOKEN_STRING): Removed yydebug for the time being. Modified: libpanorama/trunk/src/parser/parser.y =================================================================== --- libpanorama/trunk/src/parser/parser.y 2007-06-27 20:44:20 UTC (rev 2173) +++ libpanorama/trunk/src/parser/parser.y 2007-06-28 00:10:53 UTC (rev 2174) @@ -90,8 +90,11 @@ %token PT_TOKEN_COMMA %token PT_TOKEN_REFERENCE %token PT_TOKEN_MORPH_PT_LINE +%token PT_TOKEN_HUGIN_LINE +%token PT_TOKEN_HUGIN_OPTIONS_LINE +%token PT_TOKEN_HUGIN_KEYWORD +%token PT_TOKEN_ERROR - %start input %% /* Grammar rules and actions follow. */ @@ -149,9 +152,32 @@ | optimizeline | ctrlPtsLine | morphPtsLine + | huginImageParmsLine + | huginOptionsLine + | parsingError ; +parsingError: PT_TOKEN_ERROR +{ + return -1; +} PT_TOKEN_SEPARATOR ; + +huginOptionsLine: PT_TOKEN_HUGIN_OPTIONS_LINE PT_TOKEN_SEPARATOR + { + currentLine = PT_TOKEN_HUGIN_OPTIONS_LINE; + } vars eoln + + +huginImageParmsLine: PT_TOKEN_HUGIN_LINE PT_TOKEN_SEPARATOR + { + currentLine = PT_TOKEN_HUGIN_LINE; + } + huginVars + eoln { ; } +// + + ctrlPtsLine: PT_TOKEN_CONTROL_PT_LINE PT_TOKEN_SEPARATOR { currentLine = PT_TOKEN_CONTROL_PT_LINE; @@ -215,6 +241,12 @@ panoline: PT_TOKEN_PANO_LINE PT_TOKEN_SEPARATOR { currentLine=PT_TOKEN_PANO_LINE; } vars eoln { ; } +huginVars: huginVar + | huginVars PT_TOKEN_SEPARATOR huginVar + +huginVar: + PT_TOKEN_HUGIN_KEYWORD PT_TOKEN_NUMBER + vars: var | vars PT_TOKEN_SEPARATOR var @@ -321,6 +353,8 @@ case 'P': ParserStringCopy(&script.pano.projectionParmsString, $2); break; + case 'T': + ParserStringCopy(&script.pano.outputPixelType, $2); default: panoScriptParserError(1,"Invalid variable name [%c] in pano line\n", $1); return -1; @@ -346,6 +380,20 @@ { /* Processing of int variables */ switch (currentLine) { + case PT_TOKEN_HUGIN_OPTIONS_LINE: + switch ($1) { + case 'r': + printf("To do r hugin option\n"); + break; + case 'e': + printf("To do e hugin option \n"); + break; + default: + panoScriptParserError(1, "Invalid variable name [%c] in hugin options line.\n", $1); + return -1; + break; + } + break; case PT_TOKEN_CONTROL_PT_LINE: switch ($1) { case 'n': @@ -461,8 +509,10 @@ image->coef[6] = $2; break; case 'u': + image->featherSize = lroundf($2); + break; case 'm': - printf("Option %c in image line deprecated. Ignored...\n", $1); + panoScriptParserError(1,"Warning: Option %c in image line deprecated. Ignored...\n", $1); break; default: panoScriptParserError(1,"Invalid variable name [%c] in image line...\n", $1); @@ -484,7 +534,7 @@ script.optimize.huberEstimator = lround($2); break; case 'p': - panoScriptParserError(1,"Obsolete variable name [%c] in optimize line. Ignored...\n", $1); + script.optimize.photometricHuberSigma = $2; break; default: panoScriptParserError(1,"Invalid variable name [%c] in optimize line\n", $1); @@ -492,7 +542,7 @@ } break; default: - panoScriptParserError(1,"Error. Not handled (token int [%c]\n", $1); + panoScriptParserError(1,"Error. Not handled (token int [%c])\n", $1); return -1; } } @@ -504,7 +554,7 @@ case PT_TOKEN_PANO_LINE: switch ($1) { case 'T': - panoScriptParserError(1,"Invalid variable name [%c] in pano line. Ignored...\n", $1); + panoScriptParserError(1,"Warning: T parameter expects a string parameter. None provided. Ignored\n", $1); break; default: panoScriptParserError(1,"Invalid variable name [%c] in pano line\n", $1); Modified: libpanorama/trunk/src/parser/scanner.l =================================================================== --- libpanorama/trunk/src/parser/scanner.l 2007-06-27 20:44:20 UTC (rev 2173) +++ libpanorama/trunk/src/parser/scanner.l 2007-06-28 00:10:53 UTC (rev 2174) @@ -62,6 +62,7 @@ %x str %x parm +%x hugin %% @@ -99,12 +100,14 @@ /* Tokens to ignore */ -^v.*\n { ; } /* Ignore v lines */ +^v.*\n { ; } /* Ignore v lines TODO XXXXXXXXXXXX*/ /* Hugin specific variables. When they are supported it would be easier to generate a new type of token for them. For the time being just ignore them */ + + [EKVR][0-9A-Za-z.=-]+[ \t]* { panoScriptScannerTokenBegin(yytext); } /* ignore K, V,R and E parameters */ @@ -129,6 +132,51 @@ return PT_TOKEN_OPTIMIZE_LINE; } +^"#hugin_options" { + panoScriptScannerTokenBegin(yytext); + return PT_TOKEN_HUGIN_OPTIONS_LINE; + } + +^"#-hugin" { + panoScriptScannerTokenBegin(yytext); + BEGIN(hugin); + return PT_TOKEN_HUGIN_LINE; + } + +<hugin>[ \t]+ { /*printf("skypping separator\n"); */ + panoScriptScannerTokenBegin(yytext); + inVariable = 0; + return PT_TOKEN_SEPARATOR; + } + + +<hugin>{ID}+= { + panoScriptScannerTokenBegin(yytext); + strncpy(yylval.strVal, yytext, PT_TOKEN_MAX_LEN); + return PT_TOKEN_HUGIN_KEYWORD; + } + +<hugin>[ \t]*\n { + BEGIN(INITIAL); + return PT_TOKEN_EOL; + } + +<hugin>-?{DIGIT}+ { + /* printf( "An integer: %s (%d)\n", yytext, atoi( yytext ) );*/ + panoScriptScannerTokenBegin(yytext); + yylval.fVal = atof( yytext ); + return PT_TOKEN_NUMBER; + } + +<hugin>-?{DIGIT}+"."{DIGIT}* { + /*printf( "A float: %s (%g)\n", yytext, atof( yytext ) );*/ + panoScriptScannerTokenBegin(yytext); + yylval.fVal = atof( yytext ); + return PT_TOKEN_NUMBER; + } + + + ^c { panoScriptScannerTokenBegin(yytext); return PT_TOKEN_CONTROL_PT_LINE; @@ -190,7 +238,8 @@ panoScriptScannerTokenBegin(yytext); return PT_TOKEN_REFERENCE; } -"#".+\n /* eat up comments */ + +"# ".+\n /* eat up comments */ { ; } @@ -236,7 +285,7 @@ . { panoScriptParserError(1,"Unrecognized character: %s\n", yytext ); - return 0; + return PT_TOKEN_ERROR; } %% Modified: libpanorama/trunk/src/parser/tparser.c =================================================================== --- libpanorama/trunk/src/parser/tparser.c 2007-06-27 20:44:20 UTC (rev 2173) +++ libpanorama/trunk/src/parser/tparser.c 2007-06-28 00:10:53 UTC (rev 2174) @@ -102,7 +102,7 @@ vsprintf(errmsg, errorstring, args); va_end(args); - fprintf(stdout, "Error: %s\n", errmsg); + fprintf(stdout, "%s\n", errmsg); // exit } @@ -292,6 +292,7 @@ printf(" yaw %d", output->yawIndex); printf(" pitch %d", output->pitchIndex); printf(" roll %d", output->rollIndex); + printf(" feather size %d", output->featherSize); printf(" a %d", output->coefIndex[0]); printf(" b %d", output->coefIndex[1]); @@ -331,6 +332,7 @@ printf(" name %s ", script->pano.projectionName); printf(" fHorFOV %f ", script->pano.fHorFOV); printf(" format %s ", script->pano.outputFormat); + printf(" outputPixelType %s ", script->pano.outputPixelType); printf(" proj parms %s\n", script->pano.projectionParmsString); printf(" proj parms count %d\n", script->pano.projectionParmsCount); for (i=0;i<script->pano.projectionParmsCount;i++) { @@ -342,6 +344,7 @@ printf(" interpolator %d", script->optimize.interpolator); printf(" fastFT %d ", script->optimize.fastFT); printf(" huber estimator %d \n", script->optimize.huberEstimator); + printf(" photometricHuberSigma %f \n", script->optimize.photometricHuberSigma); printf("Output [%d] images ..................\n", script->iOutputImagesCount); @@ -576,6 +579,7 @@ FREE(ptr->pano.projectionParmsString); FREE(ptr->pano.outputFormat); + FREE(ptr->pano.outputPixelType); for (i=0;i<ptr->iOutputImagesCount;i++) { FREE(ptr->outputImageSpec[i].name); Modified: libpanorama/trunk/src/parser/tparser.h =================================================================== --- libpanorama/trunk/src/parser/tparser.h 2007-06-27 20:44:20 UTC (rev 2173) +++ libpanorama/trunk/src/parser/tparser.h 2007-06-28 00:10:53 UTC (rev 2174) @@ -76,6 +76,7 @@ char *projectionName; float fHorFOV; char *outputFormat; + char *outputPixelType; } pt_script_pano; typedef struct { @@ -98,6 +99,7 @@ int pitchIndex; int rollIndex; int coefIndex[PANO_PARSER_COEF_COUNT]; // a, b, c, d, e , g, t + int featherSize; int morphPointsCount; pt_script_morph_point *morphPoints; } pt_script_image; @@ -108,6 +110,7 @@ int interpolator; int fastFT; int huberEstimator; + float photometricHuberSigma; } pt_script_optimize; typedef struct { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |