Basic Image AlgorithmS Library 2.8.0

WrapBias2Ipl.hh

00001 #ifndef __WrapBias2Ipl__hh__
00002 #define __WrapBias2Ipl__hh__
00003 
00004 #include <bias_config.h>
00005 
00006 
00007 #ifndef BIAS_HAVE_OPENCV
00008 #  error BIAS_HAVE_OPENCV not defined. Please recompile BIAS with USE_OPENCV to use WrapBias2Ipl.
00009 #endif
00010 
00011 #ifdef BIAS_HAVE_OPENCV
00012 
00013 #include <Base/Image/ImageBase.hh>
00014 
00015 // forwrad declaration for cxtypes.h to avoid cv.h inclusion:
00016 typedef struct _IplImage IplImage;
00017 
00018 #define ALLOW_ALPHA_WIN_DEFAULT true
00019 
00020 namespace BIAS {
00021 
00022   /** @class WrapBias2Ipl
00023       @brief wrapper around a BIAS image to be used as an OpenCv IPlimage
00024       with shared data area. 
00025       @author Jan Woetzel 07/2005 */
00026   class BIASImageBase_EXPORT WrapBias2Ipl {
00027   public:
00028     ~WrapBias2Ipl();
00029     WrapBias2Ipl();
00030     //WrapBias2Ipl(BIAS::ImageBase * PtrImgBias);
00031     WrapBias2Ipl(const BIAS::ImageBase * PtrImgBias);
00032 
00033     /** create the internal IPL image which shares the data area with the src Bias image. 
00034     And save the pointer to this source BIAS img. 
00035     @return 0 for succes, other=error
00036     @author Jan Woetzel 07/2005 */
00037     int Bind(const BIAS::ImageBase * p_src);
00038 
00039     /** helper function to create a slave ipl image which shares the data area with the master ref. BIAS image
00040     Ipl image is slave of BIAS  image.
00041     @return 0 for succes, other=error
00042     @author Jan Woetzel 07/2005 */
00043     static int CreateIplImageShared(const BIAS::ImageBase * p_src, IplImage * &p_dest);
00044 
00045     /** helper function to create a copy (!) BIAS image from a master Ipl image 
00046     Data area is NOT shared but copied from ipl to bias. JW */
00047     static int CreateBiasImageCopy(const IplImage * p_src, BIAS::ImageBase & dest);
00048 
00049     /** @return false if the wrapped images are inconsistent JW */
00050     bool Consistent() const;
00051 
00052     /** wrapper for cvWaitKey 
00053     @return pressed key (if any) 
00054     JW 2005 */
00055     static int WaitKey(const unsigned int & delay=0);
00056 
00057     /** Display img as simple popup window. 
00058     @param waitForKey if true delaMsec is waited for keypres. 0=forever.
00059     @param delayMsec if waitForKey is true wait for key with 0=forever, see cvWaitkey.
00060     @return pressed key (if any)
00061     @author JW 2005 
00062     TODO: add interface this in BIAS/Gui as GuiCV with static functions including sliders, mouse motion etc. (jw)
00063     */
00064     static int Display(
00065       const IplImage* img,
00066       const std::string & DestWin, 
00067       const bool & autoresize,
00068       const bool & moveToTopLeft,
00069       const bool & waitForKey,
00070       const unsigned int & delayMsec,
00071       const float & scale=DEFAULT_32to8_scale,
00072       const bool & allowAlphaWindow=ALLOW_ALPHA_WIN_DEFAULT
00073       );
00074 
00075     /** Display img as simple popup window. 
00076     If you experience color channel Seq. problems, use highgui with by RGB/BGR fix(jw)
00077     @param delayMsec: 
00078     @return pressed key (if any)
00079     @author JW */
00080     int Display(const bool & waitForKey=false, 
00081       const unsigned int & delayMsec=0,
00082       const float & scale=DEFAULT_32to8_scale
00083       ) const;
00084 
00085     int Display(const char* DestWin, 
00086       const bool & autoresize=true,
00087       const bool & moveToTopLeft=true,
00088       const bool & waitForKey=false,
00089       const unsigned int & delayMsec=0,
00090       const float & scale=DEFAULT_32to8_scale,
00091       const bool & allowAlphaWindow=ALLOW_ALPHA_WIN_DEFAULT
00092       ) const;
00093 
00094     /** Display img as simple popup HighGUI window. 
00095     @param actually scale is used only for float to 8 Byte range conversion 
00096     @return pressed key (if any) 
00097     @author Jan Woetzel 2005 */
00098     int Display(
00099       const std::string & DestWin, 
00100       const bool & autoresize=true,
00101       const bool & moveToTopLeft=true,
00102       const bool & waitForKey=false,
00103       const unsigned int & delayMsec=0,
00104       const float & scale=DEFAULT_32to8_scale,
00105       const bool & allowAlphaWindow=ALLOW_ALPHA_WIN_DEFAULT
00106       ) const;
00107 
00108     /** 32 bit float to displayable 8 bit conversion
00109     Both images should be pre-initilaized to equal size and correct storage type.
00110     @param scale mapping function, e.g. 255 for 0..1 --> 0..255
00111     @author Jan Woetzel */
00112     static void ConvertIPL32to8(const IplImage* src32, 
00113       IplImage* dest8,
00114       const float & scale=DEFAULT_32to8_scale
00115       );
00116 
00117     /** wrapper for CV destroiing all HighGUI windows JW */
00118     static void DestroyAllWindows();
00119 
00120     /* wrapper for CV destroiing one HighGUI window JW */
00121     static void DestroyWindow( const char* name );
00122     static void DestroyWindow( const std::string & name );
00123 
00124     /* wrapper for OpenCV,changes size of HighGUI window JW */
00125     static void ResizeWindow( const char* name, 
00126       const unsigned int width, 
00127       const unsigned int height );
00128     static void ResizeWindow( const std::string & name, 
00129       const unsigned int width, 
00130       const unsigned int height );
00131 
00132     /* wrapper for OpenCV, moves HighGUI window position JW */
00133     static void MoveWindow( const char* name, const int newX, const int newY );
00134     static void MoveWindow( const std::string & name, const int newX, const int newY );
00135 
00136     /* wrapper for OPenCV, creates a HighGUI window JW */
00137     static void NamedWindow(const char* name, const int flags=1);
00138     static void NamedWindow(const std::string& name, const int flags=1);
00139 
00140   public:
00141     const BIAS::ImageBase* p_imgBias;
00142     //bool p_imgBiasDestroyable;
00143 
00144     IplImage * p_imgIpl;
00145     bool p_imgIplDestroyable;
00146   };
00147 } // namespace BIAS
00148 #endif // BIAS_HAVE_OPENCV
00149 
00150 #endif //__WrapBias2Ipl__hh__
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends