forked from bes-dev/HandDetector
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
56 lines (42 loc) · 913 Bytes
/
main.cpp
File metadata and controls
56 lines (42 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <iostream>
#include "HandDetector.h"
using namespace std;
using namespace cv;
int main()
{
cv::VideoCapture cap(CV_CAP_OPENNI);
cv::namedWindow("depth", 1);
cv::namedWindow("bgr", 1);
HandDetector::Params p;
p.area=1000;
p.cosThreshold=0.5;
p.equalThreshold=1e-7;
p.r=40;
p.step=16;
HandDetector hDetector;
hDetector.setParams(p);
std::vector<Hand> hands;
while(1)
{
cv::Mat depthMap;
cv::Mat bgrImage;
cap.grab();
cap.retrieve( depthMap, CV_16UC1 );
cap.retrieve( bgrImage, CV_32FC1 );
cv::Mat tmp;
cv::cvtColor(depthMap, tmp, CV_GRAY2BGR);
cv::threshold(depthMap, depthMap, 60, 255, cv::THRESH_BINARY);
hDetector.detect(depthMap, hands);
if(!hands.empty())
{
drawHands(tmp, hands);
drawHands(bgrImage, hands);
}
cv::imshow("depth", tmp);
cv::imshow("bgr", bgrImage);
if( cv::waitKey( 20 ) >= 0 )
break;
}
cv::waitKey();
return 0;
}