-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathflatulence.cpp
57 lines (54 loc) · 994 Bytes
/
flatulence.cpp
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
57
//flatulence check
#include "flatulence.hpp"
#define DEBUG 1
using namespace std;
using namespace cv;
int flatulence::flatulenceCheck(cv::Mat depthImage,float mean,float flaTh,int whiteTh,int whiteNum)
{
int id=0;
int soWhite=0;
int nr=depthImage.rows;
int nc=depthImage.cols;
float sum=0;
float num=0;
for (int j=0; j<nr; j++)
{
uchar* data= depthImage.ptr<uchar>(j);
for (int i=0; i<nc; i++)
{
if(data[i]>whiteTh)
{
soWhite++;
}
if(data[i]>1)
{
sum+=(mean-(float)data[i])*(mean-(float)data[i]);
num++;
}
}
}
cout<<"Sum: "<<sum<<",num: "<<num<<"White points: "<<soWhite<<endl;
stdDevValue=100*sqrt(sum)/num;
#if DEBUG
cout<<"StdDev: "<<stdDevValue<<endl;
#endif
if(stdDevValue>flaTh)
{
id=1;
cout<<"Warning: Flatulence!"<<endl;
}
else
{
if(soWhite>whiteNum)
{
id=2;
cout<<"Warning: White points!"<<endl;
}
else
{
id=0;
cout<<"Flatulence Check Pass!"<<endl;
}
}
return id;
}