Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
WrapBias2Ipl.hh
1 #ifndef __WrapBias2Ipl__hh__
2 #define __WrapBias2Ipl__hh__
3 
4 #include <bias_config.h>
5 
6 
7 #ifndef BIAS_HAVE_OPENCV
8 # error BIAS_HAVE_OPENCV not defined. Please recompile BIAS with USE_OPENCV to use WrapBias2Ipl.
9 #endif
10 
11 #ifdef BIAS_HAVE_OPENCV
12 
13 #include <Base/Image/ImageBase.hh>
14 
15 // forwrad declaration for cxtypes.h to avoid cv.h inclusion:
16 typedef struct _IplImage IplImage;
17 
18 #define ALLOW_ALPHA_WIN_DEFAULT true
19 
20 namespace BIAS {
21 
22  /** @class WrapBias2Ipl
23  @brief wrapper around a BIAS image to be used as an OpenCv IPlimage
24  with shared data area.
25  @author Jan Woetzel 07/2005 */
26  class BIASImageBase_EXPORT WrapBias2Ipl {
27  public:
28  ~WrapBias2Ipl();
29  WrapBias2Ipl();
30  //WrapBias2Ipl(BIAS::ImageBase * PtrImgBias);
31  WrapBias2Ipl(const BIAS::ImageBase * PtrImgBias);
32 
33  /** create the internal IPL image which shares the data area with the src Bias image.
34  And save the pointer to this source BIAS img.
35  @return 0 for succes, other=error
36  @author Jan Woetzel 07/2005 */
37  int Bind(const BIAS::ImageBase * p_src);
38 
39  /** helper function to create a slave ipl image which shares the data area with the master ref. BIAS image
40  Ipl image is slave of BIAS image.
41  @return 0 for succes, other=error
42  @author Jan Woetzel 07/2005 */
43  static int CreateIplImageShared(const BIAS::ImageBase * p_src, IplImage * &p_dest);
44 
45  /** helper function to create a copy (!) BIAS image from a master Ipl image
46  Data area is NOT shared but copied from ipl to bias. JW */
47  static int CreateBiasImageCopy(const IplImage * p_src, BIAS::ImageBase & dest);
48 
49  /** @return false if the wrapped images are inconsistent JW */
50  bool Consistent() const;
51 
52  /** wrapper for cvWaitKey
53  @return pressed key (if any)
54  JW 2005 */
55  static int WaitKey(const unsigned int & delay=0);
56 
57  /** Display img as simple popup window.
58  @param waitForKey if true delaMsec is waited for keypres. 0=forever.
59  @param delayMsec if waitForKey is true wait for key with 0=forever, see cvWaitkey.
60  @return pressed key (if any)
61  @author JW 2005
62  TODO: add interface this in BIAS/Gui as GuiCV with static functions including sliders, mouse motion etc. (jw)
63  */
64  static int Display(
65  const IplImage* img,
66  const std::string & DestWin,
67  const bool & autoresize,
68  const bool & moveToTopLeft,
69  const bool & waitForKey,
70  const unsigned int & delayMsec,
71  const float & scale=DEFAULT_32to8_scale,
72  const bool & allowAlphaWindow=ALLOW_ALPHA_WIN_DEFAULT
73  );
74 
75  /** Display img as simple popup window.
76  If you experience color channel Seq. problems, use highgui with by RGB/BGR fix(jw)
77  @param delayMsec:
78  @return pressed key (if any)
79  @author JW */
80  int Display(const bool & waitForKey=false,
81  const unsigned int & delayMsec=0,
82  const float & scale=DEFAULT_32to8_scale
83  ) const;
84 
85  int Display(const char* DestWin,
86  const bool & autoresize=true,
87  const bool & moveToTopLeft=true,
88  const bool & waitForKey=false,
89  const unsigned int & delayMsec=0,
90  const float & scale=DEFAULT_32to8_scale,
91  const bool & allowAlphaWindow=ALLOW_ALPHA_WIN_DEFAULT
92  ) const;
93 
94  /** Display img as simple popup HighGUI window.
95  @param actually scale is used only for float to 8 Byte range conversion
96  @return pressed key (if any)
97  @author Jan Woetzel 2005 */
98  int Display(
99  const std::string & DestWin,
100  const bool & autoresize=true,
101  const bool & moveToTopLeft=true,
102  const bool & waitForKey=false,
103  const unsigned int & delayMsec=0,
104  const float & scale=DEFAULT_32to8_scale,
105  const bool & allowAlphaWindow=ALLOW_ALPHA_WIN_DEFAULT
106  ) const;
107 
108  /** 32 bit float to displayable 8 bit conversion
109  Both images should be pre-initilaized to equal size and correct storage type.
110  @param scale mapping function, e.g. 255 for 0..1 --> 0..255
111  @author Jan Woetzel */
112  static void ConvertIPL32to8(const IplImage* src32,
113  IplImage* dest8,
114  const float & scale=DEFAULT_32to8_scale
115  );
116 
117  /** wrapper for CV destroiing all HighGUI windows JW */
118  static void DestroyAllWindows();
119 
120  /* wrapper for CV destroiing one HighGUI window JW */
121  static void DestroyWindow( const char* name );
122  static void DestroyWindow( const std::string & name );
123 
124  /* wrapper for OpenCV,changes size of HighGUI window JW */
125  static void ResizeWindow( const char* name,
126  const unsigned int width,
127  const unsigned int height );
128  static void ResizeWindow( const std::string & name,
129  const unsigned int width,
130  const unsigned int height );
131 
132  /* wrapper for OpenCV, moves HighGUI window position JW */
133  static void MoveWindow( const char* name, const int newX, const int newY );
134  static void MoveWindow( const std::string & name, const int newX, const int newY );
135 
136  /* wrapper for OPenCV, creates a HighGUI window JW */
137  static void NamedWindow(const char* name, const int flags=1);
138  static void NamedWindow(const std::string& name, const int flags=1);
139 
140  public:
142  //bool p_imgBiasDestroyable;
143 
144  IplImage * p_imgIpl;
146  };
147 } // namespace BIAS
148 #endif // BIAS_HAVE_OPENCV
149 
150 #endif //__WrapBias2Ipl__hh__
const BIAS::ImageBase * p_imgBias
wrapper around a BIAS image to be used as an OpenCv IPlimage with shared data area.
Definition: WrapBias2Ipl.hh:26
This is the base class for images in BIAS.
Definition: ImageBase.hh:102