digiKam
ptotype.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2012-02-04
7  * Description : a tool to create panorama by fusion of several images.
8  * This type is based on pto file format described here:
9  * hugin.sourceforge.net/docs/nona/nona.txt, and
10  * on pto files produced by Hugin's tools.
11  *
12  * Copyright (C) 2012-2015 by Benjamin Girault <benjamin dot girault at gmail dot com>
13  *
14  * This program is free software; you can redistribute it
15  * and/or modify it under the terms of the GNU General
16  * Public License as published by the Free Software Foundation;
17  * either version 2, or (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * ============================================================ */
25 
26 #ifndef DIGIKAM_PTO_TYPE_H
27 #define DIGIKAM_PTO_TYPE_H
28 
29 // Qt includes
30 
31 #include <QPoint>
32 #include <QVector>
33 #include <QSize>
34 #include <QString>
35 #include <QRect>
36 #include <QStringList>
37 #include <QPair>
38 #include <QTextStream>
39 
40 namespace Digikam
41 {
42 
43 struct PTOType
44 {
45  struct Project
46  {
47  struct FileFormat
48  {
49  typedef enum
50  {
51  PNG,
55  JPEG
57 
58  typedef enum
59  {
61  LZW,
62  DEFLATE
64 
66  unsigned char quality;
68  bool cropped;
70 
72  : fileType (JPEG),
73  quality (90),
75  cropped (false),
76  savePositions (false)
77  {
78  }
79  };
80 
81  typedef enum
82  {
88 
89  typedef enum
90  {
93  FLOAT
95 
96  QStringList previousComments;
97  QSize size;
98  QRect crop;
100  double fieldOfView;
102  double exposure;
103  bool hdr;
106  QStringList unmatchedParameters;
107 
109  : size (0, 0),
110  crop (0, 0, 0, 0),
112  fieldOfView (0),
113  exposure (0),
114  hdr (false),
115  bitDepth (UINT8),
117  {
118  }
119  };
120 
121  // --------------------------------------------------------------------------------------
122 
123  struct Stitcher
124  {
125  typedef enum
126  {
127  POLY3 = 0,
128  SPLINE16 = 1,
129  SPLINE36 = 2,
130  SINC256 = 3,
131  SPLINE64 = 4,
132  BILINEAR = 5,
134  SINC1024 = 7
136 
137  typedef enum
138  {
140  MEDIUM = 1,
141  FAST = 2
143 
144  QStringList previousComments;
145  double gamma;
148  double huberSigma;
150  QStringList unmatchedParameters;
151 
153  : gamma (1),
155  speedUp (FAST),
156  huberSigma (0),
158  {
159  }
160  };
161 
162  // --------------------------------------------------------------------------------------
163 
164  struct Mask
165  {
166  typedef enum
167  {
168  NEGATIVE = 0,
169  POSITIVE = 1,
172  NEGATIVELENS = 4
174 
175  QStringList previousComments;
178  };
179 
180  // --------------------------------------------------------------------------------------
181 
183  {
184  typedef enum
185  {
198  VA,
199  VB,
200  VC,
201  VD,
202  VX,
203  VY,
204  RA,
205  RB,
206  RC,
207  RD,
208  RE,
209  UNKNOWN
211 
212  QStringList previousComments;
214  };
215 
216  // --------------------------------------------------------------------------------------
217 
218  struct Image
219  {
220  template<typename T>
222  {
224  : value (T()),
225  referenceId(-1)
226  {
227  }
228 
229  explicit LensParameter(const T& v)
230  : value (v),
231  referenceId(-1)
232  {
233  }
234 
237 
238  friend QTextStream& operator<<(QTextStream& qts, const LensParameter<T>& p)
239  {
240  if (p.referenceId == -1)
241  {
242  qts << p.value;
243  }
244  else
245  {
246  qts << "=" << p.referenceId;
247  }
248 
249  return qts;
250  }
251  };
252 
253  typedef enum
254  {
259  EQUIRECTANGULAR = 4
261 
262  typedef enum
263  {
265  RADIAL = 1,
270 
271  QStringList previousComments;
272  QSize size;
273  int id;
278  double yaw;
279  double pitch;
280  double roll;
309  QRect crop;
311  QString fileName;
312  QStringList unmatchedParameters;
313 
315  : size (0, 0),
316  id (0),
318  fieldOfView (0),
319  yaw (0),
320  pitch (0),
321  roll (0),
325  lensCenterOffsetX (0),
326  lensCenterOffsetY (0),
327  lensShearX (0),
328  lensShearY (0),
329  exposure (0),
330  whiteBalanceRed (1),
331  whiteBalanceBlue (1),
337  vignettingOffsetX (0),
338  vignettingOffsetY (0),
339  photometricEMoRA (0),
340  photometricEMoRB (0),
341  photometricEMoRC (0),
342  photometricEMoRD (0),
343  photometricEMoRE (0),
349  crop (0, 0, 0, 0),
350  stackNumber (0)
351  {
352  }
353  };
354 
355  // --------------------------------------------------------------------------------------
356 
358  {
359  QStringList previousComments;
360  int image1Id;
361  int image2Id;
362  double p1_x;
363  double p1_y;
364  double p2_x;
365  double p2_y;
366  int type; // FIXME: change that for an enum if possible
367  QStringList unmatchedParameters;
368  };
369 
370  // --------------------------------------------------------------------------------------
371 
372  enum
373  {
375  V2014
377 
379  : version(PRE_V2014)
380  {
381  }
382 
383  explicit PTOType(const QString& version)
384  : version((version.split(QLatin1Char('.'))[0].toInt() >= 2014) ? V2014
385  : PRE_V2014)
386  {
387  }
388 
389  bool createFile(const QString& filepath);
390 
391 /*
392  NOTE: Work in progress
393  QPair<double, int> standardDeviation(int image1Id, int image2Id);
394  QPair<double, int> standardDeviation(int imageId);
395  QPair<double, int> standardDeviation();
396 */
397 
400  QVector<Image> images;
402  QStringList lastComments;
403 };
404 
405 } // namespace Digikam
406 
407 #endif // DIGIKAM_PTO_TYPE_H
#define T
DIGIKAM_DATABASE_EXPORT QStringList split(const QString &string)
Definition: coredbsearchxml.cpp:836
Definition: datefolderview.cpp:43
Definition: ptotype.h:358
double p1_x
Definition: ptotype.h:362
int type
Definition: ptotype.h:366
QStringList unmatchedParameters
Definition: ptotype.h:367
QStringList previousComments
Definition: ptotype.h:359
double p1_y
Definition: ptotype.h:363
double p2_x
Definition: ptotype.h:364
double p2_y
Definition: ptotype.h:365
int image2Id
Definition: ptotype.h:361
int image1Id
Definition: ptotype.h:360
friend QTextStream & operator<<(QTextStream &qts, const LensParameter< T > &p)
Definition: ptotype.h:238
T value
Definition: ptotype.h:235
int referenceId
Definition: ptotype.h:236
LensParameter()
Definition: ptotype.h:223
LensParameter(const T &v)
Definition: ptotype.h:229
Definition: ptotype.h:219
LensProjection lensProjection
Definition: ptotype.h:276
LensParameter< double > exposure
Definition: ptotype.h:288
LensParameter< int > vignettingOffsetX
Definition: ptotype.h:296
LensParameter< int > lensShearX
Definition: ptotype.h:286
QSize size
Definition: ptotype.h:272
LensParameter< int > lensShearY
Definition: ptotype.h:287
LensParameter< double > lensBarrelCoefficientB
Definition: ptotype.h:282
LensParameter< int > stackNumber
Definition: ptotype.h:310
QList< Mask > masks
Definition: ptotype.h:274
LensParameter< double > lensBarrelCoefficientC
Definition: ptotype.h:283
LensParameter< double > photometricEMoRE
Definition: ptotype.h:303
LensParameter< int > vignettingOffsetY
Definition: ptotype.h:297
double mosaicProjectionPlanePitch
Definition: ptotype.h:308
QRect crop
Definition: ptotype.h:309
LensParameter< int > lensCenterOffsetX
Definition: ptotype.h:284
QString fileName
Definition: ptotype.h:311
double mosaicCameraPositionZ
Definition: ptotype.h:306
QStringList unmatchedParameters
Definition: ptotype.h:312
double mosaicProjectionPlaneYaw
Definition: ptotype.h:307
LensParameter< double > photometricEMoRB
Definition: ptotype.h:300
LensProjection
Definition: ptotype.h:254
@ PANORAMIC
Definition: ptotype.h:256
@ RECTILINEAR
Definition: ptotype.h:255
@ EQUIRECTANGULAR
Definition: ptotype.h:259
@ FULLFRAMEFISHEYE
Definition: ptotype.h:258
@ CIRCULARFISHEYE
Definition: ptotype.h:257
LensParameter< double > whiteBalanceRed
Definition: ptotype.h:289
LensParameter< double > vignettingCorrectionK
Vc.
Definition: ptotype.h:294
double mosaicCameraPositionY
Definition: ptotype.h:305
LensParameter< double > vignettingCorrectionL
Vd.
Definition: ptotype.h:295
LensParameter< VignettingMode > vignettingMode
Definition: ptotype.h:291
LensParameter< double > photometricEMoRC
Definition: ptotype.h:301
QList< Optimization > optimizationParameters
Definition: ptotype.h:275
Image()
Definition: ptotype.h:314
int id
Definition: ptotype.h:273
LensParameter< double > fieldOfView
Definition: ptotype.h:277
LensParameter< double > photometricEMoRD
Definition: ptotype.h:302
LensParameter< int > lensCenterOffsetY
Definition: ptotype.h:285
double pitch
Definition: ptotype.h:279
double yaw
Definition: ptotype.h:278
LensParameter< double > vignettingCorrectionJ
Vb.
Definition: ptotype.h:293
VignettingMode
Definition: ptotype.h:263
@ PROPORTIONNALRADIAL
Definition: ptotype.h:267
@ FLATFIELD
Definition: ptotype.h:266
@ RADIAL
Definition: ptotype.h:265
@ PANO_NONE
Definition: ptotype.h:264
@ PROPORTIONNALFLATFIELD
Definition: ptotype.h:268
LensParameter< double > whiteBalanceBlue
Definition: ptotype.h:290
double mosaicCameraPositionX
Definition: ptotype.h:304
LensParameter< double > vignettingCorrectionI
Va.
Definition: ptotype.h:292
LensParameter< double > lensBarrelCoefficientA
Definition: ptotype.h:281
LensParameter< double > photometricEMoRA
Definition: ptotype.h:299
QString vignettingFlatfieldImageName
Definition: ptotype.h:298
QStringList previousComments
Definition: ptotype.h:271
double roll
Definition: ptotype.h:280
Definition: ptotype.h:165
QList< QPoint > hull
Definition: ptotype.h:177
MaskType
Definition: ptotype.h:167
@ NEGATIVESTACK
Definition: ptotype.h:170
@ NEGATIVELENS
Definition: ptotype.h:172
@ POSITIVESTACK
Definition: ptotype.h:171
@ POSITIVE
Definition: ptotype.h:169
@ NEGATIVE
Definition: ptotype.h:168
MaskType type
Definition: ptotype.h:176
QStringList previousComments
Definition: ptotype.h:175
Definition: ptotype.h:183
Parameter
Definition: ptotype.h:185
@ LENSB
Definition: ptotype.h:187
@ LENSA
Definition: ptotype.h:186
@ EXPOSURE
Definition: ptotype.h:195
@ RE
Definition: ptotype.h:208
@ VC
Definition: ptotype.h:200
@ WBR
Definition: ptotype.h:196
@ LENSD
Definition: ptotype.h:189
@ UNKNOWN
Definition: ptotype.h:209
@ VB
Definition: ptotype.h:199
@ VX
Definition: ptotype.h:202
@ VY
Definition: ptotype.h:203
@ WBB
Definition: ptotype.h:197
@ LENSC
Definition: ptotype.h:188
@ RB
Definition: ptotype.h:205
@ RD
Definition: ptotype.h:207
@ LENSPITCH
Definition: ptotype.h:193
@ VA
Definition: ptotype.h:198
@ LENSHFOV
Definition: ptotype.h:191
@ LENSYAW
Definition: ptotype.h:192
@ VD
Definition: ptotype.h:201
@ RA
Definition: ptotype.h:204
@ RC
Definition: ptotype.h:206
@ LENSE
Definition: ptotype.h:190
@ LENSROLL
Definition: ptotype.h:194
Parameter parameter
Definition: ptotype.h:213
QStringList previousComments
Definition: ptotype.h:212
CompressionMethod compressionMethod
for TIFF
Definition: ptotype.h:67
FileFormat()
Definition: ptotype.h:71
unsigned char quality
for JPEG
Definition: ptotype.h:66
FileType fileType
Definition: ptotype.h:65
CompressionMethod
Definition: ptotype.h:59
@ PANO_NONE
Definition: ptotype.h:60
@ LZW
Definition: ptotype.h:61
@ DEFLATE
Definition: ptotype.h:62
bool cropped
for TIFF
Definition: ptotype.h:68
bool savePositions
for TIFF
Definition: ptotype.h:69
FileType
Definition: ptotype.h:50
@ JPEG
Definition: ptotype.h:55
@ TIFF_multilayer
Definition: ptotype.h:54
@ PNG
Definition: ptotype.h:51
@ TIFF_m
Definition: ptotype.h:53
@ TIFF
Definition: ptotype.h:52
Definition: ptotype.h:46
int photometricReferenceId
Definition: ptotype.h:105
ProjectionType projection
Definition: ptotype.h:99
ProjectionType
Definition: ptotype.h:82
@ EQUIRECTANGULAR
Definition: ptotype.h:85
@ RECTILINEAR
Definition: ptotype.h:83
@ FULLFRAMEFISHEYE
Definition: ptotype.h:86
@ CYLINDRICAL
Definition: ptotype.h:84
double fieldOfView
Definition: ptotype.h:100
QSize size
Definition: ptotype.h:97
FileFormat fileFormat
Definition: ptotype.h:101
BitDepth
Definition: ptotype.h:90
@ FLOAT
Definition: ptotype.h:93
@ UINT8
Definition: ptotype.h:91
@ UINT16
Definition: ptotype.h:92
bool hdr
Definition: ptotype.h:103
QStringList previousComments
Definition: ptotype.h:96
Project()
Definition: ptotype.h:108
double exposure
Definition: ptotype.h:102
BitDepth bitDepth
Definition: ptotype.h:104
QStringList unmatchedParameters
Definition: ptotype.h:106
QRect crop
Definition: ptotype.h:98
Definition: ptotype.h:124
QStringList previousComments
Definition: ptotype.h:144
double gamma
Definition: ptotype.h:145
double photometricHuberSigma
Definition: ptotype.h:149
double huberSigma
Definition: ptotype.h:148
QStringList unmatchedParameters
Definition: ptotype.h:150
Stitcher()
Definition: ptotype.h:152
SpeedUp
Definition: ptotype.h:138
@ FAST
Definition: ptotype.h:141
@ SLOW
Definition: ptotype.h:139
@ MEDIUM
Definition: ptotype.h:140
Interpolator
Definition: ptotype.h:126
@ SPLINE36
Definition: ptotype.h:129
@ POLY3
Definition: ptotype.h:127
@ NEARESTNEIGHBOR
Definition: ptotype.h:133
@ BILINEAR
Definition: ptotype.h:132
@ SPLINE64
Definition: ptotype.h:131
@ SINC256
Definition: ptotype.h:130
@ SPLINE16
Definition: ptotype.h:128
@ SINC1024
Definition: ptotype.h:134
Interpolator interpolator
Definition: ptotype.h:146
SpeedUp speedUp
Definition: ptotype.h:147
Definition: ptotype.h:44
QStringList lastComments
Definition: ptotype.h:402
enum Digikam::PTOType::@0 version
bool createFile(const QString &filepath)
Definition: ptotype.cpp:44
Project project
Definition: ptotype.h:398
QList< ControlPoint > controlPoints
Definition: ptotype.h:401
Stitcher stitcher
Definition: ptotype.h:399
PTOType(const QString &version)
Definition: ptotype.h:383
@ V2014
Definition: ptotype.h:375
@ PRE_V2014
Definition: ptotype.h:374
PTOType()
Definition: ptotype.h:378
QVector< Image > images
Definition: ptotype.h:400