Skip to content

Commit ee2f5cd

Browse files
committed
cleaned up gestures files, gestures right now are usable if you match the framerate of their acquisition, will add support regardless of framerate..
1 parent f281872 commit ee2f5cd

20 files changed

Lines changed: 4025 additions & 3980 deletions

MocapNETLib/gestureRecognition.cpp

Lines changed: 230 additions & 209 deletions
Large diffs are not rendered by default.

MocapNETLib/gestureRecognition.hpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,23 @@
1414
*/
1515

1616

17-
const unsigned int hardcodedGestureNumber=12;
17+
const unsigned int hardcodedGestureNumber=10;
1818

1919
static const char * hardcodedGestureName[] =
2020
{
21-
"comeleft.bvh", //0
22-
"help.bvh", //1
23-
"push.bvh", //2
24-
"comeright.bvh", //3
25-
"lefthandcircle.bvh", //4
21+
"comeleft.bvh", //0
22+
"help.bvh", //1
23+
"push.bvh", //2
24+
"comeright.bvh", //3
25+
"lefthandcircle.bvh", //4
2626
"righthandcircle.bvh",//5
27-
"waveleft.bvh", //6
28-
"doubleclap.bvh", //7
29-
"leftkick.bvh", //8
30-
"rightkick.bvh", //9
31-
"waveright.bvh", //10
32-
"tpose.bvh", //11
27+
"waveleft.bvh", //6
28+
"doubleclap.bvh", //7
29+
"waveright.bvh", //8
30+
"tpose.bvh", //9
31+
""
32+
"leftkick.bvh", //10
33+
"rightkick.bvh", //11
3334
""
3435
};
3536

@@ -61,6 +62,7 @@ struct GestureDatabase
6162
unsigned int gestureChecksPerformed;
6263
unsigned int numberOfLoadedGestures;
6364
struct RecordedGesture gesture[hardcodedGestureNumber];
65+
unsigned long previousGestureCheckTimestamp;
6466
};
6567

6668

MocapNETLib/mocapnet.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -447,11 +447,11 @@ std::vector<float> runMocapNET(struct MocapNET * mnet,std::vector<float> input)
447447
addToMotionHistory(&mnet->poseHistoryStorage,result);
448448

449449
int gestureDetected=compareHistoryWithKnownGestures(
450-
&mnet->recognizedGestures,
451-
&mnet->poseHistoryStorage,
452-
75.0,//Percentage complete..
453-
20.0 //Angle thrshold
454-
);
450+
&mnet->recognizedGestures,
451+
&mnet->poseHistoryStorage,
452+
85.0,//Percentage complete..
453+
23.0 //Angle thrshold
454+
);
455455

456456
if (gestureDetected!=0)
457457
{

MocapNETLib/tools.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ unsigned long GetTickCountMillisecondsMN()
8888
}
8989

9090

91+
float convertStartEndTimeFromMicrosecondsToFPS(unsigned long startTime, unsigned long endTime)
92+
{
93+
float timeInMilliseconds = (float) (endTime-startTime)/1000;
94+
if (timeInMilliseconds ==0.0)
95+
{
96+
timeInMilliseconds=0.00001; //Take care of division by null..
97+
}
98+
return (float) 1000/timeInMilliseconds;
99+
}
91100

