Beispiel #1
5
FFTTracer::FFTTracer(){
    fft_size = ((testApp*)ofGetAppPtr())->fft_size;
    magnitude = new float[fft_size];
    
    for (int i = 0; i < fft_size; i++) {
        ofVec3f p = ofVec3f(0, 0, 0);
        pos.push_back(p);
        ofVec3f v = ofVec3f(0, 0, 0);
        vel.push_back(v);
        
        Tracker *t = new Tracker;
        t->setup();
        t->setTrackerLength(10);
        trackers.push_back(t);
    }
    
    //ばねパラメータ
    /*
     stiffness = 1.0;
     damping = 0.9;
     mass = 100.0;
     */
    stiffness = 2.0;
    damping = 0.92;
    mass = 200;
    
    //((testApp*)ofGetAppPtr())->cam.setPosition(0, 0, -200);
    //((testApp*)ofGetAppPtr())->cam.lookAt(ofVec3f(0,0,0));
    //camStart = ofPoint(0,0,-200);
    //camEnd = camStart;
    resetCam();
}
Beispiel #2
0
static int tracker_new(lua_State * L) {
	const char * body = luaL_checkstring(L, 1);
	const char * ip = luaL_checkstring(L, 2);
	int port = luaL_optint(L, 3, 3883);
	Tracker * u = (Tracker*)lua_newuserdata(L, sizeof(Tracker));
	sprintf(u->name, "%s@%s:%d", body, ip, port);
	
	if (u->open(u->name)) {
		luaL_getmetatable(L, "vrpn_Tracker_Remote");
		lua_setmetatable(L, -2);
		
		// create environment table to hold pos, quat etc.
		lua_createtable(L, 0, 3);
			lua_pushinteger(L, 0);	lua_setfield(L, -2, "sensor");
			lua_createtable(L, 3, 0);
				lua_pushnumber(L, 0);	lua_rawseti(L, -2, 1);
				lua_pushnumber(L, 0);	lua_rawseti(L, -2, 2);
				lua_pushnumber(L, 0);	lua_rawseti(L, -2, 3);
			lua_setfield(L, -2, "pos");
			lua_createtable(L, 4, 0);
				lua_pushnumber(L, 0);	lua_rawseti(L, -2, 1);
				lua_pushnumber(L, 0);	lua_rawseti(L, -2, 2);
				lua_pushnumber(L, 0);	lua_rawseti(L, -2, 3);
				lua_pushnumber(L, 1);	lua_rawseti(L, -2, 4);
			lua_setfield(L, -2, "quat");		
		lua_setfenv(L, -2);
		
		return 1;
	} 
	return 0;
}
Beispiel #3
0
void test_tracker() {
  int frame_count = 0;

  cv::VideoCapture cap;
  cap.set(cv::CAP_PROP_FRAME_WIDTH,320);
  cap.set(cv::CAP_PROP_FRAME_HEIGHT,240);

  if(!cap.open(0)) throw (string) "couldn't open camera";
  cv::Mat frame;

  Tracker tracker;

  for(;;) {

    cap >> frame;
    tracker.process_image(frame);
    ++frame_count;
    //const cv::Scalar white = cv::Scalar(255,255,255);
    //const cv::Scalar green = cv::Scalar(0,255,0);
    const cv::Scalar red = cv::Scalar(0,0,255);

    cv::putText(frame, (string) to_string(frame_count), cv::Point(50,50), cv::FONT_HERSHEY_SIMPLEX, 1, red, 3);
    //putText(frame, (string) to_string(tracker.low_distance), cv::Point(50,100), cv::FONT_HERSHEY_SIMPLEX ,1, red, 3);
    //putText(frame, (string) to_string(tracker.high_distance), cv::Point(50,150), cv::FONT_HERSHEY_SIMPLEX ,1, red, 3);

    cv::imshow("window 1", frame);
    if(cv::waitKey(1)==27) break;
  }

}
//-----------------------------------------------------------------------------
// Testing LightImplicitDigitalSurface
//-----------------------------------------------------------------------------
bool testLightImplicitDigitalSurface()
{
  using namespace Z3i;
  typedef ImplicitDigitalEllipse3<Point> ImplicitDigitalEllipse;
  typedef LightImplicitDigitalSurface<KSpace,ImplicitDigitalEllipse> Boundary;
  typedef Boundary::SurfelConstIterator ConstIterator;
  typedef Boundary::Tracker Tracker;
  typedef Boundary::Surfel Surfel;

  unsigned int nbok = 0;
  unsigned int nb = 0;
  trace.beginBlock ( "Testing block ... LightImplicitDigitalSurface" );
  Point p1( -10, -10, -10 );
  Point p2( 10, 10, 10 );
  KSpace K;
  nbok += K.init( p1, p2, true ) ? 1 : 0; 
  nb++;
  trace.info() << "(" << nbok << "/" << nb << ") "
	       << "K.init() is ok" << std::endl;
  ImplicitDigitalEllipse ellipse( 6.0, 4.5, 3.4 );
  Surfel bel = Surfaces<KSpace>::findABel( K, ellipse, 10000 );
  Boundary boundary( K, ellipse, 
                     SurfelAdjacency<KSpace::dimension>( true ), bel );
  unsigned int nbsurfels = 0;
  for ( ConstIterator it = boundary.begin(), it_end = boundary.end();
        it != it_end; ++it )
    {
      ++nbsurfels;
    }
  trace.info() << nbsurfels << " surfels found." << std::endl;
  trace.beginBlock ( "Checks if adjacent surfels are part of the surface." );

  for ( ConstIterator it = boundary.begin(), it_end = boundary.end();
        it != it_end; ++it )
    {
      Tracker* ptrTracker = boundary.newTracker( *it );
      Surfel s = ptrTracker->current();
      Dimension trackDir = * K.sDirs( s );
      Surfel s1, s2;
      // unsigned int m1 = 
      ptrTracker->adjacent( s1, trackDir, true ); 
      // unsigned int m2 = 
      ptrTracker->adjacent( s2, trackDir, false ); 
      // trace.info() << "s = " << s << std::endl;
      // trace.info() << "s1 = " << s1 << " m1 = " << m1 << std::endl;
      // trace.info() << "s2 = " << s2 << " m2 = " << m2 << std::endl;
      nb++, nbok += boundary.isInside( s1 ) ? 1 : 0;
      // trace.info() << "(" << nbok << "/" << nb << ") "
      //              << "boundary.isInside( s1 )" << std::endl;
      nb++, nbok += boundary.isInside( s2 ) ? 1 : 0;
      // trace.info() << "(" << nbok << "/" << nb << ") "
      //              << "boundary.isInside( s2 )" << std::endl;
      delete ptrTracker;
    }
  trace.info() << "(" << nbok << "/" << nb << ") isInside tests." << std::endl;
  trace.endBlock();
  trace.endBlock();
  return nbok == nb;
}
// Create a new tracker for images of a given size.
Tracker *create(int width, int height, bool debug) {
    Tracker *tracker = new Tracker(width, height, debug);
	if (! tracker->init()) {
		delete tracker;
		tracker = NULL;
	}
	return tracker;
}
/**
 * Example of a test. To be completed.
 *
 */
