1 /*============================================================ 2 * 3 * This file is a part of digiKam project 4 * https://www.digikam.org 5 * 6 * Description : Hugin parser API 7 * 8 * Copyright (C) 2007 by Daniel M German <dmgerman at uvic doooot ca> 9 * Copyright (C) 2012 by Benjamin Girault <benjamin dot girault at gmail dot com> 10 * 11 * This program is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU General Public License as 13 * published by the Free Software Foundation; either version 2 of 14 * the License, or (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program. If not, see <https://www.gnu.org/licenses/>. 23 * 24 * ============================================================ */ 25 26 #ifndef DIGIKAM_T_PARSER_H 27 #define DIGIKAM_T_PARSER_H 28 29 /** 30 * Maximum size for an input token 31 */ 32 #define PARSER_MAX_LINE 1000 33 #define PT_TOKEN_MAX_LEN PARSER_MAX_LINE 34 35 #define PANO_PARSER_MAX_PROJECTION_PARMS 10 36 #define PANO_PARSER_MAX_MASK_POINTS 20 37 38 /** 39 * Data structure where the entire input file will be read 40 */ 41 42 #ifndef FALSE 43 #define FALSE 0 44 #endif 45 46 #ifndef TRUE 47 #define TRUE 1 48 #endif 49 50 #define PANO_PARSER_COEF_COUNT 7 51 #define PANO_PARSER_RESP_CURVE_COEF_COUNT 5 52 #define PANO_PARSER_VIGN_COEF_COUNT 6 53 #define PANO_TRANSLATION_COEF_COUNT 3 54 #define PANO_PROJECTION_COEF_COUNT 2 55 56 typedef struct 57 { 58 int x; 59 int y; 60 } pt_point; 61 62 typedef enum 63 { 64 NEGATIVE = 0, 65 POSITIVE = 1, 66 NEGATIVESTACKAWARE = 2, 67 POSITVESTACKAWARE = 3, 68 NEGATIVELENS = 4 69 } pt_mask_type; 70 71 typedef struct 72 { 73 int iImage; 74 pt_mask_type type; 75 76 int iPointsCount; 77 pt_point* points; 78 } pt_script_mask; 79 80 typedef struct 81 { 82 char* varName; 83 int varIndex; 84 } pt_script_optimize_var; 85 86 typedef struct 87 { 88 double x; 89 double y; 90 } pt_point_double; 91 92 typedef struct 93 { 94 int iImage1; 95 int iImage2; 96 pt_point_double p1; 97 pt_point_double p2; 98 int type; 99 } pt_script_ctrl_point; 100 101 typedef enum 102 { 103 BD_UINT8 = 0, 104 BD_UINT16 = 1, 105 BD_FLOAT = 2 106 } pt_bitdepthoutput; 107 108 typedef struct 109 { 110 int width; 111 int height; 112 int cropArea[PANO_PARSER_COEF_COUNT]; /* the rectangle to crop to */ 113 114 int projection; 115 int projectionParmsCount; 116 double projectionParms[PANO_PARSER_MAX_PROJECTION_PARMS]; 117 118 double fHorFOV; 119 char* outputFormat; /* n : file format of output */ 120 121 /** 122 * Hugin parameters 123 */ 124 int dynamicRangeMode; /* R[01] 0 -> LDR; 1 -> HDR */ 125 pt_bitdepthoutput bitDepthOutput; 126 double exposureValue; /* E exposure value of final panorama */ 127 int iImagePhotometricReference; 128 } pt_script_pano; 129 130 typedef struct 131 { 132 int projection; 133 int width; 134 int height; 135 136 double fHorFOV; 137 double yaw; 138 double pitch; 139 double roll; 140 141 double geometryCoef[PANO_PARSER_COEF_COUNT]; /* a, b, c, d, e, g, t */ 142 143 /** 144 * Exposure related 145 */ 146 double imageEV; /* Exposure value of image Eev */ 147 double whiteBalanceFactorRed; /* Er */ 148 double whiteBalanceFactorBlue; /* Eb */ 149 150 double photometricCoef[PANO_PARSER_RESP_CURVE_COEF_COUNT]; /* R[abcde] */ 151 152 int vignettingCorrectionMode; /* Vm */ 153 double vignettingCorrectionCoef[PANO_PARSER_VIGN_COEF_COUNT]; /* V[abcdxy] */ 154 char* vignettingFlatFieldFile; 155 double cameraPosition[PANO_TRANSLATION_COEF_COUNT]; /* TrX and TpX params */ 156 double projectionPlaneRotation[PANO_PROJECTION_COEF_COUNT]; /* TpX params */ 157 158 159 char* name; 160 int cropArea[PANO_PARSER_COEF_COUNT]; /* the rectangle to crop to */ 161 162 int stack; 163 164 /** 165 * these variables hold pointers to equivalent variables in other images 166 * they are equivalent to the format <var>=<index> where 167 * <var> is variable name, and index is a base-zero pointer to another image 168 * If they are -1 they are unused 169 */ 170 int fHorFOVRef; 171 int yawRef; 172 int pitchRef; 173 int rollRef; 174 175 int geometryCoefRef[PANO_PARSER_COEF_COUNT]; /* a, b, c, d, e, g, t */ 176 177 /** 178 * image references for de-referencing (var=index) 179 */ 180 181 int imageEVRef; /*Exposure value of image */ 182 int whiteBalanceFactorRedRef; /* Er */ 183 int whiteBalanceFactorBlueRef; /* Eb */ 184 185 int photometricCoefRef[PANO_PARSER_RESP_CURVE_COEF_COUNT]; /* R[abcde] */ 186 187 int vignettingCorrectionModeRef; /* Vm */ 188 int vignettingCorrectionCoefRef[PANO_PARSER_VIGN_COEF_COUNT]; /* V[abcdxy] */ 189 190 int stackRef; 191 } pt_script_image; 192 193 typedef struct 194 { 195 double fGamma; 196 int interpolator; 197 int fastFT; 198 double huberEstimator; 199 double photometricHuberSigma; 200 } pt_script_optimize; 201 202 typedef struct 203 { 204 int iPano_prevCommentsCount; 205 char** pano_prevComments; 206 pt_script_pano pano; 207 208 int iInputImagesCount; 209 int* iImage_prevCommentsCount; 210 char*** image_prevComments; 211 pt_script_image* inputImageSpec; 212 213 int iOptimize_prevCommentsCount; 214 char** optimize_prevComments; 215 pt_script_optimize optimize; 216 217 int iVarsToOptimizeCount; 218 int* iVarsToOptimize_prevCommentsCount; 219 char*** varsToOptimize_prevComments; 220 pt_script_optimize_var* varsToOptimize; 221 222 int iCtrlPointsCount; 223 int* iCtrlPoints_prevCommentsCount; 224 char*** ctrlPoints_prevComments; 225 pt_script_ctrl_point* ctrlPointsSpec; 226 227 int iMasksCount; 228 int* iMasks_prevCommentsCount; 229 char*** masks_prevComments; 230 pt_script_mask** masks; 231 232 int iEndingCommentsCount; 233 char** endingComments; 234 } pt_script; 235 236 void panoScriptParserSetDefaults(pt_script* ptr); 237 int panoScriptParse(const char* const filename, pt_script* scriptOut); 238 void panoScriptFree(pt_script* ptr); 239 240 #endif /* DIGIKAM_T_PARSER_H */ 241