92101
char fileExists(const char * filename)
93102
{

MocapNETLib/tools.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ unsigned long GetTickCountMicrosecondsMN();
4040
unsigned long GetTickCountMillisecondsMN();
4141

4242

43+
/**
44+
* @brief Convert start and end time to a framerate ( frames per second )
45+
* @ingroup demo
46+
* @retval Will return a framerate from two millisecond timestamps, if no time duration has been passed there is no division by zero.
47+
*/
48+
float convertStartEndTimeFromMicrosecondsToFPS(unsigned long startTime, unsigned long endTime);
49+
4350
/**
4451
* @brief Get the dimensions of an image by relying on the identify tool
4552
* @ingroup tools

MocapNETLib/visualization.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -985,19 +985,20 @@ int visualizePoints(
985985

986986
if(gestureDetected)
987987
{
988-
if (gestureFrame<20)
988+
if (gestureFrame<25)
989989
{
990990
snprintf(textInfo,512,"%s (%u)",gestureName,gestureDetected);
991991

992992
if (endEffectorHistory)
993993
{//If we track end effectors we will use their position to emit circles
994994
if (leftEndEffector.size()>0)
995995
{
996-
cv::putText(img,textInfo,leftEndEffector[leftEndEffector.size()-1],fontUsed,2.5,cv::Scalar(0,255,255),thickness,8);
997996
cv::circle(img,leftEndEffector[leftEndEffector.size()-1],5*gestureFrame,cv::Scalar(0,255,255),3,8,0);
998997
}
999998
if (rightEndEffector.size()>0)
1000999
{
1000+
//Right is always left :P so there is space for the string
1001+
cv::putText(img,textInfo,rightEndEffector[rightEndEffector.size()-1],fontUsed,2.2,cv::Scalar(0,255,255),thickness,8);
10011002
cv::circle(img,rightEndEffector[rightEndEffector.size()-1],5*gestureFrame,cv::Scalar(0,255,255),3,8,0);
10021003
}
10031004
} else
@@ -1006,14 +1007,17 @@ int visualizePoints(
10061007
cv::putText(img,textInfo,txtPosition,fontUsed,1.5,cv::Scalar(0,255,255),thickness,8);
10071008
cv::circle(img,txtPosition,2*gestureFrame,cv::Scalar(0,255,255),3,8,0);
10081009
}
1009-
1010-
1011-
1012-
1013-
1014-
1015-
}
1016-
}
1010+
}
1011+
} else
1012+
{
1013+
//We did not detect a gesture.. Let's check the framerate
1014+
if (fpsTotal<13)
1015+
{
1016+
txtPosition.y+=30;
1017+
cv::putText(img,"Framerate is too slow for reliable gesture recognition..",txtPosition,fontUsed,0.8,color,thickness,8);
1018+
}
1019+
1020+
}
10171021

10181022

10191023

WebcamAndDeepJoint/test.cpp

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -135,23 +135,7 @@ std::vector<cv::Point_<float> > predictAndReturnSingleSkeletonOf2DCOCOJoints(
135135
}
136136

137137

138-
139-
140-
/**
141-
* @brief Convert start and end time to a framerate ( frames per second )
142-
* @ingroup demo
143-
* @retval Will return a framerate from two millisecond timestamps, if no time duration has been passed there is no division by zero.
144-
*/
145-
float convertStartEndTimeFromMicrosecondsToFPS(unsigned long startTime, unsigned long endTime)
146-
{
147-
float timeInMilliseconds = (float) (endTime-startTime)/1000;
148-
if (timeInMilliseconds ==0.0)
149-
{
150-
timeInMilliseconds=0.00001; //Take care of division by null..
151-
}
152-
return (float) 1000/timeInMilliseconds;
153-
}
154-
138+
155139

156140

157141
int feetHeuristics(struct skeletonCOCO * sk)
@@ -237,8 +221,7 @@ std::vector<float> returnMocapNETInputFrom2DDetectorOutput(
237221
numberOfHeatmaps,
238222
numberOfOutputTensors
239223
);
240-
unsigned long endTime = GetTickCountMicroseconds();
241-
unsigned long openPoseComputationTimeInMilliseconds = (unsigned long) (endTime-startTime)/1000;
224+
unsigned long endTime = GetTickCountMicroseconds();
242225
*fps = convertStartEndTimeFromMicrosecondsToFPS(startTime,endTime);
243226

244227
if (!visualize)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4+
cd "$DIR"
5+
6+
../../GroundTruthDumper --from waveleft.bvh --onlyAnimateGivenJoints 2 lshoulder lelbow --bvh waveleft.bvh
7+
../../GroundTruthDumper --from waveright.bvh --onlyAnimateGivenJoints 2 rshoulder relbow --bvh waveright.bvh
8+
../../GroundTruthDumper --from comeleft.bvh --onlyAnimateGivenJoints 2 lshoulder lelbow --bvh comeleft.bvh
9+
../../GroundTruthDumper --from comeright.bvh --onlyAnimateGivenJoints 2 rshoulder relbow --bvh comeright.bvh
10+
../../GroundTruthDumper --from lefthandcircle.bvh --onlyAnimateGivenJoints 2 lshoulder lelbow --bvh lefthandcircle.bvh
11+
../../GroundTruthDumper --from righthandcircle.bvh --onlyAnimateGivenJoints 2 rshoulder relbow --bvh righthandcircle.bvh
12+
../../GroundTruthDumper --from help.bvh --onlyAnimateGivenJoints 4 lshoulder lelbow rshoulder relbow --bvh help.bvh
13+
../../GroundTruthDumper --from push.bvh --onlyAnimateGivenJoints 4 lshoulder lelbow rshoulder relbow --bvh push.bvh
14+
../../GroundTruthDumper --from doubleclap.bvh --onlyAnimateGivenJoints 4 lshoulder lelbow rshoulder relbow --bvh doubleclap.bvh
15+
../../GroundTruthDumper --from tpose.bvh --onlyAnimateGivenJoints 4 lshoulder lelbow rshoulder relbow --bvh tpose.bvh
16+
../../GroundTruthDumper --from leftkick.bvh --onlyAnimateGivenJoints 2 lhip lknee --bvh leftkick.bvh
17+
../../GroundTruthDumper --from rightkick.bvh --onlyAnimateGivenJoints 2 rhip rknee --bvh rightkick.bvh
18+
19+
exit 0

0 commit comments

Comments
 (0)