103 m_RecordFactor = m_MaxTime / m_Granularity;
113 if ( !m_Timer.Started() ) {
120 m_Granularity = granularity;
124 m_RecordFactor = m_MaxTime / m_Granularity;
130 m_History.Init( (
int)(m_RecordFactor)+1, dummyRec );
132 MODebug2->Message(
"Tracker History Started with" +
IntToStr(m_History.Count()) +
" records in max " +
IntToStr(m_MaxTime) +
" ms." );
143 MODebug2->Message(
"Tracker History Resumed");
157 if (m_Timer.Started()) {
160 if ( p_Tick>=0 && p_InstanceRecord.
m_Tick<0) p_InstanceRecord.
m_Tick = p_Tick;
161 else if ( p_Tick == -1 ) {
162 p_InstanceRecord.
m_Tick = m_Timer.Duration();
165 if ( m_History.Count()==0 ) {
167 m_History.Add( p_InstanceRecord );
171 rec_pos = (double) ( p_InstanceRecord.
m_Tick / m_Granularity );
175 if ( rec_posl < m_History.Count() ) {
176 m_History.Set( rec_posl, p_InstanceRecord );
177 m_nRecorded = rec_posl+1;
187 m_History.Record( m_ActualRecord );
195 MODebug2->Message(
"Tracker History Recording Paused.");
201 MODebug2->Message(
"Tracker History Recording Stopped.");
208 MODebug2->Message(
"Tracker History Recording Reset.");
213 MODebug2->Message(
"moTrackerSystemHistory::SaveToFile > not implemented! argument: " + filename);
219 MODebug2->Message(
"moTrackerSystemHistory::SaveToXML > not implemented! argument: " + filename);
225 return m_History[index];
230 moTUIOSystemData::moTUIOSystemData() {
232 currentFrameTime = TuioTime::getSessionTime().getSeconds();
233 currentFrame = sessionID = maxCursorID = -1;
234 verbose = updateObject = updateCursor =
false;
235 lastObjectUpdate = lastCursorUpdate = currentFrameTime.getSeconds();
237 periodic_update =
false;
241 moTUIOSystemData::~moTUIOSystemData() {
246 TuioObject* moTUIOSystemData::addTuioObject(
int f_id,
float x,
float y,
float a) {
248 TuioObject *tobj =
new TuioObject(currentFrameTime, sessionID, f_id, x, y, a);
249 objectList.push_back(tobj);
253 std::cout <<
"add obj " << tobj->getSymbolID() <<
" (" << tobj->getSessionID() <<
") "<< tobj->getX() <<
" " << tobj->getY() <<
" " << tobj->getAngle() << std::endl;
258 void moTUIOSystemData::addExternalTuioObject(TuioObject *tobj) {
259 if (tobj==NULL)
return;
260 objectList.push_back(tobj);
264 std::cout <<
"add obj " << tobj->getSymbolID() <<
" (" << tobj->getSessionID() <<
") "<< tobj->getX() <<
" " << tobj->getY() <<
" " << tobj->getAngle() << std::endl;
267 void moTUIOSystemData::updateTuioObject(TuioObject *tobj,
float x,
float y,
float a) {
268 if (tobj==NULL)
return;
269 if (tobj->getTuioTime()==currentFrameTime)
return;
270 tobj->update(currentFrameTime,x,y,a);
273 if (verbose && tobj->isMoving())
274 std::cout <<
"set obj " << tobj->getSymbolID() <<
" (" << tobj->getSessionID() <<
") "<< tobj->getX() <<
" " << tobj->getY() <<
" " << tobj->getAngle()
275 <<
" " << tobj->getXSpeed() <<
" " << tobj->getYSpeed() <<
" " << tobj->getRotationSpeed() <<
" " << tobj->getMotionAccel() <<
" " << tobj->getRotationAccel() << std::endl;
278 void moTUIOSystemData::updateExternalTuioObject(TuioObject *tobj) {
279 if (tobj==NULL)
return;
281 if (verbose && tobj->isMoving())
282 std::cout <<
"set obj " << tobj->getSymbolID() <<
" (" << tobj->getSessionID() <<
") "<< tobj->getX() <<
" " << tobj->getY() <<
" " << tobj->getAngle()
283 <<
" " << tobj->getXSpeed() <<
" " << tobj->getYSpeed() <<
" " << tobj->getRotationSpeed() <<
" " << tobj->getMotionAccel() <<
" " << tobj->getRotationAccel() << std::endl;
286 void moTUIOSystemData::removeTuioObject(TuioObject *tobj) {
287 if (tobj==NULL)
return;
288 objectList.remove(tobj);
293 std::cout <<
"del obj " << tobj->getSymbolID() <<
" (" << tobj->getSessionID() <<
")" << std::endl;
296 void moTUIOSystemData::removeExternalTuioObject(TuioObject *tobj) {
297 if (tobj==NULL)
return;
298 objectList.remove(tobj);
302 std::cout <<
"del obj " << tobj->getSymbolID() <<
" (" << tobj->getSessionID() <<
")" << std::endl;
305 TuioCursor* moTUIOSystemData::addTuioCursor(
float x,
float y) {
308 int cursorID = (int)cursorList.size();
309 if (((
int)(cursorList.size())<=maxCursorID) && ((int)(freeCursorList.size())>0)) {
310 std::list<TuioCursor*>::iterator closestCursor = freeCursorList.begin();
312 for(std::list<TuioCursor*>::iterator iter = freeCursorList.begin();iter!= freeCursorList.end(); iter++) {
313 if((*iter)->getDistance(x,y)<(*closestCursor)->getDistance(x,y)) closestCursor = iter;
316 TuioCursor *freeCursor = (*closestCursor);
317 cursorID = (*closestCursor)->getCursorID();
318 freeCursorList.erase(closestCursor);
320 }
else maxCursorID = cursorID;
322 TuioCursor *tcur =
new TuioCursor(currentFrameTime, sessionID, cursorID, x, y);
323 cursorList.push_back(tcur);
327 std::cout <<
"add cur " << tcur->getCursorID() <<
" (" << tcur->getSessionID() <<
") " << tcur->getX() <<
" " << tcur->getY() << std::endl;
332 void moTUIOSystemData::addExternalTuioCursor(TuioCursor *tcur) {
333 if (tcur==NULL)
return;
334 cursorList.push_back(tcur);
338 std::cout <<
"add cur " << tcur->getCursorID() <<
" (" << tcur->getSessionID() <<
") " << tcur->getX() <<
" " << tcur->getY() << std::endl;
341 void moTUIOSystemData::updateTuioCursor(TuioCursor *tcur,
float x,
float y) {
342 if (tcur==NULL)
return;
343 if (tcur->getTuioTime()==currentFrameTime)
return;
344 tcur->update(currentFrameTime,x,y);
347 if (verbose && tcur->isMoving())
348 std::cout <<
"set cur " << tcur->getCursorID() <<
" (" << tcur->getSessionID() <<
") " << tcur->getX() <<
" " << tcur->getY()
349 <<
" " << tcur->getXSpeed() <<
" " << tcur->getYSpeed() <<
" " << tcur->getMotionAccel() <<
" " << std::endl;
352 void moTUIOSystemData::updateExternalTuioCursor(TuioCursor *tcur) {
353 if (tcur==NULL)
return;
355 if (verbose && tcur->isMoving())
356 std::cout <<
"set cur " << tcur->getCursorID() <<
" (" << tcur->getSessionID() <<
") " << tcur->getX() <<
" " << tcur->getY()
357 <<
" " << tcur->getXSpeed() <<
" " << tcur->getYSpeed() <<
" " << tcur->getMotionAccel() <<
" " << std::endl;
360 void moTUIOSystemData::removeTuioCursor(TuioCursor *tcur) {
361 if (tcur==NULL)
return;
362 cursorList.remove(tcur);
363 tcur->remove(currentFrameTime);
367 std::cout <<
"del cur " << tcur->getCursorID() <<
" (" << tcur->getSessionID() <<
")" << std::endl;
369 if (tcur->getCursorID()==maxCursorID) {
373 if (cursorList.size()>0) {
374 std::list<TuioCursor*>::iterator clist;
375 for (clist=cursorList.begin(); clist != cursorList.end(); clist++) {
376 int cursorID = (*clist)->getCursorID();
377 if (cursorID>maxCursorID) maxCursorID=cursorID;
380 freeCursorBuffer.clear();
381 for (std::list<TuioCursor*>::iterator flist=freeCursorList.begin(); flist != freeCursorList.end(); flist++) {
382 TuioCursor *freeCursor = (*flist);
383 if (freeCursor->getCursorID()>maxCursorID)
delete freeCursor;
384 else freeCursorBuffer.push_back(freeCursor);
386 freeCursorList = freeCursorBuffer;
389 for (std::list<TuioCursor*>::iterator flist=freeCursorList.begin(); flist != freeCursorList.end(); flist++) {
390 TuioCursor *freeCursor = (*flist);
393 freeCursorList.clear();
395 }
else if (tcur->getCursorID()<maxCursorID) {
396 freeCursorList.push_back(tcur);
400 void moTUIOSystemData::removeExternalTuioCursor(TuioCursor *tcur) {
401 if (tcur==NULL)
return;
402 cursorList.remove(tcur);
406 std::cout <<
"del cur " << tcur->getCursorID() <<
" (" << tcur->getSessionID() <<
")" << std::endl;
409 long moTUIOSystemData::getSessionID() {
414 long moTUIOSystemData::getFrameID() {
418 TuioTime moTUIOSystemData::getFrameTime() {
419 return currentFrameTime;
422 void moTUIOSystemData::initFrame(TuioTime ttime) {
423 currentFrameTime = ttime;
427 void moTUIOSystemData::commitFrame() {
472 updateCursor =
false;
473 updateObject =
false;
477 TuioObject* moTUIOSystemData::getTuioObject(
long s_id) {
478 for (std::list<TuioObject*>::iterator iter=objectList.begin(); iter != objectList.end(); iter++)
479 if((*iter)->getSessionID()==s_id)
return (*iter);
484 TuioCursor* moTUIOSystemData::getTuioCursor(
long s_id) {
485 for (std::list<TuioCursor*>::iterator iter=cursorList.begin(); iter != cursorList.end(); iter++)
486 if((*iter)->getSessionID()==s_id)
return (*iter);
491 TuioObject* moTUIOSystemData::getClosestTuioObject(
float xp,
float yp) {
493 TuioObject *closestObject = NULL;
494 float closestDistance = 1.0f;
496 for (std::list<TuioObject*>::iterator iter=objectList.begin(); iter != objectList.end(); iter++) {
497 float distance = (*iter)->getDistance(xp,yp);
498 if(distance<closestDistance) {
499 closestObject = (*iter);
500 closestDistance = distance;
504 return closestObject;
507 TuioCursor* moTUIOSystemData::getClosestTuioCursor(
float xp,
float yp) {
509 TuioCursor *closestCursor = NULL;
510 float closestDistance = 1.0f;
512 for (std::list<TuioCursor*>::iterator iter=cursorList.begin(); iter != cursorList.end(); iter++) {
513 float distance = (*iter)->getDistance(xp,yp);
514 if(distance<closestDistance) {
515 closestCursor = (*iter);
516 closestDistance = distance;
520 return closestCursor;
523 std::list<TuioObject*> moTUIOSystemData::getTuioObjects() {
527 std::list<TuioCursor*> moTUIOSystemData::getTuioCursors() {
531 std::list<TuioObject*> moTUIOSystemData::getUntouchedObjects() {
533 std::list<TuioObject*> untouched;
534 for (std::list<TuioObject*>::iterator tuioObject = objectList.begin(); tuioObject!=objectList.end(); tuioObject++) {
535 TuioObject *tobj = (*tuioObject);
536 if (tobj->getTuioTime()!=currentFrameTime) untouched.push_back(tobj);
541 void moTUIOSystemData::stopUntouchedMovingObjects() {
543 std::list<TuioObject*> untouched;
544 for (std::list<TuioObject*>::iterator tuioObject = objectList.begin(); tuioObject!=objectList.end(); tuioObject++) {
546 TuioObject *tobj = (*tuioObject);
547 if ((tobj->getTuioTime()!=currentFrameTime) && (tobj->isMoving())) {
548 tobj->stop(currentFrameTime);
558 void moTUIOSystemData::removeUntouchedStoppedObjects() {
560 std::list<TuioObject*>::iterator tuioObject = objectList.begin();
561 while (tuioObject!=objectList.end()) {
562 TuioObject *tobj = (*tuioObject);
563 if ((tobj->getTuioTime()!=currentFrameTime) && (!tobj->isMoving())) {
564 removeTuioObject(tobj);
565 tuioObject = objectList.begin();
571 std::list<TuioCursor*> moTUIOSystemData::getUntouchedCursors() {
573 std::list<TuioCursor*> untouched;
574 for (std::list<TuioCursor*>::iterator tuioCursor = cursorList.begin(); tuioCursor!=cursorList.end(); tuioCursor++) {
575 TuioCursor *tcur = (*tuioCursor);
576 if (tcur->getTuioTime()!=currentFrameTime) untouched.push_back(tcur);
581 void moTUIOSystemData::stopUntouchedMovingCursors() {
583 std::list<TuioCursor*> untouched;
584 for (std::list<TuioCursor*>::iterator tuioCursor = cursorList.begin(); tuioCursor!=cursorList.end(); tuioCursor++) {
585 TuioCursor *tcur = (*tuioCursor);
586 if ((tcur->getTuioTime()!=currentFrameTime) && (tcur->isMoving())) {
587 tcur->stop(currentFrameTime);
598 void moTUIOSystemData::removeUntouchedStoppedCursors() {
600 if (cursorList.size()==0)
return;
601 std::list<TuioCursor*>::iterator tuioCursor = cursorList.begin();
602 while (tuioCursor!=cursorList.end()) {
603 TuioCursor *tcur = (*tuioCursor);
604 if ((tcur->getTuioTime()!=currentFrameTime) && (!tcur->isMoving())) {
605 removeTuioCursor(tcur);
606 tuioCursor = cursorList.begin();
625 _zonewf = (float)(m_ZoneW) - 0.000001;
626 _zonehf = (float)(m_ZoneH) - 0.000001;
627 _zonecwf = (float)(m_ZoneCW) - 0.000001;
628 _zonechf = (float)(m_ZoneCH) - 0.000001;
629 m_Zones = m_ZoneW*m_ZoneH;
630 m_ZonesC = m_ZoneCW*m_ZoneCH;
631 m_PositionMatrix =
new int [m_Zones];
632 m_MotionMatrix =
new int [m_Zones];
633 m_AccelerationMatrix =
new int [m_Zones];
634 m_CircularPositionMatrix =
new int [m_ZonesC];
635 m_CircularMotionMatrix =
new int [m_ZonesC];
636 m_Features.Init( 0, NULL );
637 m_ActualRecord.m_nFeatures = 0;
651 _zonewf = (float)(m_ZoneW) - 0.000001;
652 _zonehf = (float)(m_ZoneH) - 0.000001;
653 _zonecwf = (float)(m_ZoneCW) - 0.000001;
654 _zonechf = (float)(m_ZoneCH) - 0.000001;
655 m_Zones = m_ZoneW*m_ZoneH;
656 m_ZonesC = m_ZoneCW*m_ZoneCH;
657 m_PositionMatrix =
new int [m_Zones];
658 m_MotionMatrix =
new int [m_Zones];
659 m_AccelerationMatrix =
new int [m_Zones];
660 m_CircularPositionMatrix =
new int [m_ZonesC];
661 m_CircularMotionMatrix =
new int [m_ZonesC];
662 m_Features.Init( 0, NULL );
663 m_ActualRecord.m_nFeatures = 0;
679 _zonewf = (float)(m_ZoneW) - 0.000001;
680 _zonehf = (float)(m_ZoneH) - 0.000001;
681 _zonecwf = (float)(m_ZoneCW) - 0.000001;
682 _zonechf = (float)(m_ZoneCH) - 0.000001;
683 m_Zones = m_ZoneW*m_ZoneH;
684 m_ZonesC = m_ZoneCW*m_ZoneCH;
685 m_PositionMatrix =
new int [m_Zones];
686 m_MotionMatrix =
new int [m_Zones];
687 m_AccelerationMatrix =
new int [m_Zones];
688 m_CircularPositionMatrix =
new int [m_ZonesC];
689 m_CircularMotionMatrix =
new int [m_ZonesC];
690 m_Features.Init( 0, NULL );
691 m_ActualRecord.m_nFeatures = 0;
703 if (m_PositionMatrix) {
704 delete [] m_PositionMatrix;
705 m_PositionMatrix = NULL;
708 if (m_MotionMatrix) {
709 delete [] m_MotionMatrix;
710 m_MotionMatrix = NULL;
713 if (m_CircularMotionMatrix) {
714 delete [] m_CircularMotionMatrix;
715 m_CircularMotionMatrix = NULL;
718 if (m_CircularPositionMatrix) {
719 delete [] m_CircularPositionMatrix;
720 m_CircularPositionMatrix = NULL;
733 return m_ActualRecord.m_Max;
737 return m_ActualRecord.m_Min;
741 return m_Features.Count();
745 return m_Features.GetRef(i);
753 return m_ActualRecord.m_Barycenter;
757 return m_ActualRecord.m_BarycenterMotion;
761 return m_ActualRecord.m_BarycenterAcceleration;
765 return m_ActualRecord.m_Variance;
769 return m_ActualRecord.m_SpeedVariance;
773 return m_ActualRecord.m_AccelerationVariance;
777 return m_ActualRecord.m_BoundingRectangle;
781 return m_ActualRecord.m_ValidFeatures;
785 return m_ActualRecord.m_DeltaValidFeatures;
789 for(
int i=0; i<m_Zones;i++) {
790 m_PositionMatrix[i] = 0;
791 m_MotionMatrix[i] = 0;
792 m_AccelerationMatrix[i] = 0;
795 for(
int i=0; i<m_Zones;i++) {
796 m_CircularMotionMatrix[i] = 0;
797 m_CircularPositionMatrix[i] = 0;
804 float i = floor( x * (
float) _zonewf );
805 float j = floor( y * (
float) _zonehf );
807 int pos = (int)i + ((
int)j)*m_ZoneW ;
815 int j = zone / m_ZoneW;
816 int i = zone - j*m_ZoneW;
817 return moVector2f( (1.0/ (2.0*
float(m_ZoneW))) + (
float)i / (
float) m_ZoneW, (1.0/(2.0*
float(m_ZoneH))) + (
float)j / (
float) m_ZoneH);
829 PosRePos =
moVector2f( x - m_ActualRecord.m_Barycenter.X(), y - m_ActualRecord.m_Barycenter.Y() );
831 if ( PosRePos.
X() > 0 && PosRePos.
Y() >= 0 ) {
832 Teta = atan( PosRePos.
Y() / PosRePos.
X() );
833 }
else if ( PosRePos.
X() > 0 && PosRePos.
Y() < 0 ) {
835 }
else if( PosRePos.
X() < 0 ) {
837 }
else if (PosRePos.
X() == 0 && PosRePos.
Y() > 0) {
839 }
else if (PosRePos.
X() == 0 && PosRePos.
Y() < 0) {
843 Radius = PosRePos.
Length();
845 MaxCuad = ( m_ActualRecord.m_Max - m_ActualRecord.m_Min ) ;
846 MaxRadius = fabs( MaxCuad.
Length() / 2.0);
847 ( MaxRadius > 0 ) ? MaxRadius = MaxRadius : MaxRadius = 1.5;
850 float j = floor( ( Radius / MaxRadius ) * (
float) _zonechf );
852 return ( (
int)i + ((
int)j)*m_ZoneCW );
864 int j = zone / m_ZoneCW;
865 int i = zone - j*m_ZoneCW;
867 PosRePos =
moVector2f( m_ActualRecord.m_Barycenter.X(), m_ActualRecord.m_Barycenter.Y() );
869 MaxCuad = ( m_ActualRecord.m_Max - m_ActualRecord.m_Min ) ;
870 MaxRadius = fabs( MaxCuad.
Length() / 2.0 );
871 ( MaxRadius > 0 ) ? MaxRadius = MaxRadius : MaxRadius = 1.5;
874 Radius = ( MaxRadius * (j+1) ) / _zonechf;
878 x = Radius * cos ( Teta ) + PosRePos.
X();
879 y = Radius * sin ( Teta ) + PosRePos.
Y();
894 int pos = PositionToZone(x,y);
895 if ( pos >=0 && pos <m_Zones ) {
896 m_PositionMatrix[pos]+=nfeatures;
901 int posi = PositionToZone(pos.
X(),pos.
Y());
902 if ( posi >=0 && posi <m_Zones ) {
903 m_PositionMatrix[posi]+=nfeatures;
909 int pos = PositionToZone(x,y);
910 if ( pos >=0 && pos <m_Zones )
return m_PositionMatrix[pos];
915 int posi = PositionToZone(pos.
X(),pos.
Y());
916 if ( posi >=0 && posi <m_Zones )
return m_PositionMatrix[posi];
926 int pos = PositionToZone(x,y);
927 if ( pos >=0 && pos <m_Zones ) m_MotionMatrix[pos]+=nfeatures;
931 int pos = PositionToZone(x,y);
932 if ( pos >=0 && pos <m_Zones )
return m_MotionMatrix[pos];
937 int posi = PositionToZone(pos.
X(),pos.
Y());
938 if ( posi >=0 && posi <m_Zones ) m_MotionMatrix[posi]+=nfeatures;
942 int posi = PositionToZone(pos.
X(),pos.
Y());
943 if ( posi >=0 && posi <m_Zones )
return m_MotionMatrix[posi];
952 int pos = PositionToZone(x,y);
953 if ( pos >=0 && pos <m_Zones ) m_AccelerationMatrix[pos]+=nfeatures;
957 int pos = PositionToZone(x,y);
958 if ( pos >=0 && pos <m_Zones )
return m_AccelerationMatrix[pos];
963 int posi = PositionToZone(pos.
X(),pos.
Y());
964 if ( posi >=0 && posi <m_Zones ) m_AccelerationMatrix[posi]+=nfeatures;
968 int posi = PositionToZone(pos.
X(),pos.
Y());
969 if ( posi >=0 && posi <m_Zones )
return m_AccelerationMatrix[posi];
979 int pos = PositionToZoneC(x,y);
980 if ( pos >=0 && pos <m_ZonesC ) m_CircularPositionMatrix[pos]+=nfeatures;
984 int pos = PositionToZoneC(x,y);
985 if ( pos >=0 && pos <m_ZonesC )
return m_CircularPositionMatrix[pos];
990 int posi = PositionToZoneC(pos.
X(),pos.
Y());
991 if ( posi >=0 && posi <m_ZonesC )
return m_CircularPositionMatrix[posi];
996 if ( zone >=0 && zone <m_ZonesC )
return m_CircularPositionMatrix[zone];
1002 int pos = PositionToZoneC(x,y);
1003 if ( pos >=0 && pos <m_ZonesC ) m_CircularMotionMatrix[pos]+=nfeatures;
1007 int pos = PositionToZoneC(x,y);
1008 if ( pos >=0 && pos <m_ZonesC )
return m_CircularMotionMatrix[pos];
1013 int posi = PositionToZoneC(pos.
X(),pos.
Y());
1014 if ( posi >=0 && posi <m_ZonesC )
return m_CircularMotionMatrix[posi];
1018 if ( zone >=0 && zone <m_ZonesC )
return m_CircularMotionMatrix[zone];
1048 glColor4f( 1.0, 0.0, 0.0, 1.0 );
1051 glDisable( GL_TEXTURE_2D );
1052 glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
1055 glLineWidth((GLfloat)2.0);
1057 glVertex2f((x - 0.5*d)*w, (y - 0.5*d)*h);
1058 glVertex2f((x - 0.5*d)*w, (y + 0.5*d)*h);
1059 glVertex2f((x + 0.5*d)*w, (y + 0.5*d)*h);
1060 glVertex2f((x + 0.5*d)*w, (y - 0.5*d)*h);
1063 glLineWidth((GLfloat)1.0);
1066 glVertex2f( x*w, (y - 0.1*d)*h);
1067 glVertex2f( x*w, (y + 0.1*d)*h);
1070 glVertex2f( x*w, (y + 0.1*d)*h);
1071 glVertex2f( (x-0.0008*d)*w, (y + 0.1*d - 0.0008*d)*h);
1073 glVertex2f((x - 0.1*d)*w, y*d*h);
1074 glVertex2f((x + 0.1*d)*w, y*d*h);
1077 glVertex2f((x + 0.1*d)*w, y*d*h);
1078 glVertex2f((x + 0.1*d - 0.0008*d)*w, (y+0.0008)*h);
1083 #endif // OPENGLESV2 1085 if (GetFeaturesCount()>0) {
1087 for (
int f = 0; f < GetFeaturesCount(); f++)
1096 x = (pF->
x) - offsetx;
1097 y = (pF->
y) - offsety;
1098 float tr_x = (pF->
tr_x) - offsetx;
1099 float tr_y = (pF->
tr_y) - offsety;
1108 glBindTexture(GL_TEXTURE_2D,0);
1109 glColor4f(1.0, 0.0, 0.0, 0.15);
1122 glColor4f(1.0, 0.0, 0.0, 1.0);
1126 glVertex2f((x - 0.008*d)*w, (y - 0.008*d)*h);
1127 glVertex2f((x - 0.008*d)*w, (y + 0.008*d)*h);
1128 glVertex2f((x + 0.008*d)*w, (y + 0.008*d)*h);
1129 glVertex2f((x + 0.008*d)*w, (y - 0.008*d)*h);
1134 glColor4f(1.0, 1.0, 1.0, 1.0);
1136 glColor4f(1.0, 0.0, 0.0, 1.0);
1138 glBindTexture(GL_TEXTURE_2D,0);
1139 glDisable(GL_TEXTURE_2D);
1140 glLineWidth((GLfloat)1.2);
1144 glVertex2f( x*w, y*h);
1145 glVertex2f( tr_x*w, tr_y*h);
1246 glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
1249 GetBarycenter().
Y() - offsety );
1251 GetMin().
Y() - offsety );
1253 GetMax().
Y() - offsety );
1256 glBindTexture(GL_TEXTURE_2D,0);
1257 glDisable(GL_TEXTURE_2D);
1258 glColor4f(1.0, 1.0, 0.0, 1.0);
1265 glVertex2f((m_TrackerBarycenter.
X() - 0.02)*w, (m_TrackerBarycenter.
Y() - 0.02)*h);
1267 glVertex2f((m_TrackerBarycenter.
X() - 0.02)*w, (m_TrackerBarycenter.
Y() + 0.02)*h);
1269 glVertex2f((m_TrackerBarycenter.
X() + 0.02)*w, (m_TrackerBarycenter.
Y() + 0.02)*h);
1271 glVertex2f((m_TrackerBarycenter.
X() + 0.02)*w, (m_TrackerBarycenter.
Y() - 0.02)*h);
1278 glColor4f(0.0, 1.0, 0.0, 1.0);
1279 glLineWidth((GLfloat)1.0);
1283 glVertex2f( m_TrackerMin.
X()*w, m_TrackerMax.
Y()*h);
1284 glVertex2f( m_TrackerMax.
X()*w, m_TrackerMax.
Y()*h);
1285 glVertex2f( m_TrackerMax.
X()*w, m_TrackerMin.
Y()*h);
1286 glVertex2f( m_TrackerMin.
X()*w, m_TrackerMin.
Y()*h);
1291 glColor4f(0.0, 1.0, 1.0, 1.0);
1292 glLineWidth((GLfloat)1.5);
1295 glVertex2f( m_TrackerBarycenter.
X()*w - m_TrackerVariance.
X()*w*5, m_TrackerBarycenter.
Y()*h-m_TrackerVariance.
Y()*h*5);
1296 glVertex2f( m_TrackerBarycenter.
X()*w + m_TrackerVariance.
X()*w*5, m_TrackerBarycenter.
Y()*h-m_TrackerVariance.
Y()*h*5);
1297 glVertex2f( m_TrackerBarycenter.
X()*w + m_TrackerVariance.
X()*w*5, m_TrackerBarycenter.
Y()*h+m_TrackerVariance.
Y()*h*5);
1298 glVertex2f( m_TrackerBarycenter.
X()*w - m_TrackerVariance.
X()*w*5, m_TrackerBarycenter.
Y()*h+m_TrackerVariance.
Y()*h*5);
1310 glEnable( GL_BLEND );
1311 glDisable(GL_TEXTURE_2D);
1312 glBlendFunc (GL_SRC_ALPHA, GL_ONE);
1317 int n = GetValidFeatures();
1319 float off_w, off_h, off_w_m, off_h_m;
1320 off_w = off_h = 1.0 / 8.0;
1322 if ( m_ZoneW > 0 ) {
1323 off_w = 1.0 / ( (float)(m_ZoneW)*2.0 );
1325 if ( m_ZoneH > 0 ) {
1326 off_h = 1.0 / ( float(m_ZoneH)*2.0 );
1328 off_w_m = off_w - off_w/8.0;
1329 off_h_m = off_h - off_h/8.0;
1333 for(z=0; z<m_Zones; z++) {
1337 npz = GetPositionMatrix( poscuad );
1338 nmz = GetMotionMatrix( poscuad );
1341 poscuad =
moVector2f( poscuad.
X()-offsetx, poscuad.
Y()-offsety);
1344 glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
1347 glColor4f(0.5, 0.5, 0.0, 0.002);
1350 glVertex2f((poscuad.
X() - off_w)*w, (poscuad.
Y() - off_h)*h);
1351 glVertex2f((poscuad.
X() - off_w)*w, (poscuad.
Y() + off_h)*h);
1352 glVertex2f((poscuad.
X() + off_w)*w, (poscuad.
Y() + off_h)*h);
1353 glVertex2f((poscuad.
X() + off_w)*w, (poscuad.
Y() - off_h)*h);
1361 glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
1364 glColor4f(0.0, 0.0, 0.5, 0.02);
1367 glVertex2f((poscuad.
X() - off_w_m)*w, (poscuad.
Y() - off_h_m)*h);
1368 glVertex2f((poscuad.
X() - off_w_m)*w, (poscuad.
Y() + off_h_m)*h);
1369 glVertex2f((poscuad.
X() + off_w_m)*w, (poscuad.
Y() + off_h_m)*h);
1370 glVertex2f((poscuad.
X() + off_w_m)*w, (poscuad.
Y() - off_h_m)*h);
1379 glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
1382 for(
int cc=0; cc < m_ZonesC; cc++) {
1386 if (((cc+1)%m_ZoneCW)==0) { p2 = ZoneToPositionC( cc - m_ZoneCW -1); }
1387 else { p2 = ZoneToPositionC( cc + 1 ); }
1390 p3 = GetBarycenter();
1391 p4 = GetBarycenter();
1394 if (((cc+1)%m_ZoneCW)==0) { p3 = ZoneToPositionC( cc - m_ZoneCW -1 - m_ZoneCW); }
1395 else { p3 = ZoneToPositionC( cc + 1 - m_ZoneCW); }
1396 p4 = ZoneToPositionC( cc - m_ZoneCW );
1400 npz = GetPositionMatrixC( cc );
1401 nmz = GetMotionMatrixC( cc );
1404 poscuadC =
moVector2f( poscuadC.
X()-offsetx, poscuadC.
Y()-offsety);
1409 glColor4f( 0.3+0.2*(
float)cc/(m_ZonesC-1), 0.3+0.2*(
float)cc/(m_ZonesC-1), 0.2, 0.0015);
1411 glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
1414 glColor4f( 0.7+0.3*(
float)cc/(m_ZonesC-1), 0.0, 0.0, 0.0025);
1416 glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
1425 glVertex2f( poscuadC.
X()*w, poscuadC.
Y()*h);
1426 glVertex2f( p2.
X()*w, p2.
Y()*h);
1427 glVertex2f( p3.
X()*w, p3.
Y()*h);
1428 glVertex2f( p4.
X()*w, p4.
Y()*h);
1436 glColor4f( 0.0, 0.0, 0.5+0.5*(
float)cc/(m_ZonesC-1), 0.0025);
1448 glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
1459 x = -1; y = -1; valid =
false;
1523 printf(
"Pos:\t%10.5f,%10.5f\t(%7.2f,%7.2f)\n",normx,normy,x,y);
1532 MOuint n = track.Count();
1535 printf(
"(%7.2f,%7.2f)\n", x, y);
1537 printf(
"(%7.2f,%7.2f) -> (%7.2f,%7.2f)\n", track[n-1]->
X(), track[n-1]->
Y(), x, y);
1546 int moTrackerFeature::updatePos(
float kltConvergeThreshold,
float kltSSDthresh,
int kltborder,
float delta,
float res,
float d1,
float d2,
float w,
float h)
1549 kltConvergeThreshold = 0.0;
1555 if (res > kltSSDthresh)
1557 else if (d1 < 0.0 && d2 < 0.0)
1566 normx = normx - delx;
1567 normy = normy - dely;
1571 if ( (x < kltborder) || (x > (w - kltborder)) || (y < kltborder) || (y > (h - kltborder)) )
1574 discardFlag =
false;
1611 SetName(
"filtermanager");
1612 SetLabelName(
"filtermanager");
moVector2f m_BarycenterMotion
void StartRecording(long maxtime=60000, long granularity=30)
Empieza a grabar.
moDefineDynamicArray(moTrackerFeatureArray) moDefineDynamicArray(moTrackerInstanceRecords)
virtual void DrawFeatures(float w, float h, float offsetx, float offsety)
virtual MOboolean Finish()
long m_Tick
operador de copia, y seteo de timers
void printTracks()
Imprime el valor de los valores trazados por este punto.
moVector2fpArray track
list of feature positions in the past frames. Forms the feature tracks in video.
virtual void SetPositionMatrixC(float x, float y, int nfeatures)
POSITION CIRCULAR.
double m_AbsoluteAccelerationAverage
cantidad de movimiento
moVector4< MOfloat > moVector4f
virtual moVector2f GetMin()
#define MO_TRACKER_LARGE_RESIDUE
int val
Other states for valid feature point.
moTrackerInstanceRecord & operator=(const moTrackerInstanceRecord &src)
float v_y
Speed in the actual frame.
virtual int GetMotionMatrixC(float x, float y)
virtual moVector2f GetSpeedVariance()
virtual int GetValidFeatures()
long uframe
once recognized
moVector4f m_BoundingRectangle
virtual moTrackerFeature * GetFeature(int i)
virtual moVector2f GetBarycenter()
virtual void SetPositionMatrix(float x, float y, int nfeatures)
POSITION.
int m_ValidFeatures
0 nada, 1 todo...
float ap_y
Acceleration in the previous frame.
virtual moVector2f GetBarycenterAcceleration()
virtual void SetAccelerationMatrix(float x, float y, int nfeatures)
ACCELERATION.
virtual int GetMotionMatrix(float x, float y)
#define MO_TRACKER_SMALL_DET
float vp_y
Speed in the previous frame.
virtual ~moFilterManager()
virtual int GetFeaturesCount()
virtual ~moTrackerFeature()
Destructor.
moVector2< MOfloat > moVector2f
bool is_object
once recognized
float tr_y
Feature position in the previous frame.
bool SaveToXML(moText filename)
clase de para manejar textos
moTrackerFeature()
Constructor.
Dispositivo de entrada/salida, típicamente, interfaces humanas de IO y datos ( teclado, mouse, tableta, tcp, udp, serial )
bool is_cursor
once recognized
virtual moVector2f ZoneToPosition(int zone)
Transforma el indice de zona al vector posicion.
long utime
once recognized
virtual void SetMax(float x, float y)
#define MO_TRACKER_NOT_FOUND
#define MO_TRACKER_TRACKED
long sframe
once recognized
long stime
once recognized
virtual ~moTrackerSystemData()
virtual void ResetMatrix()
virtual ~moTrackerSystemHistory()
moTrackerFeature & operator=(const moTrackerFeature &src)
virtual void SetMotionMatrix(float x, float y, int nfeatures)
MOTION.
virtual int PositionToZoneC(float x, float y)
Transforma el vector de posicion (0..1) a coordenadas polares luego al indice de zona de la matriz...
#define MO_TRACKER_MAX_ITERATIONS
void print()
Imprime los detalles de este punto.
virtual moVector2f GetAccelerationVariance()
bool is_parent
once recognized
bool valid
True for a valid feature point.
moTrackerFeatureArray FeaturesCaptured
virtual int GetDeltaValidFeatures()
The Y component of space.
moTrackerFeature * Parent
bool SaveToFile(moText filename)
void Record(moTrackerInstanceRecord &p_InstanceRecord, long p_Tick=-1)
virtual void SetMin(float x, float y)
double m_SurfaceCovered
separa formas de fondo
The X component of space.
virtual moVector2f GetBarycenterMotion()
virtual int GetAccelerationMatrix(float x, float y)
float t_y
Torque in the actual frame.
moTrackerInstanceRecord & Get(int index)
moVector2f m_SpeedVariance
double m_BoundingRectangleAngle
cantidad de fuerzas
void PauseRecording()
Util cuando no hay señales interesantes...
virtual moVector2f GetVariance()
virtual int GetPositionMatrix(float x, float y)
moVector2f m_AccelerationVariance
LIBMOLDEO_API moText0 IntToStr(int a)
virtual moTrackerFeatureArray & GetFeatures()
double m_AbsoluteTorqueAverage
cantidad de cambios de velocidad
virtual void SetMotionMatrixC(float x, float y, int nfeatures)
float normy
Normalized Feature Coordinates [ 0 - 1 ].
Característica de seguimiento ( sensado )
virtual int GetPositionMatrixC(float x, float y)
virtual moVector2f GetMax()
moTrackerInstanceRecord()
virtual moVector4f GetBoundingRectangle()
int updatePos(float kltConvergeThreshold, float kltSSDthresh, int kltborder, float delta, float res, float d1, float d2, float w, float h)
Update Feature Positions.
double m_AbsoluteSpeedAverage
Matrix de características.
moVector2f m_BarycenterAcceleration
virtual int PositionToZone(float x, float y)
Transforma el vector de posicion (0..1) al indice de zona de la matriz cuadrada.
virtual moVector2f ZoneToPositionC(int zone)
Transforma el indice de zona al vector posicion circular!
float a_y
Acceleration in the actual frame.