1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
|
/*
* dump.c
*
* Routines to dump data structures for debugging purposes
*
* Copyright Daniel M. German
*
* June 2010
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, a copy
* can be downloaded from http://www.gnu.org/licenses/gpl.html, or
* obtained by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*
* Author: Daniel M German dmgerman at uvic doooot ca
*
*/
#include <stdio.h>
#include <assert.h>
#include "dump.h"
#define MAX_INDENT 20
// Macro to generalize printing the fields. Notice the heavey use of stringification
// var can be preceeded with a cast, such as (int)var and it applies to the field
// i.e. (int)var->field due to the higher precedence of the -> operator
#define PRINT_GENERIC(field, format, var) fprintf(stderr, "%s\t" #field " " format "\n", ind, var->field)
static void panoDumpSetIndent(char *ind, int size)
{
assert(size < MAX_INDENT && size >= 0);
memset(ind, '\t', size);
ind[size] = 0;
}
void panoDumpPTRect(PTRect *rect, char *label, int indent)
{
char ind[MAX_INDENT+1];
panoDumpSetIndent(ind, indent);
if (label != NULL) {
fprintf(stderr, "%s%s\n", ind, label);
}
fprintf(stderr, "%sRectangle\n", ind);
#define PRINT_INT(a) PRINT_GENERIC(a, "%d", (int)rect)
PRINT_INT(top);
PRINT_INT(bottom);
PRINT_INT(left);
PRINT_INT(right);
#undef PRINT_INT
}
void panoDumpCropInfo(CropInfo *crop, char *label, int indent)
{
char ind[MAX_INDENT+1];
panoDumpSetIndent(ind, indent);
#define PRINT_INT(a) PRINT_GENERIC(a, "%d", (int)crop)
fprintf(stderr, "%sCrop Info\n", ind);
PRINT_INT(full_width);
PRINT_INT(full_height);
PRINT_INT(cropped_width);
PRINT_INT(cropped_height);
PRINT_INT(x_offset);
PRINT_INT(y_offset);
#undef PRINT_INT
}
void panoDumpCorrectPrefs(cPrefs *cP, char *label, int indent)
{
char ind[MAX_INDENT+1];
int i,j;
panoDumpSetIndent(ind, indent);
#define PRINT_INT(a) PRINT_GENERIC(a,"%d", (int)cP)
#define PRINT_F(a) PRINT_GENERIC(a,"%f", cP)
if (label != NULL) {
fprintf(stderr, "%s%s\n", ind, label);
}
fprintf(stderr, "%sCorrect Preferences\n", ind);
if (cP->radial) {
for (i=0;i<3;i++) {
for (j=0;j<5;j++) {
fprintf(stderr, "%s\tradial_params[%d][%d]\t%f\n", ind, i, j, cP->radial_params[i][j]);
}
}
}
if (cP->vertical) {
for (i=0;i<3;i++) {
fprintf(stderr, "%s\tvertical_params[%d]\t%f\n", ind, i, cP->vertical_params[i]);
}
}
if (cP->horizontal) {
for (i=0;i<3;i++) {
fprintf(stderr, "%s\thorizontal_params[%d]\t%f\n", ind, i, cP->horizontal_params[i]);
}
}
if (cP->shear) {
PRINT_F(shear_x);
PRINT_F(shear_y);
}
if (cP->tilt) {
PRINT_F(tilt_x);
PRINT_F(tilt_y);
PRINT_F(tilt_z);
PRINT_F(tilt_scale);
}
if (cP->trans) {
PRINT_F(trans_x);
PRINT_F(trans_y);
PRINT_F(trans_z);
PRINT_F(trans_yaw);
PRINT_F(trans_pitch);
}
if (cP->test) {
PRINT_F(test_p0);
PRINT_F(test_p1);
PRINT_F(test_p2);
PRINT_F(test_p3);
}
/* I don't think these files are read as parameters... we'll see
int resize;
int32_t width;
int32_t height;
int luminance;
double lum_params[3];
int correction_mode;
int cutFrame;
int fwidth;
int fheight;
int frame;
int fourier;
int fourier_mode;
fullPath psf;
int fourier_nf;
fullPath nff;
double filterfactor;
double fourier_frame;
*/
#undef PRINT_INT
#undef PRINT_F
}
void panoDumpImage(Image *im, char *label, int indent)
{
char ind[MAX_INDENT+1];
int i;
if (im == NULL) return;
// prepare indent
panoDumpSetIndent(ind, indent);
if (label != NULL) {
fprintf(stderr, "%s%s\n", ind, label);
}
#define PRINT_INT(a) PRINT_GENERIC(a,"%d", (int)im)
#define PRINT_F(a) PRINT_GENERIC(a,"%f", im)
#define PRINT_S(a) PRINT_GENERIC(a,"\"%s\"", im)
fprintf(stderr, "%sImage Data\n", ind);
PRINT_INT(width);
PRINT_INT(height);
PRINT_INT(bytesPerLine);
PRINT_INT(bitsPerPixel);
PRINT_INT(dataSize);
PRINT_INT(dataformat);
PRINT_INT(format);
PRINT_INT(formatParamCount);
for (i=0;i< im->formatParamCount; i++) {
fprintf(stderr, "%s\t\tformat Param[%d] %f\n", ind, i, im->formatParam[i]);
}
PRINT_F(hfov);
PRINT_F(yaw);
PRINT_F(roll);
PRINT_F(pitch);
PRINT_S(name);
panoDumpCorrectPrefs(&im->cP, NULL, indent+1);
panoDumpPTRect(&im->selection, NULL,indent+1);
panoDumpCropInfo(&im->cropInformation, NULL, indent+1);
#undef PRINT_INT
#undef PRINT_F
#undef PRINT_S
}
void panoDumpAdjustData(aPrefs* aP, char *label, int indent)
{
char ind[MAX_INDENT+1];
assert (aP != NULL);
panoDumpSetIndent(ind, indent);
if (label != NULL) {
fprintf(stderr, "%s%s\n", ind, label);
}
fprintf(stderr, "%s\tAdjust Data\n", ind);
#define PRINT_INT(a) PRINT_GENERIC(a,"%d", (int)aP)
#define PRINT_F(a) PRINT_GENERIC(a,"%f", aP)
#define PRINT_S(a) PRINT_GENERIC(a,"\"%s\"", aP)
PRINT_INT(mode);
PRINT_S(scriptFile.name);
PRINT_INT(nt);
PRINT_INT(interpolator);
PRINT_F(gamma);
PRINT_INT(fastStep);
#undef PRINT_INT
#undef PRINT_F
#undef PRINT_S
panoDumpImage(&aP->im, "Input Image", indent + 1);
panoDumpImage(&aP->pano, "Panorama", indent + 1);
}
|