KINECT STATS GENERATOR FOR SPORTS VISUALISATION
1.0
|
Generates all 2D stats for this application. More...
#include <TwoDStatsGeneration.h>
Public Member Functions | |
TwoDStatsGeneration () | |
ctor | |
~TwoDStatsGeneration () | |
dtor | |
void | calculatePlayerImpactPtsFromIndices (std::vector< std::vector< cv::Point3f > > &_inputPlayerBallPts, std::vector< std::vector< int > > &_playerDeepestPtIndices, std::vector< cv::Point > &o_playerImpactPtsAllRallies) |
calculates the actual player impact points from the available data and the indices this will be called by the player class whenever it needs data into impact points vector | |
void | generatePercentageDistribution (int _widthBounds, int _heightBounds, std::vector< cv::Point > &_playerImpactPtsAllRallies, int _whichQuadrant, std::vector< cv::Point > &o_specificQuadPts, float &o_percentage) |
given sets of dimensions of the field of play, this would fill up a specific percentage value representing the the corresponding field of play percentage so one set of dimension, returning one percentage value |
Generates all 2D stats for this application.
Definition at line 18 of file TwoDStatsGeneration.h.
void TwoDStatsGeneration::calculatePlayerImpactPtsFromIndices | ( | std::vector< std::vector< cv::Point3f > > & | _inputPlayerBallPts, |
std::vector< std::vector< int > > & | _playerDeepestPtIndices, | ||
std::vector< cv::Point > & | o_playerImpactPtsAllRallies | ||
) |
calculates the actual player impact points from the available data and the indices this will be called by the player class whenever it needs data into impact points vector
[in] | _inputPlayerBallPts | represents tracked pts |
[in] | _playerDeepestPtIndices | represents depth look up pts |
[out] | o_playerImpactPtsAllRallies | represents depth pts |
Definition at line 18 of file TwoDStatsGeneration.cpp.
{ if(_playerDeepestPtIndices.size() != 0) { for(int i = 0;i<_playerDeepestPtIndices.size();i++) { for(int j=0;j<_playerDeepestPtIndices[i].size();j++) { // if the impact point index is not -1, then there is an impact point for this rally if(_playerDeepestPtIndices[i][j] != -1) { o_playerImpactPtsAllRallies.push_back(cv::Point((int)(_inputPlayerBallPts[i][_playerDeepestPtIndices[i][j]]).x,(int)(_inputPlayerBallPts[i][_playerDeepestPtIndices[i][j]]).y)); } else { std::cout<<"No impact point for Rally number:"<<i<<"..so skipping to next rally.\n"; } } } } else { std::cout<<"No data in indices array for the player.\n"; } }
void TwoDStatsGeneration::generatePercentageDistribution | ( | int | _widthBounds, |
int | _heightBounds, | ||
std::vector< cv::Point > & | _playerImpactPtsAllRallies, | ||
int | _whichQuadrant, | ||
std::vector< cv::Point > & | o_specificQuadPts, | ||
float & | o_percentage | ||
) |
given sets of dimensions of the field of play, this would fill up a specific percentage value representing the the corresponding field of play percentage so one set of dimension, returning one percentage value
[in] | _widthBounds | represents width of TT table |
[in] | _heightBounds | represents height of TT table |
[in] | _whichQuadrant | represents court sides |
[out] | o_specificQuadPts | represents retrieved quad specific pts |
[out] | o_percentage | represents retrieved quad specific percentages |
Definition at line 50 of file TwoDStatsGeneration.cpp.
{ switch(_whichQuadrant) { //bottom left case 0: { for(int i=0;i<_playerImpactPtsAllRallies.size();i++) { if((_playerImpactPtsAllRallies[i].x <= _widthBounds) && (_playerImpactPtsAllRallies[i].y <= _heightBounds)) { // if it falls into the requested quadrant then fill in the buffer o_specificQuadPts.push_back(_playerImpactPtsAllRallies[i]); } } break; } // top left case 1: { for(int i=0;i<_playerImpactPtsAllRallies.size();i++) { if((_playerImpactPtsAllRallies[i].x <= _widthBounds) && (_playerImpactPtsAllRallies[i].y >= _heightBounds)) { // if it falls into the requested quadrant then fill in the buffer o_specificQuadPts.push_back(_playerImpactPtsAllRallies[i]); } } break; } // top right case 2: { for(int i=0;i<_playerImpactPtsAllRallies.size();i++) { if((_playerImpactPtsAllRallies[i].x > _widthBounds) && (_playerImpactPtsAllRallies[i].y > _heightBounds)) { // if it falls into the requested quadrant then fill in the buffer o_specificQuadPts.push_back(_playerImpactPtsAllRallies[i]); } } break; } // bottom right case 3: { for(int i=0;i<_playerImpactPtsAllRallies.size();i++) { if((_playerImpactPtsAllRallies[i].x > _widthBounds) && (_playerImpactPtsAllRallies[i].y < _heightBounds)) { // if it falls into the requested quadrant then fill in the buffer o_specificQuadPts.push_back(_playerImpactPtsAllRallies[i]); } } break; } } o_percentage = (float)((float)o_specificQuadPts.size()/(float)_playerImpactPtsAllRallies.size()); o_percentage = o_percentage * 100; }