bool testDigitalSetBoundary()
{
  unsigned int nbok = 0;
  unsigned int nb = 0;
  
  trace.beginBlock ( "Testing block ... DigitalSetBoundary" );
  using namespace Z2i;
  typedef DigitalSetBoundary<KSpace,DigitalSet> Boundary;
  typedef Boundary::SurfelConstIterator ConstIterator;
  typedef Boundary::Tracker Tracker;
  typedef Boundary::Surfel Surfel;
  Point p1( -10, -10 );
  Point p2( 10, 10 );
  Domain domain( p1, p2 );
  DigitalSet dig_set( domain );
  Shapes<Domain>::addNorm2Ball( dig_set, Point( 0, 0 ), 5 );
  Shapes<Domain>::removeNorm2Ball( dig_set, Point( 0, 0 ), 1 );
  KSpace K;
  nbok += K.init( domain.lowerBound(), domain.upperBound(), true ) ? 1 : 0; 
  nb++;
  trace.info() << "(" << nbok << "/" << nb << ") "
	       << "K.init() is ok" << std::endl;
  Boundary boundary( K, dig_set );
  unsigned int nbsurfels = 0;
  for ( ConstIterator it = boundary.begin(), it_end = boundary.end();
        it != it_end; ++it )
    {
      ++nbsurfels;
    }
  trace.info() << nbsurfels << " surfels found." << std::endl;
  nb++, nbok += nbsurfels == ( 12 + 44 ) ? 1 : 0;
  trace.info() << "(" << nbok << "/" << nb << ") "
	       << "nbsurfels == (12 + 44 )" << std::endl;
  for ( ConstIterator it = boundary.begin(), it_end = boundary.end();
        it != it_end; ++it )
    {
      Tracker* ptrTracker = boundary.newTracker( *it );
      Surfel s = ptrTracker->current();
      Dimension trackDir = * K.sDirs( s );
      Surfel s1, s2;
      unsigned int m1 = ptrTracker->adjacent( s1, trackDir, true ); 
      unsigned int m2 = ptrTracker->adjacent( s2, trackDir, false ); 
      trace.info() << "s = " << s << std::endl;
      trace.info() << "s1 = " << s1 << " m1 = " << m1 << std::endl;
      trace.info() << "s2 = " << s2 << " m2 = " << m2 << std::endl;
      nb++, nbok += boundary.isInside( s1 ) ? 1 : 0;
      trace.info() << "(" << nbok << "/" << nb << ") "
                   << "boundary.isInside( s1 )" << std::endl;
      nb++, nbok += boundary.isInside( s2 ) ? 1 : 0;
      trace.info() << "(" << nbok << "/" << nb << ") "
                   << "boundary.isInside( s2 )" << std::endl;
      delete ptrTracker;
    }
  trace.endBlock();
  return nbok == nb;
}
Beispiel #7
0
int main(int argc, char** argv)
{
	Tracker tracker;

	tracker.read_image_paths(argv[1]);
	tracker.read_confidence_paths(argv[2]);

	tracker.initialize_tracker();

	for(int i = 3; (i < argc) && ((argv[i])[0] == '-'); i++)
	{
	    switch ((argv[i])[1])
	    {
	    	case 'e':
	    		i++;
	    		tracker.set_std_noise(atof(argv[i]));
	    		break;
	    	default:
	    		printf("\nUnrecognized option %s!\n\n",argv[i]);
	            exit(0);
	    }
	}

	// process each frame
	while(tracker.is_the_end() == false)
	{
		tracker.process_frame();

		cv::waitKey(1);
		tracker.next_frame();
	}

	tracker.terminate_tracker();
}
int main(int argc,const char* argv[])
{
    vector3 v(1,2,3);
    Body b(v);
    b.print();
    std::srand(time(NULL));
    std::cout<<RangeFloat(1,2)<<std::endl;
    Tracker track;
    track.print_all();
    return 0;
}
Beispiel #9
0
int main(){
	Tracker tracker = Tracker();
	cout << tracker.allocate("apibox") << endl;
	cout << tracker.allocate("apibox") << endl;
	tracker.deallocate("apibox1");
	cout << tracker.allocate("apibox") << endl;
	cout << tracker.allocate("testbox") << endl;




}
Beispiel #10
0
int main(int argc, char *argv[]) {
  ola::AppInit(&argc, argv, "[options]",
               "Measure the latency of RPCs to olad.");

  Tracker tracker;
  if (!tracker.Setup()) {
    OLA_FATAL << "Setup failed";
    exit(1);
  }

  tracker.Start();
  return 0;
}
Beispiel #11
0
dll void Track() {
	if (capture.isOpened()) {
		// start!
		capture >> frame;
		if (frame.total() == 0) return;
		Mat img;
		im = frame;
		flip(im, im, 1); cvtColor(im, gray, CV_BGR2GRAY);
		vector<int> wSize1(1);
		vector<int> wSize2(3);
		wSize1[0] = 7;
		wSize2[0] = 11;
		wSize2[1] = 9;
		wSize2[2] = 7;
		vector<int> wSize; if (failed)wSize = wSize2; else wSize = wSize1;
		if (tracker.Track(gray, wSize, fpd, nIter, clamp, fTol, show) == 0) {
			int idx = tracker._clm.GetViewIdx(); failed = false;
			img = im.clone();
			if (show) { Draw(im, tracker._shape, con, tri, tracker._clm._visi[idx]); }
		}
		else {
			if (show) { Mat R(im, cvRect(0, 0, 150, 50)); R = Scalar(0, 0, 255); }
			tracker.FrameReset(); failed = true;
			mp.FrameReset();
		}
		if (fnum >= 9) {
			t1 = cvGetTickCount();
			fps = 10.0 / ((double(t1 - t0) / cvGetTickFrequency()) / 1e+6);
			t0 = t1; fnum = 0;
		}
		else fnum += 1;
		if (mp.frame < 5) {
			mp.Calibrate(tracker._shape);
			mp.frame++;
		}
		if (mp.frame >= 5) {
			mp.EyeOpenL(img, tracker._shape);
			mp.EyeOpenR(img, tracker._shape);
			mp.MouthOpen(img, tracker._shape);
			mp.FaceRotation(tracker._shape);
			mp.OutPutValues();
		}
		if (show) {
			sprintf(sss, "%d frames/sec", (int)round(fps)); text = sss;
			putText(im, text, Point(10, 20),
				CV_FONT_HERSHEY_SIMPLEX, 0.5, CV_RGB(0, 0, 0));
			imshow("TrackingInfo", im);
		}
		if (waitKey(1) >= 0);
	}
Beispiel #12
0
//--------------------------------------------------------------
void ofApp::setup() {
	ofSetFrameRate(60);
	ofSetVerticalSync(true);
	
	rotate = 0;
	
	// setup bvh
	bvh[0].load("bvhfiles/kashiyuka.bvh");
	bvh[1].load("bvhfiles/nocchi.bvh");
	bvh[2].load("bvhfiles/aachan.bvh");
	
	for (int i = 0; i < 3; i++)	{
		bvh[i].play();
	}
	
	track.loadSound("Perfume_globalsite_sound.wav");
	track.play();
	track.setLoop(true);
	
	// setup tracker and drawer
	for (int i = 0; i < 3; i++)
		{
		ofxBvh &b = bvh[i];
		Drawer *d = new Drawer;
		
		for (int n = 0; n < b.getNumJoints(); n++) {
			const ofxBvhJoint *o = b.getJoint(n);
			Tracker *t = new Tracker;
			t->setup(o);
			t->setTrackerLength(trackerLength);
			trackers.push_back(t);
			d->add(o);
		}
		
		drawers.push_back(d);
		}
	
	ofPushMatrix();
	ofTranslate(0, -100);
	ofScale(1, 1, 1);
	ofRotateX(90);
	camera.setFov(90);
	camera.lookAt(ofVec3f(0,0,0));
	camera.setPosition(300, 30, 300);
	//camera.disableMouseInput();
	ofPopMatrix();
	background.loadImage("background.png");
	
}
bool Graph::Visit(int node, Tracker &tracker) {
    if (tracker.IsHamiltonianCycle()) {
        return true;
    }

    for (const auto adjacent_node : adjacency_list_[node]) {
        if (!tracker.IsVisited(adjacent_node) || tracker.IsHamiltonianCycle(adjacent_node)) {
            tracker.Visit(adjacent_node);
            if (Visit(adjacent_node, tracker)) {
                return true;
            }

            tracker.UndoVisit(adjacent_node);
        }
    }

    return false;
}
Beispiel #14
0
void testApp::setup()
{
	ofSetFrameRate(60);
	ofSetVerticalSync(true);

	ofBackground(0);

	play_rate = play_rate_t = 1;
	rotate = 0;

	bvh.resize(3);

	// You have to get motion and sound data from http://www.perfume-global.com

	// setup bvh
	bvh[0].load("bvhfiles/aachan.bvh");
	bvh[1].load("bvhfiles/kashiyuka.bvh");
	bvh[2].load("bvhfiles/nocchi.bvh");

	for (int i = 0; i < bvh.size(); i++)
	{
		bvh[i].setFrame(1);
	}

	track.loadSound("Perfume_globalsite_sound.wav");
	track.play();
	track.setLoop(true);

	// setup tracker
	for (int i = 0; i < bvh.size(); i++)
	{
		ofxBvh &b = bvh[i];

		for (int n = 0; n < b.getNumJoints(); n++)
		{
			const ofxBvhJoint *o = b.getJoint(n);
			Tracker *t = new Tracker;
			t->setup(o);
			trackers.push_back(t);
		}
	}
}
Beispiel #15
0
//--------------------------------------------------------------
void ofApp::setup() {
	ofSetFrameRate(60);
	ofSetVerticalSync(true);	
	
	rotate = 0;
	
	// setup bvh
	bvh[0].load("bvhfiles/kashiyuka.bvh");
	bvh[1].load("bvhfiles/nocchi.bvh");
	bvh[2].load("bvhfiles/aachan.bvh");
	
	for (int i = 0; i < 3; i++)	{
		bvh[i].play();
	}
	
	track.load("Perfume_globalsite_sound.wav");
	track.play();
	track.setLoop(true);
	
	// setup tracker
	for (int i = 0; i < 3; i++)
	{
		ofxBvh &b = bvh[i];
		
		for (int n = 0; n < b.getNumJoints(); n++) {
			const ofxBvhJoint *o = b.getJoint(n);
			Tracker *t = new Tracker;
			t->setup(o);
			t->setTrackerLength(trackerLength);
			trackers.push_back(t);
		}
	}
	
	camera.setFov(45);
	camera.setDistance(360);
	camera.disableMouseInput();
	
	background.load("background.png");
	
}
int main(int argc, char* argv[]) {

  Parser parser;
  GeneralConfig::scale = 10;
  parser.addGroup(TrackingConfig());
  parser.addGroup(RecordingConfig());
  parser.addGroup(SceneConfig());
  parser.addGroup(GeneralConfig());

  parser.addGroup(BulletConfig());
  parser.read(argc, argv);

  Tracker* TrackerSystem;
  if (TrackingConfig::objType=="towel")
    TrackerSystem = new TowelTracker();
  else if (TrackingConfig::objType=="rope")
    TrackerSystem = new RopeTracker();
  else throw std::runtime_error("invalid objType");
  extern bool LIVE;
  if (LIVE) TrackerSystem->runOnline();
  else TrackerSystem->runOffline();
}
template <uint32_t K> static bool test_random() {
  srand(K);
  error = false;
 
  for (uint32_t j = 0; j < iterations; ++j) {
    Tracker<K> tracker;

    uint32_t i = 0;
    for (i = 0; i < ops; ++i) {
      if ((rand() & 0xF) == 0) {
        // Simulate work that takes time
        if (logging) {
          printf("SLEEPING for %dms (%d)\n", sleepPeriodMS, PR_IntervalNow());
        }
        PR_Sleep(PR_MillisecondsToInterval(sleepPeriodMS));
        // Process pending timer events
        NS_ProcessPendingEvents(nullptr);
      }
      tracker.DoRandomOperation();
    }
  }
  
  return !error;
}
Beispiel #18
0
int main() {

	// Verify that piped outputs are line-buffered
	setvbuf(stdout, (char *) NULL, _IOLBF, 0); /* make line buffered stdout */
	T = Tracker("config.tz");

#ifdef _draw_
	namedWindow("window", 1);
#endif

	while (1) {
		T.update();

#ifdef _draw_
		if (T.C.size() > 0) {
			line(img, T.C[0][0], T.C[0][1], Scalar(0, 0, 255));
			line(img, T.C[0][1], T.C[0][2], Scalar(0, 255, 0));
			line(img, T.C[0][2], T.C[0][3], Scalar(255, 0, 0));
			line(img, T.C[0][3], T.C[0][0], Scalar(128, 128, 128));
			circle(img, T.C[0][0], 40, Scalar(0, 0, 255), 2, 8);
			circle(img, T.C[0][1], 40, Scalar(0, 0, 255), 2, 8);
			circle(img, T.C[0][2], 40, Scalar(0, 0, 255), 2, 8);
			circle(img, T.C[0][3], 40, Scalar(0, 0, 255), 2, 8);
		}

		for (int n = 0; n < T.P.size(); n++) {
			circle(img, Point(T.P[n].x, T.P[n].y), sqrt(T.P[n].num / PI), Scalar(0, 255, 0), 4, 8);
		}

		imshow("window", img);
#endif

		std::cout << T.tvecf.print((T.trackerFound)?1.0:0.0) << "\n";
	}
	return 0;
}
Beispiel #19
0
// This is a function, not a class method
void wrappedOnMouse(int currentEvent, int x, int y, int flags, void* ptr)
{
    Tracker* mcPtr = (Tracker*)ptr;
    if(mcPtr != NULL)
        mcPtr->realOnMouse(currentEvent, x, y, flags);
}
Beispiel #20
0
void demo1(int strawman)
{
    Tracker trk;

    if (strawman <= 3)
    {
    // FPix
    { Det d; d.setDisk( 29.1, 4.5, 16.1, 56, false); trk.add(d); }
    { Det d; d.setDisk( 39.6, 4.5, 16.1, 56, false); trk.add(d); }
    { Det d; d.setDisk( 51.6, 4.5, 16.1, 56, false); trk.add(d); }

    // BPix
    { Det d; d.setLayer(  3.0,  0.0, 27.4, 0, false); trk.add(d); }
    { Det d; d.setLayer(  6.8,  0.0, 27.4, 0, false); trk.add(d); }
    { Det d; d.setLayer( 10.9,  0.0, 27.4, 0, false); trk.add(d); }
    { Det d; d.setLayer( 16.0,  0.0, 27.4, 0, false); trk.add(d); }

    // Variant used for the initial proposal: 4 full disks, 3 half disks
    if (strawman == 0)
    {
	{ Det d; d.setDisk(  76.0, 4.5, 16.1, 56, true); trk.add(d); }
	{ Det d; d.setDisk(  85.0, 4.5, 16.1, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 108.0, 4.5, 16.1, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 140.0, 4.5, 16.1, 56, true); trk.add(d); }

	{ Det d; d.setDisk( 200.0, 10.0, 16.1, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 230.0, 10.0, 16.1, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 264.0, 10.0, 16.1, 56, true); trk.add(d); }
    }

    // Variant using 6 disks a la FPix
    if (strawman == 1)
    {
	{ Det d; d.setDisk(  83.0, 4.5, 16.1, 56, true); trk.add(d); }
	{ Det d; d.setDisk(  99.0, 4.5, 16.1, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 138.0, 4.5, 16.1, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 175.0, 4.5, 16.1, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 218.0, 4.5, 16.1, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 264.0, 4.5, 16.1, 56, true); trk.add(d); }
    }

    // Variant optimising lever arm using small and large r rings
    if (strawman == 2)
    {
	{ Det d; d.setDisk( 100.0, 14.5, 16.0, 56, true); trk.add(d); } // 1
	{ Det d; d.setDisk( 109.0, 14.5, 16.0, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 118.0, 14.5, 16.0, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 128.0, 14.5, 16.0, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 140.0, 14.5, 16.0, 56, true); trk.add(d); } // 5
	{ Det d; d.setDisk( 153.0, 14.5, 16.0, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 168.0, 14.5, 16.0, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 184.0, 14.5, 16.0, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 202.0, 14.5, 16.0, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 222.0, 14.5, 16.0, 56, true); trk.add(d); } // 10
	{ Det d; d.setDisk( 240.0, 14.5, 16.0, 56, true); trk.add(d); }

	{ Det d; d.setDisk( 66.0, 5.5, 12.0, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 88.0, 5.5, 12.0, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 130.0, 5.5, 12.0, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 180.0, 5.5, 12.0, 56, true); trk.add(d); }

	{ Det d; d.setDisk( 34.0, 3.2, 4.8, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 48.0, 3.2, 4.8, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 65.0, 3.2, 4.8, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 84.0, 3.2, 4.8, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 112.0, 3.2, 4.8, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 138.0, 3.2, 4.8, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 164.0, 3.2, 4.8, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 190.0, 3.2, 4.8, 56, true); trk.add(d); }

	{ Det d; d.setDisk( 264.0, 4.5, 16.1, 56, true); trk.add(d); }
    }

    // Variant using 6 disks a la FPix but the rings are separated in z for disks 1-5
    if (strawman == 3)
    {
	{ Det d; d.setDisk(  68.0, 4.5, 11.0, 56, true); trk.add(d); }
	{ Det d; d.setDisk(  92.0, 4.5, 11.0, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 125.0, 4.5, 11.0, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 170.0, 4.5, 11.0, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 210.0, 4.5, 11.0, 56, true); trk.add(d); }

	{ Det d; d.setDisk(  90.0, 10.0, 16.1, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 115.0, 10.0, 16.1, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 140.0, 10.0, 16.1, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 180.0, 10.0, 16.1, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 220.0, 10.0, 16.1, 56, true); trk.add(d); }

	{ Det d; d.setDisk( 264.0, 4.5, 16.1, 56, true); trk.add(d); }
    }

    // Variant with conical supply tube, first attempt
    if (strawman == 104)
    {
	// another FPix disk
	{ Det d; d.setDisk(  68.0, 4.5, 16.1, 56, true); trk.add(d); }

	// Now the start of VFpix
	{ Det d; d.setDisk(  85.0, 4.5, 16.1, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 109.0, 4.5, 16.1, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 140.0, 4.5, 16.1, 56, true); trk.add(d); }

	// In conical part, increasing radii
	{ Det d; d.setDisk( 183.0, 7.5, 20.0, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 230.0, 7.5, 35.0, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 265.0,12.0, 39.0, 56, true); trk.add(d); }
    }

    // Variant with conical supply tube, first attempt
    if (strawman == 105)
    {
	// another FPix disk
	{ Det d; d.setDisk(  51.6, 3.0,  4.5, 56, true); trk.add(d); }
	{ Det d; d.setDisk(  68.0, 4.5, 16.1, 56, true); trk.add(d); }

	// Now the start of VFpix
	{ Det d; d.setDisk(  85.0, 4.5, 16.1, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 109.0, 4.5, 16.1, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 140.0, 4.5, 16.1, 56, true); trk.add(d); }

	// In conical part, increasing radii
	{ Det d; d.setDisk( 183.0, 7.5, 20.0, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 230.0, 7.5, 35.0, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 265.0,12.0, 39.0, 56, true); trk.add(d); }
    }
    }

    if (strawman == 4)
    {
        // BPix
        { Det d; d.setLayer(  2.0,  0.0, 20.0, 0, false); trk.add(d); }
        { Det d; d.setLayer(  4.0,  0.0, 33.0, 0, false); trk.add(d); }
        { Det d; d.setLayer(  7.0,  0.0, 33.0, 0, false); trk.add(d); }
        { Det d; d.setLayer( 11.5,  0.0, 33.0, 0, false); trk.add(d); }
        { Det d; d.setLayer( 17.6,  0.0, 33.0, 0, false); trk.add(d); }

        // FPix
        { Det d; d.setDisk( 35.5, 4.0, 16.0, 56, false); trk.add(d); }
        { Det d; d.setDisk( 47.5, 4.0, 16.0, 56, false); trk.add(d); }
        { Det d; d.setDisk( 75.0, 10.0, 16.0, 56, false); trk.add(d); }

        // VFPix
        { Det d; d.setLayer(  2.0, 20.0, 55.0, 0, true); trk.add(d); }
	{ Det d; d.setDisk( 75.0, 4.0, 10.0, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 95.0, 4.0, 14.6, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 120.0, 4.5, 14.6, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 160.0, 6.0, 12, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 165.0, 10.5, 16.1, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 215.0, 8.0, 20, 56, true); trk.add(d); }
	{ Det d; d.setDisk( 285.0, 10.5, 28, 56, true); trk.add(d); }

    // Define tracker volumes
    trk.volBP.addPoint(0, 0);
    trk.volBP.addPoint(300, 0);
    trk.volBP.addPoint(300, 4.6);
    trk.volBP.addPoint(96, 1.5);
    trk.volBP.addPoint(0, 1.5);
    trk.volBP.addPoint(0, 0);

    trk.volBPix.addPoint(0, 2.0);
    trk.volBPix.addPoint(30, 2.0);
    trk.volBPix.addPoint(30, 17.4);
    trk.volBPix.addPoint(152, 17.4);
    trk.volBPix.addPoint(290, 33.4);
    trk.volBPix.addPoint(290, 50);
    trk.volBPix.addPoint(280, 50);
    trk.volBPix.addPoint(280, 34);
    trk.volBPix.addPoint(156, 19);
    trk.volBPix.addPoint(0, 19);
    trk.volBPix.addPoint(0, 2.0);

    trk.volFPix.addPoint(30, 2.0);
    trk.volFPix.addPoint(70, 2.0);
    trk.volFPix.addPoint(70, 15.6);
    trk.volFPix.addPoint(141, 15.6);
    trk.volFPix.addPoint(300, 33);
    trk.volFPix.addPoint(300, 50);
    trk.volFPix.addPoint(290, 50);
    trk.volFPix.addPoint(290, 33.2);
    trk.volFPix.addPoint(150, 17.2);
    trk.volFPix.addPoint(30, 17.2);
    trk.volFPix.addPoint(30, 2.0);

    trk.volVFPix.addPoint(70, 2.0);
    trk.volVFPix.addPoint(90, 2.0);
    trk.volVFPix.addPoint(310, 10);
    trk.volVFPix.addPoint(310, 50);
    trk.volVFPix.addPoint(300, 50);
    trk.volVFPix.addPoint(300, 32.2);
    trk.volVFPix.addPoint(143.5, 15.4);
    trk.volVFPix.addPoint(70, 15.4);
    trk.volVFPix.addPoint(70, 2.0);
    }

    if (strawman == 5)
    {
        // BPix
        { Det d; d.setLayer(  3.0,  0.0, 32.0, 0, false, "vtx_b1"); trk.add(d); } // vtx_b1
        { Det d; d.setLayer(  6.8,  0.0, 32.0, 0, false, "vtx_b2"); trk.add(d); } // vtx_b2
        { Det d; d.setLayer( 11.8,  0.0, 32.0, 0, false, "vtx_b3"); trk.add(d); } // vtx_b3
        { Det d; d.setLayer( 18.8,  0.0, 32.0, 0, false, "vtx_b4"); trk.add(d); } // vtx_b4

        // FPix
        { Det d; d.setDisk( 34.0, 12.0, 20.0, 56, false, "vtx_f1_d1"); trk.add(d); } // vtx_f1_d1
        { Det d; d.setDisk( 37.0,  6.8, 12.8, 56, false, "vtx_f1_d2"); trk.add(d); } // vtx_f1_d2
        { Det d; d.setDisk( 54.0, 12.0, 20.0, 56, false, "vtx_f2_d1"); trk.add(d); } // vtx_f2_d1
        { Det d; d.setDisk( 69.0,  7.6, 15.6, 56, false, "vtx_f2_d2"); trk.add(d); } // vtx_f2_d2
        { Det d; d.setDisk( 92.0, 12.0, 20.0, 56, false, "vtx_f3_d1"); trk.add(d); } // vtx_f3_d1
        { Det d; d.setDisk(109.0, 12.0, 20.0, 56, false, "vtx_f4_d1"); trk.add(d); } // vtx_f4_d1
        { Det d; d.setDisk(145.0, 16.0, 20.0, 56, true, "vtx_f5_d1"); trk.add(d); } // vtx_f5_d1

        // VFPix
        { Det d; d.setLayer(  3.0, 32.0, 72.0, 0, true, "pt_b1"); trk.add(d); } // pt_b1
        { Det d; d.setDisk( 88.0, 3.2, 11.2, 56, true, "pt_f1_d1"); trk.add(d); } // pt_f1_d1
        { Det d; d.setDisk(126.0, 9.2, 15.2, 56, true, "pt_f2_d1"); trk.add(d); } // pt_f2_d1
        { Det d; d.setDisk(144.0, 5.4, 11.4, 56, true, "pt_f2_d2"); trk.add(d); } // pt_f2_d2
        { Det d; d.setDisk(183.0,12.2, 20.2, 56, true, "pt_f3_d1"); trk.add(d); } // pt_f3_d1
        { Det d; d.setDisk(189.0, 7.0, 13.0, 56, true, "pt_f3_d2"); trk.add(d); } // pt_f3_d2
        { Det d; d.setDisk(233.0,17.6, 25.6, 56, true, "pt_f4_d1"); trk.add(d); } // pt_f4_d1
        { Det d; d.setDisk(230.0,11.8, 17.8, 56, true, "pt_f4_d2"); trk.add(d); } // pt_f4_d2
        { Det d; d.setDisk(238.0, 8.8, 12.8, 56, true, "pt_f4_d3"); trk.add(d); } // pt_f4_d3
        { Det d; d.setDisk(287.0,24.0, 32.0, 56, true, "pt_f5_d1"); trk.add(d); } // pt_f5_d1
        { Det d; d.setDisk(284.0,16.0, 24.0, 56, true, "pt_f5_d2"); trk.add(d); } // pt_f5_d2
        { Det d; d.setDisk(288.0,10.6, 16.6, 56, true, "pt_f5_d3"); trk.add(d); } // pt_f5_d3
    }


    cout << "Tracker consists of " << trk.getSize() << " units" << endl;

    const double eta_min(0);
    const double eta_max(5);
    const double eta_delta = eta_max-eta_min;
    const int N(5000);
    const double eta_step = eta_delta / N;

    TH1D *h1 = new TH1D("h1", "all pixels;#eta;# of hits", N, eta_min, eta_max);
    TH1D *h2 = new TH1D("h2", "VFPix only;#eta;# of hits", N, eta_min, eta_max);
    TH1D *h3 = new TH1D("h3", "all pixels;#eta;r_{min} [cm]", N, eta_min, eta_max);
    TH1D *h4 = new TH1D("h4", "all pixels;#eta;r_{max} [cm]", N, eta_min, eta_max);
    TH1D *h5 = new TH1D("h5", "all pixels;#eta;r_{max}-r_{min} [cm]", N, eta_min, eta_max);
    TH1D *h6 = new TH1D("h6", "all pixels;#eta;z_{min} [cm]", N, eta_min, eta_max);

    for (int i = 0; i!=N; i++)
    {
	const double eta = eta_min + i*eta_step;
	Trackresult res = trk.track(eta);
	//cout << "eta: " << eta << " nHits: " << res.nHits << endl;
	h1->SetBinContent(i+1,res.nHits);
	h2->SetBinContent(i+1,res.nHits_vfpix);
	h3->SetBinContent(i+1,res.r_min);
	h4->SetBinContent(i+1,res.r_max);
	h5->SetBinContent(i+1,res.r_max-res.r_min);
	h6->SetBinContent(i+1,res.z_min);
    }
    TCanvas *c = new TCanvas("c","c", 500, 500);
    trk.draw(0, 0, 300, 50); c->SaveAs("tracker.pdf"); c->SaveAs("tracker.png");
    h1->Draw(); c->SaveAs("h1.pdf"); c->SaveAs("h1.png");
    h2->Draw(); c->SaveAs("h2.pdf"); c->SaveAs("h2.png");
    h3->Draw(); c->SaveAs("h3.pdf"); c->SaveAs("h3.png");
    h4->Draw(); c->SaveAs("h4.pdf"); c->SaveAs("h4.png");
    h5->Draw(); c->SaveAs("h5.pdf"); c->SaveAs("h5.png");
    h6->Draw(); c->SaveAs("h6.pdf"); c->SaveAs("h6.png");
    trk.dump();
}
Beispiel #21
0
int main(int argc, const char **argv)
{

    VideoCapture cap;
    Tracker objTracker;

    CommandLineParser parser(argc, argv, keys);
    if (parser.has("help")) {
        help();
        return 0;
    }

    cap.open(argv[1]);
    if (!cap.isOpened()) {
        help();
        cout << "***Could not access file...***\n";
        return -1;
    }
    Size S = Size((int) cap.get(CV_CAP_PROP_FRAME_WIDTH),    //Acquire input size
                  (int) cap.get(CV_CAP_PROP_FRAME_HEIGHT));

    cout << hot_keys;
    bool paused = false;

    Mat frame;
    cap >> frame;

    objTracker.Init(S, Tracker::InitParams());

    int ex = static_cast<int>(cap.get(CV_CAP_PROP_FOURCC));
    VideoWriter outputVideo;
    // outputVideo.open("output.mp4" , ex, cap.get(CV_CAP_PROP_FPS), S, true);

    Mat out;
    try {

        while (1) {

            if (!paused && Tracker::g_initTracking) {
                cap >> frame;
                if (frame.empty())
                    break;
            }

            if (!paused) {


                objTracker.ProcessFrame(frame, out);

            }
            imshow("CamShift", out);
            // outputVideo << out;

            char c = (char)waitKey(10);
            if (c == 27)
                break;
            switch (c) {
            case 'b':
                objTracker.ToggleShowBackproject();
                break;
            case 'c':
                // trackObject = 0;
                // histimg = Scalar::all(0);
                break;
            case 'h':
                objTracker.HideControlsGUI();
            //     showHist = !showHist;    
            //     if (!showHist)
            //         destroyWindow("Histogram");
            //     else
            //         namedWindow("Histogram", 1);
            //     break;
            case 'p':
                paused = !paused;
                break;
            case 'r':
                cap.set(CV_CAP_PROP_POS_AVI_RATIO, 0);
                // outputVideo.set(CV_CAP_PROP_POS_AVI_RATIO, 0);
                cap >> frame;
                objTracker.Init(S, Tracker::InitParams());

                break;
            default:
                ;
            }
        }
    }

    catch (const cv::Exception &e) {
        std::cerr << e.what();
        cap.release();
        outputVideo.release();

        return 1;
    }
    cap.release();
    outputVideo.release();

    return 0;
}
Beispiel #22
0
 bool configure(ResourceFinder &rf)
 {
     return tracker.open();
 }
Beispiel #23
0
inline bool operator == (Tracker const& lhs, Tracker const& rhs)
{
    return
        &lhs.GetStatistics() == &rhs.GetStatistics() &&
        lhs.GetTag() == rhs.GetTag();
}
Beispiel #24
0
 bool updateModule()
 {
     tracker.loop();
     
     return true; 
 }
Beispiel #25
0
    bool close()
    {
	    return tracker.close();
    }
Beispiel #26
0
    bool interruptModule()
    {
        tracker.interrupt();

        return true;
    }
void test_shared_alloc()
{
#if defined( KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST )
  typedef const Kokkos::Impl::SharedAllocationHeader                               Header;
  typedef Kokkos::Impl::SharedAllocationTracker                                    Tracker;
  typedef Kokkos::Impl::SharedAllocationRecord< void, void >                       RecordBase;
  typedef Kokkos::Impl::SharedAllocationRecord< MemorySpace, void >                RecordMemS;
  typedef Kokkos::Impl::SharedAllocationRecord< MemorySpace, SharedAllocDestroy >  RecordFull;

  static_assert( sizeof( Tracker ) == sizeof( int* ), "SharedAllocationTracker has wrong size!" );

  MemorySpace s;

  const size_t N = 1200;
  const size_t size = 8;

  RecordMemS * rarray[ N ];
  Header     * harray[ N ];

  RecordMemS ** const r = rarray;
  Header     ** const h = harray;

  Kokkos::RangePolicy< ExecutionSpace > range( 0, N );

  {
    // Since always executed on host space, leave [=]
    Kokkos::parallel_for( range, [=] ( size_t i ) {
      char name[64];
      sprintf( name, "test_%.2d", int( i ) );

      r[i] = RecordMemS::allocate( s, name, size * ( i + 1 ) );
      h[i] = Header::get_header( r[i]->data() );

      ASSERT_EQ( r[i]->use_count(), 0 );

      for ( size_t j = 0; j < ( i / 10 ) + 1; ++j ) RecordBase::increment( r[i] );

      ASSERT_EQ( r[i]->use_count(), ( i / 10 ) + 1 );
      ASSERT_EQ( r[i], RecordMemS::get_record( r[i]->data() ) );
    });

#ifdef KOKKOS_DEBUG
    // Sanity check for the whole set of allocation records to which this record belongs.
    RecordBase::is_sane( r[0] );
    // RecordMemS::print_records( std::cout, s, true );
#endif

    Kokkos::parallel_for( range, [=] ( size_t i ) {
      while ( 0 != ( r[i] = static_cast< RecordMemS * >( RecordBase::decrement( r[i] ) ) ) ) {
#ifdef KOKKOS_DEBUG
        if ( r[i]->use_count() == 1 ) RecordBase::is_sane( r[i] );
#endif
      }
    });
  }

  {
    int destroy_count = 0;
    SharedAllocDestroy counter( &destroy_count );

    Kokkos::parallel_for( range, [=] ( size_t i ) {
      char name[64];
      sprintf( name, "test_%.2d", int( i ) );

      RecordFull * rec = RecordFull::allocate( s, name, size * ( i + 1 ) );

      rec->m_destroy = counter;

      r[i] = rec;
      h[i] = Header::get_header( r[i]->data() );

      ASSERT_EQ( r[i]->use_count(), 0 );

      for ( size_t j = 0; j < ( i / 10 ) + 1; ++j ) RecordBase::increment( r[i] );

      ASSERT_EQ( r[i]->use_count(), ( i / 10 ) + 1 );
      ASSERT_EQ( r[i], RecordMemS::get_record( r[i]->data() ) );
    });

#ifdef KOKKOS_DEBUG
    RecordBase::is_sane( r[0] );
#endif

    Kokkos::parallel_for( range, [=] ( size_t i ) {
      while ( 0 != ( r[i] = static_cast< RecordMemS * >( RecordBase::decrement( r[i] ) ) ) ) {
#ifdef KOKKOS_DEBUG
        if ( r[i]->use_count() == 1 ) RecordBase::is_sane( r[i] );
#endif
      }
    });

    ASSERT_EQ( destroy_count, int( N ) );
  }

  {
    int destroy_count = 0;

    {
      RecordFull * rec = RecordFull::allocate( s, "test", size );

      // ... Construction of the allocated { rec->data(), rec->size() }

      // Copy destruction function object into the allocation record.
      rec->m_destroy = SharedAllocDestroy( & destroy_count );

      ASSERT_EQ( rec->use_count(), 0 );

      // Start tracking, increments the use count from 0 to 1.
      Tracker track;

      track.assign_allocated_record_to_uninitialized( rec );

      ASSERT_EQ( rec->use_count(), 1 );
      ASSERT_EQ( track.use_count(), 1 );

      // Verify construction / destruction increment.
      for ( size_t i = 0; i < N; ++i ) {
        ASSERT_EQ( rec->use_count(), 1 );

        {
          Tracker local_tracker;
          local_tracker.assign_allocated_record_to_uninitialized( rec );
          ASSERT_EQ( rec->use_count(), 2 );
          ASSERT_EQ( local_tracker.use_count(), 2 );
        }

        ASSERT_EQ( rec->use_count(), 1 );
        ASSERT_EQ( track.use_count(), 1 );
      }

      Kokkos::parallel_for( range, [=] ( size_t i ) {
        Tracker local_tracker;
        local_tracker.assign_allocated_record_to_uninitialized( rec );
        ASSERT_GT( rec->use_count(), 1 );
      });

      ASSERT_EQ( rec->use_count(), 1 );
      ASSERT_EQ( track.use_count(), 1 );

      // Destruction of 'track' object deallocates the 'rec' and invokes the destroy function object.
    }

    ASSERT_EQ( destroy_count, 1 );
  }

#endif /* #if defined( KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST ) */

}
    return result;
}
}

