We are about to switch to a new forum software. Until then we have removed the registration on this forum.
**Ok, this is my code. And everything runs ok until this error appear : (Image) get next frame failed -2097086458
Any sugestion?**
import kinect4WinSDK.Kinect;
import kinect4WinSDK.SkeletonData;
Kinect kinect;
ArrayList <SkeletonData> bodies;
PImage teste;
float barWidth = 20;
float lastBar = -1;
float tamanho_kinect_W = 640*2;
float tamanho_kinect_H = 480*2;
void setup()
{
size( displayWidth, displayHeight);
frameRate(30);
kinect = new Kinect(this);
smooth();
bodies = new ArrayList<SkeletonData>();
teste = loadImage("KC.jpg");
}
void draw()
{
background(0);
//image(kinect.GetImage(), 0,0);
//image(kinect.GetDepth(), 320, 240, 320, 240);
pushMatrix();
rotate(radians(270));
translate(-displayHeight, 0);
image(teste,0, 0, displayHeight, displayWidth );
popMatrix();
pushMatrix();
rotate(radians(270));
translate(-displayHeight, 300);
for (int i=0; i<bodies.size (); i++)
{
quadrado(bodies.get(i));
drawPosition(bodies.get(i));
}
image(kinect.GetMask(), 0, 0,tamanho_kinect_W,tamanho_kinect_H );
//image(kinect.GetImage(),0,0,displayHeight, displayWidth);
popMatrix();
}
void drawPosition(SkeletonData _s)
{
noStroke();
fill(0, 100, 255);
String s1 = str(_s.dwTrackingID);
text(s1, _s.position.x*width/2, _s.position.y*height/2);
}
void quadrado(SkeletonData _s)
{
mao_esquerda(_s,
Kinect.NUI_SKELETON_POSITION_WRIST_LEFT,
Kinect.NUI_SKELETON_POSITION_HAND_LEFT);
mao_direita(_s,
Kinect.NUI_SKELETON_POSITION_WRIST_RIGHT,
Kinect.NUI_SKELETON_POSITION_HAND_RIGHT);
}
void mao_esquerda(SkeletonData _s, int _j1, int _j2)
{
fill(0);
stroke(255, 255, 0);
if (_s.skeletonPositionTrackingState[_j1] != Kinect.NUI_SKELETON_POSITION_NOT_TRACKED &&
_s.skeletonPositionTrackingState[_j2] != Kinect.NUI_SKELETON_POSITION_NOT_TRACKED) {
float xMapped = map((_s.skeletonPositions[_j2].x*640), 0, 640, 0, displayWidth - 100);
float yMapped = map((_s.skeletonPositions[_j2].y*480), 0, 480, 0, displayHeight - 100);
rect(xMapped, yMapped,100, 150);
}
}
void mao_direita(SkeletonData _s, int _j1, int _j2)
{
fill(0);
stroke(255, 255, 0);
if (_s.skeletonPositionTrackingState[_j1] != Kinect.NUI_SKELETON_POSITION_NOT_TRACKED &&
_s.skeletonPositionTrackingState[_j2] != Kinect.NUI_SKELETON_POSITION_NOT_TRACKED) {
float xMapped = map((_s.skeletonPositions[_j2].x*640), 0, 640, 0, displayWidth);
float yMapped = map((_s.skeletonPositions[_j2].y*480), 0, 480, 0, displayHeight);
rect(xMapped, yMapped,100, 150);
}
}
void appearEvent(SkeletonData _s)
{
if (_s.trackingState == Kinect.NUI_SKELETON_NOT_TRACKED)
{
return;
}
synchronized(bodies) {
bodies.add(_s);
}
}
void disappearEvent(SkeletonData _s)
{
synchronized(bodies) {
for (int i=bodies.size ()-1; i>=0; i--)
{
if (_s.dwTrackingID == bodies.get(i).dwTrackingID)
{
bodies.remove(i);
}
}
}
}
void moveEvent(SkeletonData _b, SkeletonData _a)
{
if (_a.trackingState == Kinect.NUI_SKELETON_NOT_TRACKED)
{
return;
}
synchronized(bodies) {
for (int i=bodies.size ()-1; i>=0; i--)
{
if (_b.dwTrackingID == bodies.get(i).dwTrackingID)
{
bodies.get(i).copy(_a);
break;
}
}
}
}
****
Answers
Solved. I just update the java to the right version.