Hi, I’m a beginner in processing.
I count the number of people with a Kinect program.
It recognizes the current number of people and the previous number of people in real time. But there’s a problem.
From zero to one, the previous count will be zero, the new count will be one, and the previous count will be one, too, in the next frame.The frame is then counted with the previous count 1 and the new count 1.
Similarly, if there are one to two, the previous count is one and the new count is two. In the next frame, the previous count is two and the new count is two.
The problem here is,
From zero to one, the previous count 1 new count is one in the next frame.
And even in the frame after two to one, the previous count 1 and the new count are 1.
To sum up, I want to make a difference in the image of the result when I recognize 0 to 1 person counting from 2 to 1 person counting.
-MAIN-
import KinectPV2.*;
KinectPV2 kinect;
import KinectPV2.KJoint;
boolean foundUsers = false;
Circle circle;
Motion motion;
Motion2 motion2;
int sec;
int stateIndex = 0;
void setup() {
size(500, 500);
background(255);
circle = new Circle();
motion = new Motion();
motion2 = new Motion2();
kinect = new KinectPV2(this);
kinect.enableDepthImg(true);
kinect.enableBodyTrackImg(true);
kinect.init();
}
int c = 0;
void draw() {
//circle.display();
stateIndex = circle.getState();
circle.display(stateIndex);
//print(stateIndex);
}
-COUNTING CLASS-
//int newCount=0;
int oldCount=0;
class Circle {
float c = 1;
float t = 1;
float r = random(500);
float cc = 255; // circle color
float co = 15; // circle opacity
float x;
float y;
int sec;
Circle() {
x = random(width);
y = random(height);
}
int getState() {
int currentCount = kinect.getNumOfUsers();
int state = 0;
int check = 0;
if (currentCount == 1 && oldCount == 0) {
check = 1;
state = 1;
} else if (currentCount == 1 && oldCount == 1) {
state = 11;
} else if (currentCount == 1 && oldCount >= 2) {
check = 2;
state = 5;
} else if (currentCount == 1 && oldCount == 1) {
state = 22;
} else if (currentCount >= 2 && oldCount == 1) {
state = 2;
} else if (currentCount == 2 && oldCount == 2) {
//plz dont change please .. :(
state = 5;
} else if (currentCount >= 3 && oldCount >= 2) {
state = 5;
} else if (currentCount >= 3 && oldCount >= 3) {
//plz dont change please ..
state = 5;
} else if (foundUsers == false) {
state = 0;
}
oldCount = currentCount;
return state;
}
void display(int index) {
switch(index) {
case 0:
// 0 myeong
//pintln("0 : defalut");
background(0);
fill(255);
text("COME ON ~~~~ EVERYBODY ~~", width/2, height/2);
println("0");
break;
case 1:
// 0->1
background(255);
println("1 : 0->1");
fill(0);
text("1 : 0->1 ", width/2, height/2);
break;
case 2:
//1->2
background(255);
println("2 : 1->2");
fill(0);
text("2 : 1->2 ", width/2, height/2);
break;
case 5:
// 2&2
background(255);
println("2&2");
break;
case 11:
// 0->1..1&1 /
// background(255);
println("0->1 // 1&1");
break;
case 22:
// 2->1..1&1 / same as 2&2
// background(255);
println("2->1 // 1&1");
break;
}
}
}
int getNumOfUsers(int newCount) {
return newCount;
}