//-------------------------------------------------------------- void testApp::update() { if(PXCUPipeline_AcquireFrame(mSession, true)) { if(PXCUPipeline_QueryRGB(mSession, mRgbMap)) mRgbTex.loadData(mRgbMap,mcw,mch,GL_RGBA); if(PXCUPipeline_QueryLabelMap(mSession, mLabelMap,0)) mLabelTex.loadData(mLabelMap,mlw,mlh,GL_LUMINANCE); PXCUPipeline_ReleaseFrame(mSession); } }
//-------------------------------------------------------------- void testApp::update() { if(PXCUPipeline_AcquireFrame(mSession, false)) { mPositions.clear(); if(PXCUPipeline_QueryLabelMap(mSession, mLabelMap, 0)) mLabelTexture.loadData(mLabelMap, mLW, mLH, GL_LUMINANCE); for(int i=0;i<HANDS;i++) { for(int j=0;j<FINGERS;j++) { if(PXCUPipeline_QueryGeoNode(mSession, gHands[i]|gFingers[j], &mNode)){ myPositions tempPos; tempPos.imagePos.set(mNode.positionImage.x*2, mNode.positionImage.y*2); tempPos.worldPos.set(mNode.positionWorld.x,mNode.positionWorld.y,mNode.positionWorld.z); tempPos.node = gFingers[j]; mPositions.push_back(tempPos); } if(PXCUPipeline_QueryGeoNode(mSession, gHands[i], &mNode)){ myPositions tempPos; tempPos.imagePos.set(mNode.positionImage.x*2, mNode.positionImage.y*2); tempPos.worldPos.set(mNode.positionWorld.x,mNode.positionWorld.y,mNode.positionWorld.z); tempPos.node = gHands[i]; mPositions.push_back(tempPos); } } } //video if(PXCUPipeline_QueryRGB(mSession, mRGBMap)) mRGBTexture.loadData(mRGBMap, mCW, mCH, GL_RGBA); bool getDepth = PXCUPipeline_QueryDepthMap(mSession, mDepthBuffer); bool getIR = PXCUPipeline_QueryIRMap(mSession, mIRBuffer); if(getDepth||getIR) { for(int i=0;i<mLW*mLH;++i) { if(getDepth) mDepthMap[i] = (unsigned char)ofMap((float)mDepthBuffer[i],0,2000,0,255); if(getIR) mIRMap[i] = (unsigned char)ofMap((float)mIRBuffer[i],0,3000,0,255); } if(getDepth) mDepthTexture.loadData(mDepthMap, mLW, mLH, GL_LUMINANCE); if(getIR) mIRTexture.loadData(mIRMap, mLW, mLH, GL_LUMINANCE); } PXCUPipeline_ReleaseFrame(mSession); } //my------------------------------ L.set(0,0,0); R.set(0,0,0); bool bLeftHand,bRightHand, left, right; bLeftHand = false, bRightHand = false; left = false; right = false; float dis; for(int i = 0; i<mPositions.size();i++){ if(mPositions[i].node == PXCGesture::GeoNode::LABEL_BODY_HAND_LEFT){ L = mPositions[i].worldPos; bLeftHand = true; } else if(mPositions[i].node == PXCGesture::GeoNode::LABEL_BODY_HAND_RIGHT){ R = mPositions[i].worldPos; bRightHand = true; } } if (bLeftHand&&bRightHand) { dis = L.distance(R); cout<<dis<<endl; if (L.y - R.y>0.02 && dis<0.3) { // cout<<"left"<<endl; left = true; right = false; }else if(R.y-L.y>0.02 && dis<0.3){ cout<<"right"<<endl; left = false; right = true; } else{ left = false; right = false; } // if (L.y - R.y>0.02 && dis>0.3) // { // // hero_Pos.y += 30; // } // // if (R.y-L.y>0.02 && dis>0.3) // { // // hero_Pos.y -= 30; // } } if (left) { frc.x +=0.01; if (frc.x > 1) { frc.x = 1; } }else if(right) { frc.x -=0.01; if (frc.x < -1) { frc.x = -1; } }else{ if (frc.x > 0) { frc.x-=0.3; }else if(frc.x < 0){ frc.x+=0.3; }else{ frc.x = 0; } } hero_Pos.z -= 100*(1-frc.x); hero_Pos.x += 100*frc.x; float freqMult = 1; float amp = 30; float scale = 1; //hero.setPosition(ofVec3f(sin(ofGetElapsedTimef() * freqMult) * amp, cos(ofGetElapsedTimef() * freqMult) * amp, sin(ofGetElapsedTimef() * freqMult * 0.7) * amp)); hero_Pos += foc; hero.setPosition(hero_Pos); hero.setScale(scale); hero.setOrientation(frc*10); for (int i=0; i<nodes.size(); i++) { float freqMult = 1; float amp = 30; nodes[i].setOrientation(ofVec3f(sin(ofGetElapsedTimef() * freqMult * 0.2) * amp * 5, cos(ofGetElapsedTimef() * freqMult * 0.2) * amp * 5, sin(ofGetElapsedTimef() * freqMult * 0.2 * 0.7) * amp * 5)); } pre_L = L; pre_R = R; }