libmoldeo (Moldeo 1.0 Core)  1.0
libmoldeo is the group of objects and functions that executes the basic operations of Moldeo 1.0 Platform.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
moFilterManager.h
Go to the documentation of this file.
1 /*******************************************************************************
2 
3  moFilterManager.h
4 
5  ****************************************************************************
6  * *
7  * This source is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This code is distributed in the hope that it will be useful, but *
13  * WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
15  * General Public License for more details. *
16  * *
17  * A copy of the GNU General Public License is available on the World *
18  * Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
19  * obtain it by writing to the Free Software Foundation, *
20  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  * *
22  ****************************************************************************
23 
24  Copyright(C) 2006 Fabricio Costa
25 
26  Authors:
27  Fabricio Costa
28 
29 *******************************************************************************/
30 
31 #ifndef __MOFILTERMANAGER_H
32 #define __MOFILTERMANAGER_H
33 
34 #include "moTypes.h"
35 #include "moAbstract.h"
36 #include "moText.h"
37 #include "moVideoGraph.h"
38 #include "moResourceManager.h"
39 #include "moBuckets.h"
40 #include "moParam.h"
41 #include "moMathVector.h"
42 
43 
44 #define MO_TRACKER_TRACKED 0
45 #define MO_TRACKER_NOT_FOUND -1
46 #define MO_TRACKER_SMALL_DET -2
47 #define MO_TRACKER_MAX_ITERATIONS -3
48 #define MO_TRACKER_OOB -4
49 #define MO_TRACKER_LARGE_RESIDUE -5
50 
51 
52 #undef USE_TUIO
53 #ifdef USE_TUIO
54 
55 using namespace TUIO;
56 
57 //these includes TuioPoint.h TuioTime.h and TuioContainer.h
58 #include <TUIO/TuioObject.h>
59 #include <TUIO/TuioCursor.h>
60 
61 moDeclareExportedDynamicArray( TuioCursor*, moTuioCursorArray );
62 moDeclareExportedDynamicArray( TuioObject*, moTuioObjectArray );
63 
64 
66 
71 class LIBMOLDEO_API moTUIOSystemData {
72 
73  public:
74 
75  moTUIOSystemData();
76  virtual ~moTUIOSystemData();
77  virtual moVideoFormat& SetVideoFormat( moVideoFormat p_videoformat) { m_VideoFormat = p_videoformat; }
78  virtual moVideoFormat& GetVideoFormat() { return m_VideoFormat; }
79 
80 
81  virtual int GetCursorCount() { return m_Cursors.Count(); }
82  virtual int GetObjectCount() { return m_Objects.Count(); }
83 
84  virtual TuioCursor* GetCursor(int i) { return m_Cursors[i]; }
85  virtual moTuioCursorArray& GetCursors() { return m_Cursors; }
86 
87  virtual TuioObject* GetObject(int i) { return m_Objects[i]; }
88  virtual moTuioObjectArray& GetObjects() { return m_Objects; }
89 
90 
100  TuioCursor* addTuioCursor(float xp, float yp);
101 
109  void updateTuioCursor(TuioCursor *tcur, float xp, float yp);
110 
117  void removeTuioCursor(TuioCursor *tcur);
118 
124  void addExternalTuioCursor(TuioCursor *tcur);
125 
131  void updateExternalTuioCursor(TuioCursor *tcur);
132 
139  void removeExternalTuioCursor(TuioCursor *tcur);
140 
141 
142 
143 
144 
156  virtual TuioObject* addTuioObject(int sym, float xp, float yp, float a);
157 
166  virtual void updateTuioObject(TuioObject *tobj, float xp, float yp, float a);
167 
174  virtual void removeTuioObject(TuioObject *tobj);
175 
176 
177 
183  void addExternalTuioObject(TuioObject *tobj);
184 
190  void updateExternalTuioObject(TuioObject *tobj);
191 
198  void removeExternalTuioObject(TuioObject *tobj);
199 
200 
201 
207  virtual void initFrame(TuioTime ttime);
208 
213  virtual void commitFrame();
214 
215 
220  //virtual void commitFrame();
221 
226  virtual long getSessionID();
227 
232  virtual long getFrameID();
233 
238  virtual TuioTime getFrameTime();
239 
245  std::list<TuioObject*> getUntouchedObjects();
246 
252  std::list<TuioCursor*> getUntouchedCursors();
253 
257  void stopUntouchedMovingObjects();
258 
262  void stopUntouchedMovingCursors();
263 
267  void removeUntouchedStoppedObjects();
268 
272  void removeUntouchedStoppedCursors();
273 
279  std::list<TuioObject*> getTuioObjects();
280 
281 
287  std::list<TuioCursor*> getTuioCursors();
288 
295  TuioObject* getTuioObject(long s_id);
296 
303  TuioCursor* getTuioCursor(long s_id);
304 
311  TuioObject* getClosestTuioObject(float xp, float yp);
312 
319  TuioCursor* getClosestTuioCursor(float xp, float yp);
320 
321 
322  private:
323 
324  moVideoFormat m_VideoFormat;
325 
326  moTuioCursorArray m_Cursors;
327  moTuioObjectArray m_Objects;
328  std::list<TuioObject*> objectList;
329  std::list<TuioCursor*> cursorList;
330 
331  int maxCursorID;
332  //moTuioCursorArray m_freeCursorList;
333  //moTuioObjectArray m_freeCursorBuffer;
334  std::list<TuioCursor*> freeCursorList;
335  std::list<TuioCursor*> freeCursorBuffer;
336 
337  bool full_update;
338  int update_interval;
339  bool periodic_update;
340 
341  long currentFrame;
342  TuioTime currentFrameTime;
343  bool updateObject, updateCursor;
344  long lastCursorUpdate, lastObjectUpdate;
345 
346  long sessionID;
347  bool verbose;
348 
349 };
350 #endif
351 
352 class moTrackerFeature;
353 
354 moDeclareExportedDynamicArray( moTrackerFeature*, moTrackerFeatureArray );
355 
357 
365 class LIBMOLDEO_API moTrackerFeature { //de GpuKLT_Feature
366 
367  public:
368 
369  bool is_object;
370  bool is_parent;
371  bool is_cursor;
372  long stime;
373  long sframe;
374  long utime;
375  long uframe;
376 
377  moTrackerFeatureArray FeaturesCaptured;
379 
380  float x,y;
381  float normx, normy;
382  float tr_x, tr_y;
383  float v_x, v_y;
384  float vp_x, vp_y;
385  float a_x, a_y;
386  float ap_x, ap_y;
387  float t_x, t_y;
388  bool valid;
389  int val;
390  moVector2fpArray track;
391 
394 
396 
398  virtual ~moTrackerFeature();
399 
401  void print();
402 
404  void printTracks();
405 
407  int updatePos(float kltConvergeThreshold, float kltSSDthresh, int kltborder, float delta, float res, float d1, float d2, float w, float h);
408 };
409 
411 
417 
418  public:
422 
424  long m_Tick;
425 
426 
434 
446 
457 
461 
464 
465 };
466 
467 moDeclareExportedDynamicArray( moTrackerInstanceRecord, moTrackerInstanceRecords );
468 
469 #include "moTimeManager.h"
470 
472  public:
474  virtual ~moTrackerSystemHistory();
475 
476 
478 
488  void StartRecording( long maxtime = 60000, long granularity = 30 );
489  bool IsRecording() {return m_Timer.Started(); }
490  void Record( moTrackerInstanceRecord& p_InstanceRecord, long p_Tick = -1 );
492  void PauseRecording();
493  void ContinueRecording();
494  void StopRecording();
495  void Reset();
496  long CountRecords();
497  bool SaveToFile( moText filename );
498  bool SaveToXML( moText filename );
499  moTrackerInstanceRecord& Get( int index );
500 
501  public:
502 
503  long m_MaxTime;
507 
509  moTrackerInstanceRecords m_History;
510 };
511 
513 
521  public:
522 
524  moTrackerSystemData( int ZoneW, int ZoneH );
525  moTrackerSystemData( int ZoneW, int ZoneH, int ZoneCW, int ZoneCH );
526  virtual ~moTrackerSystemData();
527 
531  virtual int GetFeaturesCount();
532 
536  virtual int GetValidFeatures();
537  virtual int GetDeltaValidFeatures();
538 
542  virtual moVector2f GetBarycenter();
543 
547  virtual moVector2f GetBarycenterMotion();
548 
552  virtual moVector2f GetBarycenterAcceleration();
553 
557  virtual moVector2f GetVariance();
558 
562  virtual moVector2f GetSpeedVariance();
563 
567  virtual moVector2f GetAccelerationVariance();
568 
572  virtual moVector4f GetBoundingRectangle();
573 
574  virtual moVector2f GetMax();
575  virtual moVector2f GetMin();
576  virtual void SetMax( float x, float y );
577  virtual void SetMin( float x, float y );
578 
579 
580  virtual moTrackerFeature* GetFeature(int i);
581  virtual moTrackerFeatureArray& GetFeatures();
582 
583  virtual moVideoFormat& GetVideoFormat() { return m_VideoFormat; }
584 
585  virtual void SetBarycenter( float b_x, float b_y) { m_ActualRecord.m_Barycenter = moVector2f(b_x,b_y); }
586  virtual void SetBarycenterMotion( float b_x, float b_y) { m_ActualRecord.m_BarycenterMotion = moVector2f(b_x,b_y); }
587  virtual void SetBarycenterAcceleration( float b_x, float b_y) { m_ActualRecord.m_BarycenterAcceleration = moVector2f(b_x,b_y); }
588 
589  virtual void SetVariance( float v_x, float v_y) { m_ActualRecord.m_Variance = moVector2f(v_x,v_y); }
590  virtual void SetSpeedVariance( float v_x, float v_y) { m_ActualRecord.m_SpeedVariance = moVector2f(v_x,v_y); }
591  virtual void SetAccelerationVariance( float v_x, float v_y) { m_ActualRecord.m_AccelerationVariance = moVector2f(v_x,v_y); }
592  virtual void SetBoundingRectangle( float r_x, float r_y, float s_x, float s_y ) { m_ActualRecord.m_BoundingRectangle = moVector4f(r_x,r_y,s_x,s_y); }
593 
594  virtual void SetValidFeatures( int validfeatures) { m_ActualRecord.m_ValidFeatures = validfeatures; }
595  virtual void SetDeltaValidFeatures( int deltavalidfeatures) { m_ActualRecord.m_DeltaValidFeatures = deltavalidfeatures; }
596 
597  virtual void SetAbsoluteSpeedAverage( float speedaverage ) { m_ActualRecord.m_AbsoluteSpeedAverage = speedaverage; }
598  virtual void SetAbsoluteAccelerationAverage( float accaverage ) { m_ActualRecord.m_AbsoluteAccelerationAverage = accaverage; }
599  virtual void SetAbsoluteTorqueAverage( float toraverage ) { m_ActualRecord.m_AbsoluteTorqueAverage = toraverage; }
600 
601 
603  virtual int PositionToZone( float x, float y );
604 
606  virtual moVector2f ZoneToPosition( int zone );
607 
608 
610  virtual int PositionToZoneC( float x, float y );
611 
613  virtual moVector2f ZoneToPositionC( int zone );
614 
615  virtual void SetPositionMatrix( float x, float y, int nfeatures );
616  virtual void SetPositionMatrix( moVector2f pos, int nfeatures );
617  virtual int GetPositionMatrix( float x, float y );
618  virtual int GetPositionMatrix( moVector2f pos );
619 
620  virtual void SetMotionMatrix( float x, float y, int nfeatures );
621  virtual void SetMotionMatrix( moVector2f pos, int nfeatures );
622  virtual int GetMotionMatrix( float x, float y );
623  virtual int GetMotionMatrix( moVector2f pos );
624 
625  virtual void SetAccelerationMatrix( float x, float y, int nfeatures );
626  virtual void SetAccelerationMatrix( moVector2f pos, int nfeatures );
627  virtual int GetAccelerationMatrix( float x, float y );
628  virtual int GetAccelerationMatrix( moVector2f pos );
629 
630  virtual void SetPositionMatrixC( float x, float y, int nfeatures );
631  virtual int GetPositionMatrixC( float x, float y );
632  virtual int GetPositionMatrixC( moVector2f pos );
633  virtual int GetPositionMatrixC( int zone );
634 
635  virtual void SetMotionMatrixC( float x, float y, int nfeatures );
636  virtual int GetMotionMatrixC( float x, float y );
637  virtual int GetMotionMatrixC( moVector2f pos );
638  virtual int GetMotionMatrixC( int zone );
639 
640  virtual void ResetMatrix();
641  virtual void DrawFeatures( float w, float h, float offsetx, float offsety );
642 
643  virtual void SetMaxFeatures( int p_nFeatures ) { m_ActualRecord.m_nFeatures = p_nFeatures; }
644  virtual int GetMaxFeatures() { return m_ActualRecord.m_nFeatures; }
645 
646  void Record();
647  moTrackerSystemHistory& GetHistory() { return m_History; }
648 
649  int m_ZoneW;
650  int m_ZoneH;
651  int m_ZoneCW;
652  int m_ZoneCH;
653  int m_Zones;
654  int m_ZonesC;
655  float** m_Distancias;
656  int** m_Pares;
657  int nPares;
658 
659  protected:
660 
661  float _zonewf;
662  float _zonehf;
663  float _zonecwf;
664  float _zonechf;
665 
667 
668  moTrackerFeatureArray m_Features;
669 
671 
681 
684 
685 };
686 
687 
699 {
700  public:
701 
702  moFilterManager();
703  virtual ~moFilterManager();
704 
705  virtual MOboolean Init();
706  virtual MOboolean Finish();
707 
708  protected:
709 
710 
711 };
712 
713 
714 #endif
715 
moVideoFormat m_VideoFormat
virtual void SetBarycenterMotion(float b_x, float b_y)
long m_Tick
operador de copia, y seteo de timers
virtual void SetValidFeatures(int validfeatures)
moVector2fpArray track
list of feature positions in the past frames. Forms the feature tracks in video.
virtual void SetAccelerationVariance(float v_x, float v_y)
double m_AbsoluteAccelerationAverage
cantidad de movimiento
Recurso ( objeto para cargar y manipular objetos físicos de datos de imágenes, audio, video, 3d, 2d, fuentes, shaders y de cualquier otro tipo extendible por un plugin )
moVector4< MOfloat > moVector4f
int val
Other states for valid feature point.
float v_y
Speed in the actual frame.
virtual void SetDeltaValidFeatures(int deltavalidfeatures)
virtual void SetBoundingRectangle(float r_x, float r_y, float s_x, float s_y)
#define MOboolean
Definition: moTypes.h:385
moDeclareExportedDynamicArray(moTrackerFeature *, moTrackerFeatureArray)
virtual moVideoFormat & GetVideoFormat()
long uframe
once recognized
int m_ValidFeatures
0 nada, 1 todo...
float ap_y
Acceleration in the previous frame.
virtual void SetBarycenterAcceleration(float b_x, float b_y)
virtual void SetBarycenter(float b_x, float b_y)
virtual void SetAbsoluteSpeedAverage(float speedaverage)
float vp_y
Speed in the previous frame.
Clase base abstracta de donde deben derivar los objetos [virtual pura].
Definition: moAbstract.h:191
moVector2< MOfloat > moVector2f
Definition: moMathVector.h:423
bool is_object
once recognized
float tr_y
Feature position in the previous frame.
#define LIBMOLDEO_API
Definition: moTypes.h:180
moTrackerInstanceRecord m_ActualRecord
clase de para manejar textos
Definition: moText.h:75
float y
Location.
virtual void SetAbsoluteTorqueAverage(float toraverage)
bool is_cursor
once recognized
long utime
once recognized
virtual int GetMaxFeatures()
int * m_MotionMatrix
4 x 4 zones
long sframe
once recognized
long stime
once recognized
Sistema de características.
int * m_CircularMotionMatrix
12 semitones, 3 levels
virtual void SetSpeedVariance(float v_x, float v_y)
virtual void SetVariance(float v_x, float v_y)
moTrackerInstanceRecords m_History
virtual void SetAbsoluteAccelerationAverage(float accaverage)
bool is_parent
once recognized
bool valid
True for a valid feature point.
moTrackerFeatureArray FeaturesCaptured
virtual void SetMaxFeatures(int p_nFeatures)
moTrackerFeature * Parent
double m_SurfaceCovered
separa formas de fondo
float t_y
Torque in the actual frame.
moTrackerSystemHistory m_History
int * m_AccelerationMatrix
4 x 4 zones
double m_BoundingRectangleAngle
cantidad de fuerzas
Clase para el control de un temporizador (relativo) con identificación
Definition: moTimer.h:321
moMatrix3 & operator=(const moMatrix3 &rkM)
Formato de video.
Definition: moVideoGraph.h:155
double m_AbsoluteTorqueAverage
cantidad de cambios de velocidad
float normy
Normalized Feature Coordinates [ 0 - 1 ].
Característica de seguimiento ( sensado )
moTrackerFeatureArray m_Features
Matrix de características.
moVector2f m_BarycenterAcceleration
moTrackerSystemHistory & GetHistory()
int * m_CircularPositionMatrix
4 x 4 zones
float a_y
Acceleration in the actual frame.