Hauptseite | Liste aller Namensbereiche | Klassenhierarchie | Alphabetische Liste | Übersicht | Auflistung der Dateien | Elemente eines Namensbereiches | Datenstruktur-Elemente | Datei-Elemente

correlation.h

gehe zur Dokumentation dieser Datei
00001 #ifndef CORRELATIONOUTPUT_H
00002 #define CORRELATIONOUTPUT_H
00003 
00004 #include "output.h"
00005 #include "../recognition/correlation.h"
00006 #include "../microadam.h"
00007 #include <iostream>
00008 
00009 using namespace std;
00010 
00011 extern "C"
00012 {
00013   #include <opencv/highgui.h>
00014 }
00015 
00016 namespace seemicro
00017 {
00018 
00019 class CorrelationOutput : public OutputModule
00020 {
00021   CorrelationModule& c;
00022   Micro& micro;
00023   MicroAdam *adam;
00024   IplImage *back;
00025 
00029   static CorrelationOutput *home;
00030 
00031   int back_threshold;
00032 
00036   int radius;
00037 
00041   int ialpha;
00042 
00046   int ibeta;
00047 
00048 public:
00049   CorrelationOutput(CorrelationModule& Ac) :
00050     c(Ac), micro(c.micro)
00051   {
00052     home = this;
00053     adam = dynamic_cast<MicroAdam*>(&micro);
00054     back_threshold = 1;
00055     radius = int(c.kparams->radius);
00056     ialpha = int(c.kparams->alpha*180/M_PI);
00057     back = cvCreateImage(cvSize(c.src.img->width,
00058       c.src.img->height), IPL_DEPTH_8U, 3);
00059 
00060     if(1 != cvNamedWindow("Correlation", 1))
00061     { cerr << "cvNamedWindow(Correlation): error" << endl; }
00062     if(DEBUGLEVEL>=2) cerr << "c.arm_auch=" << c.arm_auch
00063       << " radius=" << radius
00064       << " ialpha=" << ialpha << endl;
00065 
00066     cvCreateTrackbar("Rad-Radius", "Correlation", &radius,
00067       c.src.img->height/2, callback);
00068     cvCreateTrackbar("Alpha", "Correlation", &ialpha, 360, callback);
00069 
00070     if(adam)
00071     {
00072       ibeta = int(c.kparams->alpha*180/M_PI+180);
00073       cvCreateTrackbar("Beta", "Correlation", &ibeta, 360, callback);
00074       int ret = cvCreateTrackbar("Kern mit Arm(en)?", "Correlation",
00075         &c.arm_auch, 1, callback);
00076       if(DEBUGLEVEL>=2) cerr << "Rückgabe: " << ret << endl;
00077     }
00078 
00079     cvCreateTrackbar("Grün-Schwellwert", "Correlation", &back_threshold, 50,
00080       callback);
00081 
00082     if(DEBUGLEVEL>=2) cerr << " created.";
00083   }
00084 
00085   ~CorrelationOutput()
00086   {
00087     cvReleaseImage(&back);
00088     cvDestroyWindow("Correlation");
00089   }
00090 
00091   void output(bool keyframe)
00092   {
00093     if(!c.outputChanged) return;
00094     if(!keyframe) return;
00095     doubles2IplImage(1/150.0, back, (double*)c.ffback,
00096         back->width, back->height, above_threshold);
00097     cvShowImage("Correlation", back);
00098     radius = int(c.micro.radius);
00099     cvSetTrackbarPos("Rad-Radius", "Correlation", radius);
00100     cvResizeWindow("Correlation", back->width+15, back->height+280);
00101     c.outputChanged = false;// sollte eigentlich erst zurückgesetzt werden,
00102     // wenn alle Module durchgelaufen sind, sonst können unsere
00103     // Nachfolger nicht reagieren
00104   }
00105 
00106   void parametrize(void)
00107   {
00108     c.kparams->radius = radius;
00109     c.kparams->alpha = double(ialpha)*M_PI/180.0;
00110     if(adam)
00111     {
00112       MicroAdam *kadam = dynamic_cast<MicroAdam*>(c.kparams);
00113       kadam->beta = double(ibeta-180)/180*M_PI;
00114       adam->beta = kadam->beta;
00115     }
00116 
00117     // damit beim Einzeichnen die Kernel-Parameter verwendet werden
00118     micro.mitte = c.kparams->mitte;
00119     micro.mitteValid = true;
00120     micro.alpha = c.kparams->alpha;
00121 
00122     c.paramChanged = true;
00123   }
00124 
00125   static void callback(int dummy=0)
00126   {
00127     if(!home) return;
00128     home->parametrize();
00129   }
00130 
00131   static double threshold_value(void)
00132   {
00133     return exp(home->back_threshold*0.05)*255;
00134   }
00135 
00136   static int above_threshold(double v)
00137   {
00138     return v > home->threshold_value();
00139   }
00140 
00141 }; // CorrelationOutput
00142 
00143 } // seemicro
00144 
00145 #endif
00146 

Erzeugt am Sun Oct 3 12:52:47 2004 für seemicro von doxygen 1.3.2