From: <dm...@us...> - 2007-06-28 22:16:47
|
Revision: 2191 http://hugin.svn.sourceforge.net/hugin/?rev=2191&view=rev Author: dmg Date: 2007-06-28 15:16:45 -0700 (Thu, 28 Jun 2007) Log Message: ----------- 007-06-28 dmg <dm...@uv...> * parser.y, tparser.c, tparser.h: Implemented R variable in p-line * parser.y, tparser.c, tparser.h, scanner.l: Implemented Hugin autoCenterCrop and cropFactor in i-lines. Modified Paths: -------------- libpanorama/trunk/src/parser/ChangeLog libpanorama/trunk/src/parser/TODO libpanorama/trunk/src/parser/parser.y libpanorama/trunk/src/parser/scanner.l libpanorama/trunk/src/parser/testparser.c 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-28 21:44:08 UTC (rev 2190) +++ libpanorama/trunk/src/parser/ChangeLog 2007-06-28 22:16:45 UTC (rev 2191) @@ -1,5 +1,18 @@ +2007-06-28 dmg <dm...@uv...> + + * parser.y, tparser.c, tparser.h: Implemented R variable in p-line + + * parser.y, tparser.c, tparser.h, scanner.l: Implemented Hugin + autoCenterCrop and cropFactor in i-lines. + 2007-06-27 dmg <dm...@uv...> + * parser.y, tparser.c, tparser.h, scanner.l: Implemented Ra...Re + variables and their references + + * parser.y, tparser.c, tparser.h: implemented hugin_options + variables r and e. + * Removed several debugging messages to make the output cleaner. * parser.y: Improved error handling in case of unrecognized Modified: libpanorama/trunk/src/parser/TODO =================================================================== --- libpanorama/trunk/src/parser/TODO 2007-06-28 21:44:08 UTC (rev 2190) +++ libpanorama/trunk/src/parser/TODO 2007-06-28 22:16:45 UTC (rev 2191) @@ -1,3 +1,4 @@ + * The parser needs to implement the 'v' lines * C and morph-to lines are to be tested @@ -3,3 +4,19 @@ * Implement variables r and e in hugin_options + r: optimizeReferenceImage + e: blendMode + + + +> #2. Also, there is a variable R in the pano line. What is it? it is the +> same as #hugin_options r0? + +No, it specifies the output mode: 0: LDR, 1: HDR + +> #3. Should I treat Ee, Er and Eb as an array of 3 values? if so, in +> which order? I will assume they are not linkable. + +Eev should be separate its the photographic Exposure Value. +Er and Eb are the white balance factors, I'd just keep the separate. + Modified: libpanorama/trunk/src/parser/parser.y =================================================================== --- libpanorama/trunk/src/parser/parser.y 2007-06-28 21:44:08 UTC (rev 2190) +++ libpanorama/trunk/src/parser/parser.y 2007-06-28 22:16:45 UTC (rev 2191) @@ -48,8 +48,19 @@ static pt_script_ctrl_point *ctrlPoint; static pt_script_morph_point *morphPoint; +// Look ahead variables +// Hugin uses a comment line _before_ the i line: for example +// #-hugin autoCenterCrop=1 cropFactor=1 +#define PT_AUTO_CENTER_CROP_ST "autoCenterCrop" +#define PT_AUTO_CENTER_CROP_DEFAULT 0 +static int autoCenterCrop = PT_AUTO_CENTER_CROP_DEFAULT; + +#define PT_CROP_FACTOR_ST "cropFactor" +#define PT_CROP_FACTOR_DEFAULT 0 +static int cropFactor = PT_CROP_FACTOR_DEFAULT; + /* copy a string while allocating and checking for memory */ static void ParserStringCopy(char **dest, char *from) { @@ -77,6 +88,7 @@ %token PT_TOKEN_SEP %token <fVal> PT_TOKEN_NUMBER %token <strVal> PT_TOKEN_STRING +%token <strVal> PT_TOKEN_HUGIN_KEYWORD %token <cVal> PT_TOKEN_KEYWORD %token <cVal> PT_TOKEN_CROPPING @@ -205,6 +217,13 @@ image = (pt_script_image *)panoScriptReAlloc((void*)&(script.inputImageSpec), sizeof(pt_script_image), &script.iInputImagesCount); + // This might require more though. Are the defaults of these two variables zero? + image->autoCenterCrop = autoCenterCrop; + image->cropFactor = cropFactor; + cropFactor = PT_CROP_FACTOR_DEFAULT; + autoCenterCrop = PT_AUTO_CENTER_CROP_DEFAULT; + + #ifdef asdfasf // allocate the new output script.iInputImagesCount++; @@ -244,8 +263,18 @@ huginVars: huginVar | huginVars PT_TOKEN_SEPARATOR huginVar -huginVar: - PT_TOKEN_HUGIN_KEYWORD PT_TOKEN_NUMBER +huginVar: PT_TOKEN_HUGIN_KEYWORD PT_TOKEN_NUMBER + { + // The tokens include the = at the end + // we could do a substr, but there is no real value on that + if (strcmp(PT_AUTO_CENTER_CROP_ST "=", $1) == 0) { + autoCenterCrop = lroundf($2); + } else if (strcmp(PT_CROP_FACTOR_ST "=" , $1) == 0) { + cropFactor = $2; + } else { + panoScriptParserError(1,"Warning: invalid variable %s found in Hugin image line. Ignored...\n", $1); + } + } vars: var | vars PT_TOKEN_SEPARATOR var @@ -294,8 +323,29 @@ case 't': image->coefIndex[6] = imageRef; break; + case 'R': // This is a hugin Ra,Rb, ...Re + // This is a hack. $1 is referenced as a char, but the next character is the + // a,b,c,d,e so let us get at it + { + char *temp = &$1; + temp++; + printf("string %c \n", *(temp)); + switch (*temp) { + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + image->responseCurveCoefIndex[(*temp)-'a'] = imageRef; + break; + default: + panoScriptParserError(1,"Invalid variable name R[%c] in image line...\n", *temp); + return -1; + } + } + break; default: - panoScriptParserError(1,"Invalid variable name [%c] in input line.\n", $1); + panoScriptParserError(1,"Invalid variable name [%c=] in input line.\n", $1); return -1; break; } @@ -367,7 +417,7 @@ ParserStringCopy(&image->name, $2); break; default: - panoScriptParserError(1,"Invalid variable name [%c] in image line..\n", $1); + panoScriptParserError(1,"Invalid variable name [%c] in image line...\n", $1); return -1; } break; @@ -383,10 +433,10 @@ case PT_TOKEN_HUGIN_OPTIONS_LINE: switch ($1) { case 'r': - printf("To do r hugin option\n"); + script.optimize.optimizeReferenceImage = lround($2); break; case 'e': - printf("To do e hugin option \n"); + script.optimize.blendMode = lround($2); break; default: panoScriptParserError(1, "Invalid variable name [%c] in hugin options line.\n", $1); @@ -418,7 +468,7 @@ ctrlPoint->type = $2; break; default: - panoScriptParserError(1, "Invalid variable name [%c] in input line.\n", $1); + panoScriptParserError(1, "Invalid variable name [%c] in control point line.\n", $1); return -1; break; } @@ -441,7 +491,7 @@ morphPoint->p2.y = $2; break; default: - panoScriptParserError(1, "Invalid variable name [%c] in input line.\n", $1); + panoScriptParserError(1, "Invalid variable name [%c] in morph line.\n", $1); return -1; break; } @@ -464,7 +514,7 @@ panoScriptParserError(1,"Invalid variable name [%c] in pano line. Ignored...\n", $1); break; case 'R': - panoScriptParserError(1,"Invalid variable name [%c] in pano line. Ignored...\n", $1); + script.pano.outputMode = lroundf($2); break; default: panoScriptParserError(1,"Invalid variable name [%c] in pano line\n", $1); @@ -514,6 +564,27 @@ case 'm': panoScriptParserError(1,"Warning: Option %c in image line deprecated. Ignored...\n", $1); break; + case 'R': // This is a hugin Ra,Rb, ...Re + // This is a hack. $1 is referenced as a char, but the next character is the + // a,b,c,d,e so let us get at it + { + char *temp = &$1; + temp++; + printf("string %c \n", *(temp)); + switch (*temp) { + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + image->responseCurveCoef[(*temp)-'a'] = $2; + break; + default: + panoScriptParserError(1,"Invalid variable name R[%c] in image line...\n", *temp); + return -1; + } + } + break; default: panoScriptParserError(1,"Invalid variable name [%c] in image line...\n", $1); return -1; Modified: libpanorama/trunk/src/parser/scanner.l =================================================================== --- libpanorama/trunk/src/parser/scanner.l 2007-06-28 21:44:08 UTC (rev 2190) +++ libpanorama/trunk/src/parser/scanner.l 2007-06-28 22:16:45 UTC (rev 2191) @@ -108,7 +108,7 @@ -[EKVR][0-9A-Za-z.=-]+[ \t]* { panoScriptScannerTokenBegin(yytext); } /* ignore K, V,R and E parameters */ +[EKV][0-9A-Za-z.=-]+[ \t]* { panoScriptScannerTokenBegin(yytext); } /* ignore K, V,R and E parameters */ /* These are the types of lines supported */ @@ -195,8 +195,15 @@ return PT_TOKEN_COMMA; } +R[abcde] { /* Hugin defines these variables in the i line */ + panoScriptScannerTokenBegin(yytext); + strncpy(yylval.strVal, yytext, PT_TOKEN_MAX_LEN); + return PT_TOKEN_KEYWORD; + } + + [CS] { - /*printf("Multi variable: %s\n", yytext); */ + /* These are the C and S parameters that contain multiple values */ strncpy(yylval.strVal, yytext, PT_TOKEN_MAX_LEN); return PT_TOKEN_CROPPING; } Modified: libpanorama/trunk/src/parser/testparser.c =================================================================== --- libpanorama/trunk/src/parser/testparser.c 2007-06-28 21:44:08 UTC (rev 2190) +++ libpanorama/trunk/src/parser/testparser.c 2007-06-28 22:16:45 UTC (rev 2191) @@ -44,19 +44,20 @@ script = panoScriptParse(argv[1], FALSE); - printf("\n\n-----------------Finished parsing\n"); - if (script == NULL) { printf("Parsing error\n"); } else { - panoScriptDump(script); - printf("-------------------------------------------------\n"); if (!panoScriptDeReferenceVariables(script)) { printf("Unable to de-reference all variable\n"); } + printf("\n\n-----------------Finished parsing\nValues after dereferencing\n\n"); + + panoScriptDump(script); + + /* printf("Printing after variables are dereferrenced\n"); Modified: libpanorama/trunk/src/parser/tparser.c =================================================================== --- libpanorama/trunk/src/parser/tparser.c 2007-06-28 21:44:08 UTC (rev 2190) +++ libpanorama/trunk/src/parser/tparser.c 2007-06-28 22:16:45 UTC (rev 2191) @@ -278,6 +278,12 @@ printf(" g %f", output->coef[5]); printf(" t %f\n", output->coef[6]); + printf(" Ra %f", output->responseCurveCoef[0]); + printf(" Rb %f", output->responseCurveCoef[1]); + printf(" Rc %f", output->responseCurveCoef[2]); + printf(" Rd %f", output->responseCurveCoef[3]); + printf(" Re %f\n", output->responseCurveCoef[4]); + printf(" name %s\n", output->name); printf(" cropType %c ", output->cropType); printf(" cropArea %i,%i,%i,%i ", @@ -292,7 +298,7 @@ printf(" yaw %d", output->yawIndex); printf(" pitch %d", output->pitchIndex); printf(" roll %d", output->rollIndex); - printf(" feather size %d", output->featherSize); + printf(" feather size %d\n", output->featherSize); printf(" a %d", output->coefIndex[0]); printf(" b %d", output->coefIndex[1]); @@ -302,6 +308,18 @@ printf(" g %d", output->coefIndex[5]); printf(" t %d\n", output->coefIndex[6]); + printf(" Ra %d", output->responseCurveCoefIndex[0]); + printf(" Rb %d", output->responseCurveCoefIndex[1]); + printf(" Rc %d", output->responseCurveCoefIndex[2]); + printf(" Rd %d", output->responseCurveCoefIndex[3]); + printf(" Re %d\n", output->responseCurveCoefIndex[4]); + + printf("Other parameters............."); + printf(" autoCenterCrop %d", output->autoCenterCrop); + printf(" cropFactor %f", output->cropFactor); + printf("\n"); + + printf(" Morphing points count %d\n", output->morphPointsCount); for (i=0;i<output->morphPointsCount;i++) { @@ -310,6 +328,7 @@ panoParserDumpMorphPoint(morphPoint); } + } /* @@ -338,6 +357,10 @@ for (i=0;i<script->pano.projectionParmsCount;i++) { printf(" proj parm %d: %f\n", i, script->pano.projectionParms[i]); } + printf("Hugin \n"); + printf(" output mode %d", script->pano.outputMode); + printf("\n"); + printf("Optimize .................."); printf(" gamma %f", script->optimize.fGamma); @@ -345,6 +368,9 @@ printf(" fastFT %d ", script->optimize.fastFT); printf(" huber estimator %d \n", script->optimize.huberEstimator); printf(" photometricHuberSigma %f \n", script->optimize.photometricHuberSigma); + printf(" optimize reference image %d \n", script->optimize.optimizeReferenceImage); + printf(" blend mode %d \n", script->optimize.blendMode); + printf("Output [%d] images ..................\n", script->iOutputImagesCount); @@ -464,6 +490,9 @@ for (j=0;j<PANO_PARSER_COEF_COUNT;j++) { UNLINK_VARIABLE(i,coef[j],coefIndex[j]); } + for (j=0;j<PANO_PARSER_RESP_CURVE_COEF_COUNT;j++) { + UNLINK_VARIABLE(i,responseCurveCoef[j],responseCurveCoefIndex[j]); + } } } #undef UNLINK_VARIABLE @@ -480,6 +509,9 @@ for (j=0;j<PANO_PARSER_COEF_COUNT;j++) { VERIFY_VARIABLE(i,coefIndex[j], names[j]); } + for (j=0;j<PANO_PARSER_RESP_CURVE_COEF_COUNT;j++) { + VERIFY_VARIABLE(i,responseCurveCoefIndex[j],names[j]); + } } #undef VERIFY_VARIABLE Modified: libpanorama/trunk/src/parser/tparser.h =================================================================== --- libpanorama/trunk/src/parser/tparser.h 2007-06-28 21:44:08 UTC (rev 2190) +++ libpanorama/trunk/src/parser/tparser.h 2007-06-28 22:16:45 UTC (rev 2191) @@ -46,6 +46,7 @@ #endif #define PANO_PARSER_COEF_COUNT 7 +#define PANO_PARSER_RESP_CURVE_COEF_COUNT 5 typedef struct { double x; @@ -77,6 +78,7 @@ float fHorFOV; char *outputFormat; char *outputPixelType; + int outputMode; } pt_script_pano; typedef struct { @@ -87,7 +89,8 @@ float yaw; float pitch; float roll; - float coef[7]; // a, b, c, d, e, g, t + float coef[PANO_PARSER_COEF_COUNT]; // a, b, c, d, e, g, t + float responseCurveCoef[PANO_PARSER_RESP_CURVE_COEF_COUNT]; // a b c d e char *name; char cropType ; // it can be 'S' or 'C' int cropArea[PANO_PARSER_COEF_COUNT]; // the rectangle to crop to @@ -99,9 +102,12 @@ int pitchIndex; int rollIndex; int coefIndex[PANO_PARSER_COEF_COUNT]; // a, b, c, d, e , g, t + int responseCurveCoefIndex[PANO_PARSER_RESP_CURVE_COEF_COUNT]; // a, b, c, d, e , g, t int featherSize; int morphPointsCount; pt_script_morph_point *morphPoints; + int autoCenterCrop; + float cropFactor; } pt_script_image; @@ -111,6 +117,8 @@ int fastFT; int huberEstimator; float photometricHuberSigma; + int optimizeReferenceImage; + int blendMode; } pt_script_optimize; typedef struct { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |