// Draw Data void Kinect::draw() { // Draw Color drawColor(); // Draw Depth drawDepth(); }
int Read_Kinect::control_running() { int rtn = 0; WaitForSingleObject(h1, INFINITE); //drawColor(h2); WaitForSingleObject(h3, INFINITE); drawDepth(h4); WaitForSingleObject(h5, INFINITE); //_depth.copyTo(_skeleton); //drawSkeleton(_skeleton); drawSkeleton(); if (_remove_num > 0) { remove_cache(); } fall_detection.falldetectiondistance(_avg_dis); _if_fall_down = fall_detection.get_fall_output_dis(); //visualization_update(); //imshow("Activity Recognition", _dispImg); return rtn; }
void drawFrame() { // calculate locations g_DrawConfig.DepthLocation.uBottom = 0; g_DrawConfig.DepthLocation.uTop = WIN_SIZE_Y - 1; g_DrawConfig.DepthLocation.uLeft = 0; g_DrawConfig.DepthLocation.uRight = WIN_SIZE_X - 1; g_DrawConfig.ColorLocation.uBottom = 0; g_DrawConfig.ColorLocation.uTop = WIN_SIZE_Y - 1; g_DrawConfig.ColorLocation.uLeft = 0; g_DrawConfig.ColorLocation.uRight = WIN_SIZE_X - 1; if (g_DrawConfig.Streams.ScreenArrangement == SIDE_BY_SIDE) { g_DrawConfig.DepthLocation.uTop = WIN_SIZE_Y / 2 - 1; g_DrawConfig.DepthLocation.uRight = WIN_SIZE_X / 2 - 1; g_DrawConfig.ColorLocation.uTop = WIN_SIZE_Y / 2 - 1; g_DrawConfig.ColorLocation.uLeft = WIN_SIZE_X / 2; } // Texture map init openni::VideoFrameRef* pDepthMD = &getDepthFrame(); if (isDepthOn() && pDepthMD->isValid()) { int maxDepth = 0; maxDepth = getDepthStream().getMaxPixelValue(); g_fMaxDepth = maxDepth; TextureMapInit(&g_texDepth, pDepthMD->getVideoMode().getResolutionX(), pDepthMD->getVideoMode().getResolutionY(), 4, pDepthMD->getWidth(), pDepthMD->getHeight()); fixLocation(&g_DrawConfig.DepthLocation, pDepthMD->getVideoMode().getResolutionX(), pDepthMD->getVideoMode().getResolutionY()); } openni::VideoFrameRef* pImageMD = NULL; if (isColorOn()) { pImageMD = &getColorFrame(); } else if (isIROn()) { pImageMD = &getIRFrame(); } if (pImageMD != NULL && pImageMD->isValid()) { TextureMapInit(&g_texColor, pImageMD->getVideoMode().getResolutionX(), pImageMD->getVideoMode().getResolutionY(), 4, pImageMD->getWidth(), pImageMD->getHeight()); fixLocation(&g_DrawConfig.ColorLocation, pImageMD->getVideoMode().getResolutionX(), pImageMD->getVideoMode().getResolutionY()); } // check if pointer is over a map bool bOverDepth = (pDepthMD != NULL && pDepthMD->isValid()) && isPointInRect(g_DrawUserInput.Cursor, &g_DrawConfig.DepthLocation); bool bOverImage = (pImageMD != NULL && pImageMD->isValid()) && isPointInRect(g_DrawUserInput.Cursor, &g_DrawConfig.ColorLocation); bool bDrawDepthPointer = false; bool bDrawImagePointer = false; int imagePointerRed = 255; int imagePointerGreen = 0; int imagePointerBlue = 0; IntPair pointerInDepth = {0,0}; IntPair pointerInColor = {0,0}; if (bOverImage) { pointerInColor.X = (double)(g_DrawUserInput.Cursor.X - g_DrawConfig.ColorLocation.uLeft) / (g_DrawConfig.ColorLocation.uRight - g_DrawConfig.ColorLocation.uLeft + 1) * pImageMD->getVideoMode().getResolutionX(); pointerInColor.Y = (double)(g_DrawUserInput.Cursor.Y - g_DrawConfig.ColorLocation.uBottom) / (g_DrawConfig.ColorLocation.uTop - g_DrawConfig.ColorLocation.uBottom + 1) * pImageMD->getVideoMode().getResolutionY(); bDrawImagePointer = true; } if (bOverDepth) { pointerInDepth.X = (double)(g_DrawUserInput.Cursor.X - g_DrawConfig.DepthLocation.uLeft) / (g_DrawConfig.DepthLocation.uRight - g_DrawConfig.DepthLocation.uLeft + 1) * pDepthMD->getVideoMode().getResolutionX(); pointerInDepth.Y = (double)(g_DrawUserInput.Cursor.Y - g_DrawConfig.DepthLocation.uBottom) / (g_DrawConfig.DepthLocation.uTop - g_DrawConfig.DepthLocation.uBottom + 1) * pDepthMD->getVideoMode().getResolutionY(); bDrawDepthPointer = true; if (!bOverImage && g_DrawConfig.bShowPointer && pointerInDepth.X >= pDepthMD->getCropOriginX() && pointerInDepth.X < (pDepthMD->getCropOriginX() + pDepthMD->getWidth()) && pointerInDepth.Y >= pDepthMD->getCropOriginY() && pointerInDepth.Y < (pDepthMD->getCropOriginY() + pDepthMD->getHeight())) { // try to translate depth pixel to image openni::DepthPixel* pDepthPixels = (openni::DepthPixel*)pDepthMD->getData(); openni::DepthPixel pointerDepth = pDepthPixels[(pointerInDepth.Y - pDepthMD->getCropOriginY()) * pDepthMD->getWidth() + (pointerInDepth.X - pDepthMD->getCropOriginX())]; if (convertDepthPointToColor(pointerInDepth.X, pointerInDepth.Y, pointerDepth, &pointerInColor.X, &pointerInColor.Y)) { bDrawImagePointer = true; imagePointerRed = 0; imagePointerGreen = 0; imagePointerBlue = 255; } } } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); // Setup the opengl env for fixed location view glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(0,WIN_SIZE_X,WIN_SIZE_Y,0,-1.0,1.0); glDisable(GL_DEPTH_TEST); if (g_DrawConfig.Streams.Depth.Coloring == CYCLIC_RAINBOW_HISTOGRAM || g_DrawConfig.Streams.Depth.Coloring == LINEAR_HISTOGRAM || g_DrawConfig.bShowPointer) calculateHistogram(); drawColor(&g_DrawConfig.ColorLocation, bDrawImagePointer ? &pointerInColor : NULL, imagePointerRed, imagePointerGreen, imagePointerBlue); drawDepth(&g_DrawConfig.DepthLocation, bDrawDepthPointer ? &pointerInDepth : NULL); printRecordingInfo(); if (g_DrawConfig.bShowPointer) drawPointerMode(bOverDepth ? &pointerInDepth : NULL); drawUserInput(!bOverDepth && !bOverImage); drawUserMessage(); drawPlaybackSpeed(); if (g_DrawConfig.strErrorState[0] != '\0') drawErrorState(); if (g_DrawConfig.bHelp) drawHelpScreen(); glutSwapBuffers(); }
void drawFrame() { // calculate locations g_DrawConfig.DepthLocation.uBottom = 0; g_DrawConfig.DepthLocation.uTop = WIN_SIZE_Y - 1; g_DrawConfig.DepthLocation.uLeft = 0; g_DrawConfig.DepthLocation.uRight = WIN_SIZE_X - 1; g_DrawConfig.ImageLocation.uBottom = 0; g_DrawConfig.ImageLocation.uTop = WIN_SIZE_Y - 1; g_DrawConfig.ImageLocation.uLeft = 0; g_DrawConfig.ImageLocation.uRight = WIN_SIZE_X - 1; if (g_DrawConfig.Streams.ScreenArrangement == SIDE_BY_SIDE) { g_DrawConfig.DepthLocation.uTop = WIN_SIZE_Y / 2 - 1; g_DrawConfig.DepthLocation.uRight = WIN_SIZE_X / 2 - 1; g_DrawConfig.ImageLocation.uTop = WIN_SIZE_Y / 2 - 1; g_DrawConfig.ImageLocation.uLeft = WIN_SIZE_X / 2; } // Texture map init const DepthMetaData* pDepthMD = getDepthMetaData(); if (isDepthOn()) { g_nMaxDepth = getDepthGenerator()->GetDeviceMaxDepth(); TextureMapInit(&g_texDepth, pDepthMD->FullXRes(), pDepthMD->FullYRes(), 4, pDepthMD->XRes(), pDepthMD->YRes()); fixLocation(&g_DrawConfig.DepthLocation, pDepthMD->FullXRes(), pDepthMD->FullYRes()); } const MapMetaData* pImageMD = NULL; if (isImageOn()) { pImageMD = getImageMetaData(); } else if (isIROn()) { pImageMD = getIRMetaData(); } if (pImageMD != NULL) { TextureMapInit(&g_texImage, pImageMD->FullXRes(), pImageMD->FullYRes(), 4, pImageMD->XRes(), pImageMD->YRes()); fixLocation(&g_DrawConfig.ImageLocation, pImageMD->FullXRes(), pImageMD->FullYRes()); } // check if pointer is over a map bool bOverDepth = (pDepthMD != NULL) && isPointInRect(g_DrawUserInput.Cursor, &g_DrawConfig.DepthLocation); bool bOverImage = (pImageMD != NULL) && isPointInRect(g_DrawUserInput.Cursor, &g_DrawConfig.ImageLocation); bool bDrawDepthPointer = false; bool bDrawImagePointer = false; int imagePointerRed = 255; int imagePointerGreen = 0; int imagePointerBlue = 0; IntPair pointerInDepth; IntPair pointerInImage; if (bOverImage) { pointerInImage.X = (double)(g_DrawUserInput.Cursor.X - g_DrawConfig.ImageLocation.uLeft) / (g_DrawConfig.ImageLocation.uRight - g_DrawConfig.ImageLocation.uLeft + 1) * pImageMD->FullXRes(); pointerInImage.Y = (double)(g_DrawUserInput.Cursor.Y - g_DrawConfig.ImageLocation.uBottom) / (g_DrawConfig.ImageLocation.uTop - g_DrawConfig.ImageLocation.uBottom + 1) * pImageMD->FullYRes(); bDrawImagePointer = true; } if (bOverDepth) { pointerInDepth.X = (double)(g_DrawUserInput.Cursor.X - g_DrawConfig.DepthLocation.uLeft) / (g_DrawConfig.DepthLocation.uRight - g_DrawConfig.DepthLocation.uLeft + 1) * pDepthMD->FullXRes(); pointerInDepth.Y = (double)(g_DrawUserInput.Cursor.Y - g_DrawConfig.DepthLocation.uBottom) / (g_DrawConfig.DepthLocation.uTop - g_DrawConfig.DepthLocation.uBottom + 1) * pDepthMD->FullYRes(); // make sure we're in cropped area if (pointerInDepth.X >= pDepthMD->XOffset() && pointerInDepth.X < (pDepthMD->XOffset() + pDepthMD->XRes()) && pointerInDepth.Y >= pDepthMD->YOffset() && pointerInDepth.Y < (pDepthMD->YOffset() + pDepthMD->YRes())) { bDrawDepthPointer = true; if (!bOverImage && g_DrawConfig.bShowPointer) { // try to translate depth pixel to image if (getImageCoordinatesForDepthPixel(pointerInDepth.X, pointerInDepth.Y, pointerInImage.X, pointerInImage.Y)) { bDrawImagePointer = true; imagePointerRed = 0; imagePointerGreen = 0; imagePointerBlue = 255; } } } } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); // Setup the opengl env for fixed location view glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(0,WIN_SIZE_X,WIN_SIZE_Y,0,-1.0,1.0); glDisable(GL_DEPTH_TEST); if (g_DrawConfig.Streams.Depth.Coloring == CYCLIC_RAINBOW_HISTOGRAM || g_DrawConfig.Streams.Depth.Coloring == LINEAR_HISTOGRAM || g_DrawConfig.bShowPointer) calculateHistogram(); drawColorImage(&g_DrawConfig.ImageLocation, bDrawImagePointer ? &pointerInImage : NULL, imagePointerRed, imagePointerGreen, imagePointerBlue); drawDepth(&g_DrawConfig.DepthLocation, bDrawDepthPointer ? &pointerInDepth : NULL); printStatisticsInfo(); printRecordingInfo(); if (g_DrawConfig.bShowPointer) drawPointerMode(bDrawDepthPointer ? &pointerInDepth : NULL); drawUserInput(!bOverDepth && !bOverImage); drawUserMessage(); drawPlaybackSpeed(); if (g_DrawConfig.strErrorState != NULL) drawErrorState(); if (g_DrawConfig.bHelp) drawHelpScreen(); glutSwapBuffers(); }
//--------------------------------------------------------------------------- void ofxKinect::drawDepth(float _x, float _y){ drawDepth(_x, _y, (float)width, (float)height); }
//---------------------------------------------------------- void ofxKinect::drawDepth(const ofRectangle & rect) { drawDepth(rect.x, rect.y, rect.width, rect.height); }
//---------------------------------------------------------- void ofxKinect::drawDepth(const ofPoint & point) { drawDepth(point.x, point.y); }
void SceneManager::drawDebug(Depth & depth) { if (player.isLoaded() && isPlayingSequence) { if (isDancerSilhouetteDebugVisible) { // Draw the video frame ofSetColor(255, 255, 255); ofPushMatrix(); ofTranslate(0, ofGetHeight() - srcH * vidScale); ofScale(vidScale, vidScale); player.draw(0, 0); ofPopMatrix(); // draw blurred ofPushMatrix(); ofTranslate(srcW * vidScale, ofGetHeight() - srcH * vidScale); ofScale(vidScale, vidScale); dancerFbo[currentVidFbo].draw(0, 0); ofPopMatrix(); // draw CV Grey image ofPushMatrix(); ofTranslate(srcW * 2 * vidScale, ofGetHeight() - srcH * vidScale); ofScale(vidScale, vidScale); dancerSilhouette.drawCvGreyImg(); ofPopMatrix(); // draw contour ofPushStyle(); ofSetColor(255, 0, 0); ofPushMatrix(); ofTranslate(srcW * 3 * vidScale, ofGetHeight() - srcH * vidScale); ofScale(vidScale, vidScale); dancerSilhouette.drawContour(); ofPopMatrix(); ofPopStyle(); } } if (isUserSilhouetteDebugVisible) { // draw blurred ofPushMatrix(); ofTranslate(srcW * vidScale, ofGetHeight() - srcH * vidScale * 2); ofScale(vidScale, vidScale); userFbo[currentVidFbo].draw(0, 0); ofPopMatrix(); // draw CV Grey image ofPushMatrix(); ofTranslate(srcW * 2 * vidScale, ofGetHeight() - srcH * vidScale * 2); ofScale(vidScale, vidScale); userSilhouette.drawCvGreyImg(); ofPopMatrix(); // draw contour ofPushStyle(); ofSetColor(255, 0, 0); ofPushMatrix(); ofTranslate(srcW * 3 * vidScale, ofGetHeight() - srcH * vidScale * 2); ofScale(vidScale, vidScale); userSilhouette.drawContour(); ofPopMatrix(); ofPopStyle(); } if (isDrawDepth) drawDepth(depth, 0, 480 * 0.5); if (isDrawClippedDepth) { ofPushMatrix(); ofTranslate(0, ofGetHeight() - srcH * vidScale * 2); ofScale(vidScale, vidScale); drawClippedDepth(0, 0); ofPopMatrix(); } if (isDrawLargeClippedDepth) { ofPushMatrix(); ofTranslate(640 * 0.5, 0); ofScale(largeClippingScale, largeClippingScale); depthFbo.draw(0, 0); ofPopMatrix(); } if (screenRecorder.getIsRecording()) { fastFboReader.readToPixels(depthFbo, pix); screenRecorder.addFrame(pix); } ofPushStyle(); ofSetColor(0); ofPushMatrix(); ofTranslate(ofGetWidth() - 100, 20); screenRecorder.draw(); ofPopMatrix(); ofPopStyle(); }
//---------------------------------------------------------- void ofxRSSDK::drawDepth(const ofPoint & point) { drawDepth(point.x, point.y); }
//--------------------------------------------------------------------------- void ofxRSSDK::drawDepth(float _x, float _y) { drawDepth(_x, _y, (float)width, (float)height); }