//Body tracking Single Threaded int mainSingleThread(string path, int cameras, int frames, int particles, int layers, bool OutputBMP) { cout << endl << "Running Single Threaded" << endl << endl; TrackingModel model; if(!model.Initialize(path, cameras, layers)) //Initialize model parameters { cout << endl << "Error loading initialization data." << endl; return 0; } model.GetObservation(0); //load data for first frame ParticleFilter<TrackingModel> pf; //particle filter instantiated with body tracking model type pf.SetModel(model); //set the particle filter model pf.InitializeParticles(particles); //generate initial set of particles and evaluate the log-likelihoods cout << "Using dataset : " << path << endl; cout << particles << " particles with " << layers << " annealing layers" << endl << endl; ofstream outputFileAvg((path + "poses.txt").c_str()); vector<float> estimate; //expected pose from particle distribution #if defined(ENABLE_PARSEC_HOOKS) __parsec_roi_begin(); #endif clock_t start_t1 = clock(); for(int i = 0; i < frames; i++) //process each set of frames { cout << "Processing frame " << i << endl; if(!pf.Update((float)i)) //Run particle filter step { cout << "Error loading observation data" << endl; return 0; } pf.Estimate(estimate); //get average pose of the particle distribution WritePose(outputFileAvg, estimate); if(OutputBMP) pf.Model().OutputBMP(estimate, i); //save output bitmap file } #if defined(ENABLE_PARSEC_HOOKS) __parsec_roi_end(); #endif clock_t end_t2 = clock(); long double diff_ticks = ((long double)end_t2 - (long double)start_t1); cout << "ROI It took me " << diff_ticks << " clicks and " << diff_ticks/CLOCKS_PER_SEC << " seconds." << endl; return 1; }
//Body tracking Single Threaded int mainSingleThread(string path, int cameras, int frames, int particles, int layers, bool OutputBMP) { cout << endl << "Running Single Threaded" << endl << endl; TrackingModel model; if(!model.Initialize(path, cameras, layers)) //Initialize model parameters { cout << endl << "Error loading initialization data." << endl; return 0; } model.GetObservation(0); //load data for first frame ParticleFilter<TrackingModel> pf; //particle filter instantiated with body tracking model type pf.SetModel(model); //set the particle filter model pf.InitializeParticles(particles); //generate initial set of particles and evaluate the log-likelihoods cout << "Using dataset : " << path << endl; cout << particles << " particles with " << layers << " annealing layers" << endl << endl; ofstream outputFileAvg((path + "poses.txt").c_str()); vector<float> estimate; //expected pose from particle distribution for(int i = 0; i < frames; i++) //process each set of frames { cout << "Processing frame " << i << endl; if(!pf.Update((float)i)) //Run particle filter step { cout << "Error loading observation data" << endl; return 0; } pf.Estimate(estimate); //get average pose of the particle distribution WritePose(outputFileAvg, estimate); if(OutputBMP) pf.Model().OutputBMP(estimate, i); //save output bitmap file } return 1; }