TEST_CASE("Tracker works", "[overlay][Tracker]")
{
    VirtualClock clock;
    auto const& cfg = getTestConfig();
    auto app = Application::create(clock, cfg);

    auto hash = sha256(ByteSlice{"hash"});
    auto nullAskPeer = AskPeer{[](Peer::pointer, Hash) {}};

    SECTION("empty tracker")
    {
        Tracker t{*app, hash, nullAskPeer};
        REQUIRE(t.size() == 0);
        REQUIRE(t.empty());
        REQUIRE(t.getLastSeenSlotIndex() == 0);
    }

    SECTION("can listen on envelope")
    {
        Tracker t{*app, hash, nullAskPeer};
        auto env1 = makeEnvelope(1);
        t.listen(env1);

        REQUIRE(t.size() == 1);
        REQUIRE(!t.empty());
        REQUIRE(t.getLastSeenSlotIndex() == 1);
        REQUIRE(env1 == t.pop());
Beispiel #29
0
int main( int argc, const char* argv[] )
{

	vector<double> mx,my,px,py;

	CDisplayWindowPlots medidasPlot("Medidas");
	CDisplayWindowPlots clusterPlot("Cluster");
	CDisplayWindowPlots piernasPlot("Piernas");
	CDisplayWindowPlots personasPlot("Personas");

	vector<CPose2D>* puntos;
	CTicTac timer;

	Detector detector;

	Tracker seguidor;

	bool filtroInicializado=false;



	// Cargar modelo SVM
	struct svm_model *model=svm_load_model("svm_model");
	struct svm_node *instancia;
	double target;

	// datos de cada instancia, 4 en total: 3 carcateristicas más -1 indicando fin
	instancia=Malloc(struct svm_node,4);


	medidasPlot.hold_on();
	double limits[] = {0,2,-2,2};
	vector<double> limites (limits, limits + 4);



	for(int i=0;i<24;i++){

		timer.Tic();

		char nombre[100];

		sprintf(nombre,"/home/jplata/Eclipse/MedidasPiernas/12Julio/200ms/raw_laser%i.dat",i);
		cout << "Fichero:  " << nombre << endl;

		// Comprobar existencia del archivo
		FILE* file=fopen(nombre,"r");

		if(!file){
			cout << "¡¡¡¡Archivo no encontrado!!! Continuar con el siguiente" << endl;
			continue;
		}


		detector.abrirFichero(nombre,false);


		// Medidas
		puntos=detector.getPuntos();


		Eigen::MatrixXf rectas=detector.eliminarRectas(30,181);


		vector<Cluster> piernas=detector.clusterizar(0.1,3);;

		mx.clear();
		my.clear();



		for(unsigned int i=0;i<puntos->size();i++){
			mx.push_back(puntos->at(i).x());
			my.push_back(puntos->at(i).y());
		}

		medidasPlot.clear();
		string fileName(nombre);
		medidasPlot.setWindowTitle("Medidas - " + fileName.substr(fileName.find_last_of("/")+1));
		medidasPlot.plot(mx,my,".b2");

		for(int j=0;j < rectas.rows();j++){

			Grafico::dibujarLinea(&medidasPlot,rectas(j,0),rectas(j,1),limites);

		}


		clusterPlot.clear();
		clusterPlot.setWindowTitle("Cluster - " + fileName.substr(fileName.find_last_of("/")+1));
		clusterPlot.hold_on();

		piernasPlot.clear();
		piernasPlot.setWindowTitle("Piernas - " + fileName.substr(fileName.find_last_of("/")+1));
		piernasPlot.hold_on();

		personasPlot.clear();
		personasPlot.setWindowTitle("Personas - " + fileName.substr(fileName.find_last_of("/")+1));
		personasPlot.hold_on();



		// Obtengo puntos clusters
		string formato[2];
		formato[0]=".r2";
		formato[1]=".b2";
		int f=0;

		for(int j=0;j < piernas.size();j++){


			puntos=piernas[j].getPuntos();
			px.clear();
			py.clear();

			for(unsigned int k=0;k<puntos->size();k++){
				px.push_back(puntos->at(k).x());
				py.push_back(puntos->at(k).y());
			}
			clusterPlot.plot(px,py,formato[f%2]);

			// Determinar si es pierna o no
			instancia[0].index=1;
			instancia[1].index=2;
			instancia[2].index=3;
			instancia[3].index=-1;

			instancia[0].value=piernas[j].getContorno();
			instancia[1].value=piernas[j].getAncho();
			instancia[2].value=piernas[j].getProfundidad();

			target=svm_predict(model,instancia);

			if(target==1){
				// El clasificador SVM lo reconoce como pierna
				piernasPlot.plot(px,py,formato[j%2]);
			}
			else{
				// No es una pierna, lo elimino del vector
				piernas.erase(piernas.begin()+j);
				j--;
			}
			f++;

		}


		vector<CPose2D> personas=detector.buscarPersonas(piernas);
		cout << "Personas detectadas: " << personas.size() << endl;



		detector.printClusters(piernas);
		px.clear();
		py.clear();
		for(int k=0;k < personas.size(); k++){
			px.push_back(personas[k].x());
			py.push_back(personas[k].y());
		}
		piernasPlot.plot(px,py,".c4");
		personasPlot.plot(px,py,".r4");


		// Filtro de Partículas
		if(!filtroInicializado){
			// Filtro no inicializado aún
			// Compruebo si se ha detectado persona
			if(!personas.empty()){
				seguidor.inicializar(50,personas[0]);
				filtroInicializado=true;
				seguidor.drawParticles(&personasPlot);
			}

		}
		else{
			CPose2D objetivo;
			// Filtro ya inicializado
			if(personas.empty()){
				// No se ha detectado persona
				objetivo=seguidor.obtenerPosicionEstimada(CPose2D(),false);
			}
			else{
				objetivo=seguidor.obtenerPosicionEstimada(personas[0],true);
			}
			seguidor.drawParticles(&personasPlot);
			px.clear();
			py.clear();
			px.push_back(objetivo.x());
			py.push_back(objetivo.y());

			personasPlot.plot(px,py,".k8");
		}




		medidasPlot.axis(-0.5,4,-4,4);
		clusterPlot.axis(-0.5,3,-3,3);
		piernasPlot.axis(-0.5,3,-3,3);
		personasPlot.axis(-0.5,3,-3,3);

		cout << "Tiempo total (ms): " << timer.Tac()*1000 << endl;


		cout << "Presione cualquier tecla para pasar a la siguiente muestra" << endl;

		mrpt::system::os::getch();

	}


	//print_vector("%f\t",ancho);



	//plot1.axis(-0.1,0.5,-0.1,0.5);
	//plot2.axis(-0.1,0.5,-0.1,0.5);


	cout << "Presione cualquier tecla para terminar:" << endl;

	mrpt::system::os::getch();


}
    void MagnetGeneratorPlugin::generateMagnet()
    {
        bt::TorrentInterface* tor = getGUI()->getTorrentActivity()->getCurrentTorrent();
        if (!tor)
            return;

        QUrl dn(tor->getStats().torrent_name);
        SHA1Hash ih(tor->getInfoHash());

        QString uri("magnet:?xt=urn:btih:");
        uri.append(ih.toString());

        if (MagnetGeneratorPluginSettings::dn())
        {
            uri.append("&dn=");
            uri.append(QUrl::toPercentEncoding(dn.toString(), "{}", NULL));
        }

        if ((MagnetGeneratorPluginSettings::customtracker() && MagnetGeneratorPluginSettings::tr().length() > 0) && !MagnetGeneratorPluginSettings::torrenttracker())
        {
            uri.append("&tr=");
            QUrl tr(MagnetGeneratorPluginSettings::tr());
            uri.append(QUrl::toPercentEncoding(tr.toString(), "{}", NULL));
        }

        if (MagnetGeneratorPluginSettings::torrenttracker())
        {
            QList<bt::TrackerInterface*> trackers = tor->getTrackersList()->getTrackers();
            if (!trackers.isEmpty())
            {
                Tracker* trk = (Tracker*)trackers.first();
                QUrl tr(trk->trackerURL());

                uri.append("&tr=");
                uri.append(QUrl::toPercentEncoding(tr.toString(), "{}", NULL));
            }

        }

        addToClipboard(uri);

        if (MagnetGeneratorPluginSettings::popup())
            showPopup();

    }