Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

KalmanTemplate.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Tracking_KalmanTemplate_h
00002 #define Impala_Core_Tracking_KalmanTemplate_h
00003 
00004 #include "Core/Array/Pattern/PatGenConv2d.h"
00005 #include "Core/Array/Pattern/PatBinaryPixOp.h"
00006 
00007 #include "Core/Tracking/ObjectRepresentation.h"
00008 #include "Core/Tracking/SearcherAroundLastPos.h"
00009 #include "Core/Tracking/FunctorKalman.h"
00010 
00011 namespace Impala
00012 {
00013 namespace Core
00014 {
00015 namespace Tracking
00016 {
00017 
00021 class KalmanTemplate : public ObjectRepresentation
00022 {
00023 public:
00024     KalmanTemplate()
00025     {
00026         mTemplate = new Array::Array2dVec3Real64(0, 0, 0, 0);
00027         mScratch = new Array::Array2dVec3UInt8(0, 0, 0, 0);
00028         mTemplatePrediction = Array::ArrayClone<Array::Array2dVec3Real64,Array::Array2dVec3Real64>(mTemplate);
00029     }
00030 
00031     virtual ~KalmanTemplate()
00032     {
00033         delete mScratch;
00034         delete mTemplate;
00035         delete mTemplatePrediction;
00036     }
00037 
00040     void Update(/*const*/ Array::Array2dVec3Real64& image, const Position& pos)
00041     {
00042         Array::Array2dVec3Real64* temp = new Array::Array2dVec3Real64(pos.size.x, pos.size.y, 0, 0);
00043         Array::Pattern::PatSet(temp, &image, pos.translation.x, pos.translation.y, pos.size.x, pos.size.y, 0, 0);
00044         Array::Pattern::PatBinaryPixOp(mTemplatePrediction, mTemplate, temp, mKalman);
00045         delete temp;
00046         mKalman.UpdateKalman();
00047         if(!mKalman.mOcclusion)
00048         {
00049             Array::Pattern::PatSet(mTemplate, mTemplatePrediction, 0, 0, mTemplate->CW(), mTemplate->CH(), 0, 0);
00050         }
00051 
00052         Array::Pattern::PatSet(mScratch,mTemplate,0,0,pos.size.x, pos.size.y,0,0);
00053     }
00054 
00057     double Score(/*const*/ Array::Array2dVec3Real64& image, const Position& pos)
00058     {
00059         Array::Trait::FuncBpoRobustMahalanobis dif;
00060         for(int i=0 ; i<3 ; i++)
00061             dif.mSigma[i] = mKalman.mSigmaG[i] + mKalman.mSigmaI[i];
00062         Array::Pattern::PatBinaryPixOp(mTemplatePrediction, &image, mTemplate, dif);
00063         return dif.mError;
00064     }
00065 
00072     void Reset(/*const*/ Array::Array2dVec3Real64& image, const Position& pos)
00073     {
00074         ILOG_DEBUG("Reset with size = (" << pos.size.x << "," << pos.size.y << ")");
00075         delete mTemplate;
00076         mTemplate = new Array::Array2dVec3Real64(pos.size.x, pos.size.y, 0, 0);
00077         Array::Pattern::PatSet(mTemplate, &image, pos.translation.x, pos.translation.y, pos.size.x, pos.size.y, 0, 0);
00078         delete mTemplatePrediction;
00079         mTemplatePrediction = new Array::Array2dVec3Real64(pos.size.x, pos.size.y, 0, 0);
00080         Array::Pattern::PatSet(mTemplatePrediction, &image, pos.translation.x, pos.translation.y, pos.size.x, pos.size.y, 0, 0);
00081         mKalman.Reset(pos.size.x, pos.size.y);
00082 
00083         delete mScratch;
00084         mScratch = new Array::Array2dVec3UInt8(pos.size.x, pos.size.y, 0, 0);
00085         Array::Pattern::PatSet(mScratch,mTemplate,0,0,pos.size.x, pos.size.y,0,0);
00086     }
00087 
00090     Array::Array2dVec3Real64* GetImage()
00091     {
00092         ILOG_DEBUG("object image requested");
00093         return mTemplate;
00094     }
00095 
00096 
00097     Array::Array2dVec3Real64* mTemplate;
00098     Array::Array2dVec3Real64* mTemplatePrediction;
00099     Array::Trait::FuncKalmanColor mKalman;
00100     Array::Array2dVec3UInt8* mScratch;
00101 
00102     static log4cpp::Category& sLog;
00103 };
00104 
00105 ILOG_VAR_INIT(KalmanTemplate, Impala.Core.Tracking);
00106 
00107 } // namespace Tracking
00108 } // namespace Core
00109 } // namespace Impala
00110 
00111 #endif //Impala_Core_Tracking_KalmanTemplate_h
00112 

Generated on Fri Mar 19 09:31:23 2010 for ImpalaSrc by  doxygen 1.5.1