Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ImageAttributes.hh
1 #ifndef _IMAGEATTRIBUTES_H_INCLUDED_
2 #define _IMAGEATTRIBUTES_H_INCLUDED_
3 #include <Base/Common/BIASpragmaStart.hh>
4 
5 #include <bias_config.h>
6 #include <math.h>
7 
8 #include <Base/Debug/Debug.hh>
9 #include "ExifTag.hh"
10 #include <iostream>
11 #include <vector>
12 #include <string>
13 #include <map>
14 
15 
16 
17 /// return code for success:
18 #define BIAS_IMAGEATTRIBUTES_SUCCESS 0
19 
20 #define D_EXIF 1
21 
22 #ifdef BIAS_HAVE_IMAGEMAGICKLIB
23 # include <Magick++.h>
24 #endif
25 
26 // Begin namespace BIAS
27 namespace BIAS {
28 
29  /** @class ImageAttributes
30  @todo Add Image Attributes write functionality to write meta data directly to images EXIF Tags, comments etc.
31  @brief contains all atribute info and values of e.g. a file.
32  @author Jan Woetzel 10/2004 */
33  class BIASImageBase_EXPORT ImageAttributes
34  : public std::vector< ExifTag >, public BIAS::Debug
35  {
36  public:
39 
40  /** @brief main entry routine to read all EXIF tags from the header of image file.
41  @return BIAS_IMAGEATTRIBUTES_SUCCESS if OK.
42  @param filename image to ping and read header from.
43  @author Jan Woetzel */
44  int Read(const std::string & filename);
45 
46  /** @return BIAS_IMAGEATTRIBUTES_SUCCESS if reading was OK, negative number in case of error.
47  @param filename image file to read attributes form header.
48  @return 0 = ok, -1=Getting Attr. with ImageMagick failed, -2=Failed unspecified, -3=mip image, no attributes
49  @author Jan Woetzel */
50  int ReadMagickPP(const std::string & filename);
51 
52 #ifdef BIAS_HAVE_IMAGEMAGICKLIB
53  /** @brief direct interface to Magick::IMage to be able to read the XIF tags of an already opened image.
54  @return BIAS_IMAGEATTRIBUTES_SUCCESS;BIAS_EXIFTAGTABLE_SUCCESS
55  @param filename image to ping and read header from.
56  @author Jan Woetzel */
57  int ReadMagickPP(Magick::Image & img);
58 #endif
59 
60 
61  /** initialize me vector with all known EXIF tags */
62  void InitExifTags();
63 
64  /** print the content of this to os
65  @param printAll true prints all tags, false only those whose value is not empty.
66  */
67  std::ostream& Print(std::ostream& os=std::cout,
68  const bool printAll=false) const;
69 
70  /** @brief compute focallength in meters
71  @return 0:ok, <0:information missing, >0:missing information guessed
72  @author koeser 07/2005 */
73  int GetFocalLengthMeter(double &fm);
74 
75  /** @brief compute focallength in pixels
76  @return 0:ok, <0:information missing, >0:missing information guessed
77  @author koeser 07/2005 */
78  int GetFocalLengthXPixel(double &fp);
79 
80  /** @brief compute focallength in pixels
81  @return 0:ok, <0:information missing, >0:missing information guessed
82  @author koeser 07/2005 */
83  int GetFocalLengthYPixel(double &fp);
84 
85  /** @brief compute pixel size in meter
86  @return 0:ok, <0:information missing, >0:missing information guessed
87  @author koeser 07/2005 */
88  int GetPixelSizeXMeter(double &p);
89 
90  /** @brief compute pixel size in meter
91  @return 0:ok, <0:information missing, >0:missing information guessed
92  @author koeser 07/2005 */
93  int GetPixelSizeYMeter(double &p);
94 
95  /** @brief compute field of view in degree
96  @return 0:ok, <0:information missing, >0:missing information guessed
97  @author koeser 07/2005 */
98  int GetFieldOfViewDegree(double &x, double& y);
99 
100  /** @brief get width and height of image
101  @return 0:ok, <0:information missing, >0:missing information guessed
102  @author koeser 07/2005 */
103  int GetImageDimensions(int& width, int& height);
104 
105  /** @brief look up principal point
106  @return 0:ok, <0:information missing, >0:missing information guessed
107  @author koeser 07/2005 */
108  int GetPrincipalPoint(double& x, double& y);
109 
110  /** @brief look up camera make and model
111  @return 0:ok, <0:information missing, >0:missing information guessed
112  @author koeser 07/2005 */
113  int GetHardwareName(std::string& Make, std::string& Model);
114  /** combine Make, Model and focallength to one special identifier
115  @author evers 2009-07 */
116  std::string GetIdentifier();
117 
118  protected:
119  bool GetString_(const std::string& key, std::string& value);
120  bool GetRational_(const std::string& key, double& value);
121  bool GetShort_(const std::string& key, int& value);
122 
123  private: // avoid DLL export by private
124  std::map<std::string, unsigned int> mapValidTags_;
125 
126  }; // end of class
127 } // end namespace
128 
129 
130 // ------------------
131 
132 /** @brief output operator for ExifTable
133 @author Jan Woetzel */
134 BIASImageBase_EXPORT std::ostream& operator<<(std::ostream& os,
135  const BIAS::ImageAttributes &attr);
136 
137 
138 #include <Base/Common/BIASpragmaEnd.hh>
139 
140 #endif
std::ostream & operator<<(std::ostream &os, const AppData &ad)
contains all atribute info and values of e.g. a file.