Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleMixtureOfGaussians.hh
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003, 2004 (see file CONTACTS for details)
5 Multimediale Systeme der Informationsverarbeitung
6 Institut fuer Informatik
7 Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 
26 /**
27  * @example ExampleMixtureOfGaussians.cpp
28  @relates MixtureOfGaussians
29  @brief example for usage of MixtureOfGaussians scene change detection. see constructor for
30  * parameters used in this example. it has been tested with point grey grasshopper camera
31  * and a region of interest has been set specifically for this.
32  @ingroup g_examples
33  @author fkellner
34 */
35 
36 #ifndef __EXAMPLE_MIXTURE_OF_GAUSSIANS_FRAME_HH__
37 #define __EXAMPLE_MIXTURE_OF_GAUSSIANS_FRAME_HH__
38 
39 
40 #include <wx/wx.h>
41 #include <wx/toolbar.h>
42 
43 
44 #include <Gui/StringConv.hh>
45 #include <Gui/ImageCanvas.hh>
46 
47 #include <Base/Common/BIASpragmaStart.hh>
48 #include <bias_config.h>
49 #include <Image/Camera.hh>
50 #include <Image/MixtureOfGaussians.hh>
51 #include <Base/Image/ImageIO.hh>
52 #include <Base/Debug/TimeMeasure.hh>
53 #include <Filter/Rescale.hh>
54 
55 #include <VideoSource/VideoSource_Base.hh>
56 #include <Gui/VideoSource_Controller.hh>
57 #ifdef BIAS_HAVE_DCAM
58 # include <VideoSource/VideoSource_DCAM.hh>
59 #endif // BIAS_HAVE_DCAM
60 
61 #include <VideoSource/VideoSource_Disk.hh>
62 #include <Utils/Param.hh>
63 
64 #include <Gui/ConsoleRedirectIO.hh>
65 
66 
67 namespace BIAS {
68 
69  // event ids
70  enum {
71  ID_Quit = 42,
87  };
88 
89  /** \internal */
90  class ExampleMixtureOfGaussians: public wxApp
91  {
92  virtual bool OnInit();
93  };
94 
95  /** \internal */
96  class ExampleMixtureOfGaussiansFrame : public wxFrame
97  {
98  public:
99 
100  ExampleMixtureOfGaussiansFrame(const wxString& title, const wxPoint& pos,
101  const wxSize& size);
103 
104  /** Initialize cameras with param file. Only call after InitParams().
105  */
106  void InitCamera(std::vector<std::string>* fileNames=NULL);
107  void InitCameraFL(std::vector<std::string>* fileNames=NULL);
108 
109  /** Creates the menu of the main window.
110  */
111  void CreateMenu();
112 
113  /** Stores one image from all activated cameras
114  */
115  void GrabImage();
116 
117  protected:
118 
119  // functions for event handling
120  void OnQuit(wxCommandEvent& event);
121  void OnGrab(wxCommandEvent& event);
122  void OnGrabContinuous(wxCommandEvent& event);
123  void OnShowImage1(wxCommandEvent& event);
124  void OnShowImage2(wxCommandEvent& event);
125  void OnShowImage3(wxCommandEvent& event);
126  void OnShowImage4(wxCommandEvent& event);
127  void OnShowImage5(wxCommandEvent& event);
128  void OnShowImage6(wxCommandEvent& event);
129  void OnShowImage7(wxCommandEvent& event);
130  void OnShowImage8(wxCommandEvent& event);
131  void OnShowImage9(wxCommandEvent& event);
132  void OnShowFL(wxCommandEvent& event);
133  void OnShowController(wxCommandEvent& event);
134  void OnTimer(wxTimerEvent& event);
135  void OnKey(wxKeyEvent& event);
136 
137  unsigned int FrameCounter_;
138  unsigned int Width_, Height_;
139  unsigned int dCurImage_;
140 
143  // camera images
146 
148 
152 
160 
162 
164 
165  wxTimer Timer_;
167  wxMenuItem* pCheckItemFL_;
168 
171 
174 
175  pthread_mutex_t* guardimagemutex;
176  pthread_mutex_t* guarddiffimagemutex;
177  pthread_barrier_t* barrier;
178  pthread_t grabthread;
179  pthread_t processthread;
180  static void* grabImages_(void *thisvisu);
181  static void* processImages_(void *thisvisu);
183  DECLARE_EVENT_TABLE()
184  }; // end of class
185 
186 } // end of namespace MIP
187 
188 #include <Base/Common/BIASpragmaEnd.hh>
189 
190 #endif // __EXAMPLE_MIXTURE_OF_GAUSSIANS_FRAME_HH__
Defines a common interface to different devices.
BIAS::Camera< unsigned char > DifferenceImgCharRGB_
display image in wx application, provides zoom and investigation functionality
Definition: ImageCanvas.hh:38
Helper class to store blob corners.
ExampleMixtureOfGaussiansFrame(const wxString &title, const wxPoint &pos, const wxSize &size)
BIAS::Camera< unsigned char > CamImgRescaled_
void GrabImage()
Stores one image from all activated cameras.
BIAS::Camera< unsigned char > DifferenceImgChar_
BIAS::MixtureOfGaussians< unsigned char > * mog_
BIAS::Camera< unsigned char > WeightImgChar_
BIAS::Camera< unsigned char > * ShowImage_
void CreateMenu()
Creates the menu of the main window.
BIAS::Camera< unsigned char > CamImgNormalizedChar_
void InitCameraFL(std::vector< std::string > *fileNames=NULL)
class TimeMeasure contains functions for timing real time and cpu time.
Definition: TimeMeasure.hh:111
void InitCamera(std::vector< std::string > *fileNames=NULL)
Initialize cameras with param file.
BIAS::MixtureOfGaussians< float > * mogFL_