25 #include "ExampleMixtureOfGaussians.hh"
26 #include <Base/Image/ImageIO.hh>
27 #include <Base/Common/FileHandling.hh>
33 bool ExampleMixtureOfGaussians::OnInit()
45 mainFrame->SetSizeHints(640,480,1800,1600);
48 std::vector<string> files,filesFL;
63 mainFrame->Show(
true);
64 SetTopWindow(mainFrame);
74 EVT_MENU (
ID_Quit, ExampleMixtureOfGaussiansFrame::OnQuit)
75 EVT_MENU (
ID_Grab, ExampleMixtureOfGaussiansFrame::OnGrab)
77 EVT_MENU (
ID_Show1, ExampleMixtureOfGaussiansFrame::OnShowImage1)
78 EVT_MENU (
ID_Show2, ExampleMixtureOfGaussiansFrame::OnShowImage2)
79 EVT_MENU (
ID_Show3, ExampleMixtureOfGaussiansFrame::OnShowImage3)
80 EVT_MENU (
ID_Show4, ExampleMixtureOfGaussiansFrame::OnShowImage4)
81 EVT_MENU (
ID_Show5, ExampleMixtureOfGaussiansFrame::OnShowImage5)
82 EVT_MENU (
ID_Show6, ExampleMixtureOfGaussiansFrame::OnShowImage6)
83 EVT_MENU (
ID_Show7, ExampleMixtureOfGaussiansFrame::OnShowImage7)
84 EVT_MENU (
ID_Show8, ExampleMixtureOfGaussiansFrame::OnShowImage8)
85 EVT_MENU (
ID_Show9, ExampleMixtureOfGaussiansFrame::OnShowImage9)
86 EVT_MENU (
ID_Show_FL, ExampleMixtureOfGaussiansFrame::OnShowFL)
87 EVT_MENU (
ID_Controller, ExampleMixtureOfGaussiansFrame::OnShowController)
88 EVT_TIMER (
ID_Timer, ExampleMixtureOfGaussiansFrame::OnTimer)
90 EVT_KEY_DOWN (ExampleMixtureOfGaussiansFrame::OnKey)
94 ExampleMixtureOfGaussiansFrame::
95 ExampleMixtureOfGaussiansFrame(const wxString& title,
96 const wxPoint& pos, const wxSize& size)
97 : wxFrame(NULL, -1, title, pos, size)
103 mog_->SetSmoothing(
false);
106 mogFL_->SetSmoothing(
false);
119 text.Printf(wxT(
"size: %4dx%4d"),0, 0);
120 SetStatusText(text, 2);
123 IC_ =
new ImageCanvas(
this,GetStatusBar(), 0,-1,wxDefaultPosition,
127 wxBoxSizer *vbox =
new wxBoxSizer(wxVERTICAL);
128 vbox->Add(IC_,1, wxEXPAND |wxALL |wxFIXED_MINSIZE , 5);
129 vbox->SetMinSize(640,480);
135 Timer_.SetOwner(
this, ID_Timer);
136 Timer_.Start(50,
true);
138 ShowImage_ = &CamImg_;
141 guardimagemutex =
new pthread_mutex_t;
142 guarddiffimagemutex =
new pthread_mutex_t;
143 pthread_mutex_init(guardimagemutex, NULL);
144 pthread_mutex_init(guarddiffimagemutex, NULL);
145 barrier =
new pthread_barrier_t;
146 pthread_barrier_init(barrier, NULL, 2);
151 if(fileNames != NULL && fileNames->size() > 0){
163 if(Camera_->OpenDevice() != 0){
165 BIASERR(
"No DCAM present!");
170 Camera_->InitImage(CamImgOrg_);
171 CamImgOrgRGB_.Init(CamImgOrg_.GetWidth(), CamImgOrg_.GetHeight(),3);
174 pthread_create(&grabthread, NULL, grabImages_,
this);
175 pthread_create(&processthread, NULL, processImages_,
this);
180 if(fileNames != NULL && fileNames->size() > 0){
189 CameraFL_->PreGrab();
194 wxMenu *menuFile =
new wxMenu;
195 menuFile->Append(
ID_Quit, wxT(
"E&xit") );
198 wxMenu *menuShow =
new wxMenu;
199 menuShow->Append(
ID_Show1, wxT(
"Original Image") );
200 menuShow->Append(
ID_Show2, wxT(
"Normalized Image") );
201 menuShow->Append(
ID_Show3, wxT(
"Weight Image") );
202 menuShow->Append(
ID_Show4, wxT(
"Difference Image") );
203 menuShow->Append(
ID_Show5, wxT(
"Visualization") );
204 menuShow->AppendSeparator();
205 if(CameraFL_ != NULL){
208 wxT(
"&Show float images"),
210 pCheckItemFL_->Check(
false);
215 wxMenuBar *menuBar =
new wxMenuBar;
216 menuBar->Append(menuFile, wxT(
"&File"));
217 menuBar->Append(menuShow, wxT(
"&Show"));
248 bShowImageFL_ =
event.IsChecked();
271 pthread_barrier_wait(obj->
barrier);
280 pthread_barrier_wait(obj->
barrier);
297 double fps = 1000000.0 / StopWatch_.GetRealTime();
302 text.Printf(wxT(
"%05d %2.1f fps "),FrameCounter_, fps);
303 SetStatusText(text, 2);
305 pthread_mutex_lock(guardimagemutex);
306 CamImg_ = CamImgOrgRGB_;
307 pthread_mutex_unlock(guardimagemutex);
311 w = CamImg_.GetWidth();
312 h = CamImg_.GetHeight();
314 text.Printf(wxT(
"size: %4dx%4d"),w, h);
315 SetStatusText(text, 1);
318 if (w != Width_ || h != Height_)
322 IC_->SetSize(w+50,h+80);
323 SetMinSize(wxSize(w+50,h+80));
330 if(CameraFL_ != NULL){
331 CameraFL_->GrabSingle(CamImgOrgFL_);
333 if (CamImgRescaledFL_.IsEmpty())
334 CamImgRescaledFL_.
Init(CamImgOrgFL_.GetWidth()/2,CamImgOrgFL_.GetHeight()/2,1);
336 pRescaleFilter.
Downsample (CamImgOrgFL_,CamImgFL_,2);
340 CamImgFL_ = CamImgOrgFL_;
342 w = CamImgFL_.GetWidth();
343 h = CamImgFL_.GetHeight();
344 CamImgFL_.SetROI(15,15,w-15,h-15);
346 mogFL_->Apply(CamImgFL_);
352 mog_->AllowCreationOfNewDistributions(
false);
353 mog_->SetUpdateFactor(0.0f);
354 mog_->EnableCleanup(
true,
true,
false);
356 switch (dCurImage_) {
360 CamImgFL_.ScaleShiftBetween(0,255);
364 else ShowImage_ = &CamImg_;
368 mogFL_->GetNormalizedImage(tmp);
370 mog_->GetNormalizedImage(tmp);
374 ShowImage_ = &CamImgNormalizedChar_;
378 mogFL_->GetWeightImage(tmp);
381 mog_->GetMatchValueImage(tmp);
385 ShowImage_ = &WeightImgChar_;
389 mogFL_->GetDifferenceImage(DifferenceImgChar_);
391 mog_->GetDifferenceImage(DifferenceImgChar_);
392 ShowImage_ = &DifferenceImgChar_;
396 mogFL_->GetDifferenceImageWithVisuals(DifferenceImgCharRGB_);
398 mog_->GetDifferenceImageWithVisuals(DifferenceImgCharRGB_);
399 ShowImage_ = &DifferenceImgCharRGB_;
403 ShowImage_ = &CamImg_;
408 IC_->Show(*ShowImage_,
"Camera Image");
410 Timer_.Start(30,
true);
void OnShowImage2(wxCommandEvent &event)
pthread_mutex_t * guardimagemutex
pthread_barrier_t * barrier
void OnShowImage6(wxCommandEvent &event)
void BIASGui_EXPORT ConsoleRedirectIO(std::string name=std::string(""))
Extra Console for WIN32 WinMain gui applications.
wxString AsciiToWx(const char *thestring)
Converts a C string to a wxString.
void CopyIn_NoInit(void *data)
Take some data and fill it into the Image.
void OnKey(wxKeyEvent &event)
void OnShowImage3(wxCommandEvent &event)
BIAS::VideoSource * Camera_
int ScaleShiftBetween(double Min, double Max)
scales and shifts image so afterwards every pixel has a value between Min and Max ...
void OnQuit(wxCommandEvent &event)
display image in wx application, provides zoom and investigation functionality
void OnShowFL(wxCommandEvent &event)
void OnShowController(wxCommandEvent &event)
This class VideoSource_DCAM implements access to IEEE1394 (Firewire, iLink) cameras following the DCa...
Down-, Upsampling routines and Resize.
int Downsample(const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
generic downsample function.
unsigned int GetWidth() const
void OnGrabContinuous(wxCommandEvent &event)
void OnGrab(wxCommandEvent &event)
int InitWeights(const int maxWeight, const int minWeight, const float errorMargin)
init weights for background/object distinction
void OnShowImage4(wxCommandEvent &event)
virtual int OpenDevice(std::string Prefix, std::string Postfix, int DigitCount, int PictureCount, int StartCount=0)
this opens all images given by prefix, postfix, Digitcount and PictureCount e.g.
void OnShowImage5(wxCommandEvent &event)
void OnShowImage7(wxCommandEvent &event)
static int ConvertST(const BIAS::ImageBase &source, BIAS::ImageBase &dest, ImageBase::EStorageType targetST)
Function to convert the storage type of images e.g.
color values, 3 channels, order: red,green,blue
void OnShowImage1(wxCommandEvent &event)
static std::string LeadingZeroString(const int &n, const unsigned int &digits=DEFAULT_LEADING_ZEROS)
Create a string with leading zeroes from number.
unsigned int GetHeight() const
static int ParseListFile(const std::string &ListFileName, std::vector< std::string > &LinesInFile)
Extracts lines from passed file.
BIAS::MixtureOfGaussians< unsigned char > * mog_
static int Save(const std::string &filename, const ImageBase &img, const enum TFileFormat FileFormat=FF_auto, const bool sync=BIAS_DEFAULT_SYNC, const int c_jpeg_quality=BIAS_DEFAULT_IMAGE_QUALITY, const bool forceNewID=BIAS_DEFAULT_FORCENEWID, const bool &writeMetaData=true)
Export image as file using extrnal libs.
int SetROI(unsigned int UpperLeftX, unsigned int UpperLeftY, unsigned int LowerRightX, unsigned int LowerRightY)
deprecated, use SetROICorners()
void Init(unsigned int Width, unsigned int Height, unsigned int channels=1, enum EStorageType storageType=ST_unsignedchar, const bool interleaved=true)
calls Init from ImageBase storageType is ignored, just dummy argument
const StorageType * GetImageData() const
overloaded GetImageData() from ImageBase
enum EColorModel GetColorModel() const
virtual int GrabSingle(BIAS::Camera< unsigned char > &image)
void OnShowImage9(wxCommandEvent &event)
void CreateMenu()
Creates the menu of the main window.
BIAS::Camera< unsigned char > CamImgOrg_
(8bit) unsigned char image storage type
void OnTimer(wxTimerEvent &event)
pthread_mutex_t * guarddiffimagemutex
void OnShowImage8(wxCommandEvent &event)
static int ToRGB(const Image< StorageType > &source, Image< StorageType > &dest)
Create a RGB converted copy of source image in this.
int Apply(BIAS::Image< StorageType > &in)
update calculations with new image the image has to be formatted correctly, e.g for MoG on HSL images...
void InitCameraFL(std::vector< std::string > *fileNames=NULL)
void InitCamera(std::vector< std::string > *fileNames=NULL)
Initialize cameras with param file.
static void * processImages_(void *thisvisu)
This class simulates a video device by loading images from disk.
BIAS::Camera< unsigned char > CamImgOrgRGB_
static void * grabImages_(void *thisvisu)