void drawSelectionChanged(SelectionState state, IntRect selection) { g_DrawUserInput.State = state; g_DrawUserInput.Rect = selection; if (state == SELECTION_DONE) { // Crop depth if (getDepthGenerator() != NULL && g_DrawConfig.Streams.Depth.Coloring != DEPTH_OFF) { drawCropStream(getDepthGenerator(), g_DrawConfig.DepthLocation, selection, 2); } // Crop image if (getImageGenerator() != NULL && g_DrawConfig.Streams.Image.Coloring != IMAGE_OFF) { drawCropStream(getImageGenerator(), g_DrawConfig.ImageLocation, selection, 4); } // Crop IR if (getIRGenerator() != NULL && g_DrawConfig.Streams.Image.Coloring != IMAGE_OFF) { drawCropStream(getIRGenerator(), g_DrawConfig.ImageLocation, selection, 4); } } }
void changePrimaryStream(int nIndex) { if (nIndex == 0) { g_pPrimary = NULL; return; } XnProductionNodeType Type; xnProductionNodeTypeFromString(g_PrimaryStream.pValues[nIndex], &Type); switch (Type) { case XN_NODE_TYPE_DEPTH: g_pPrimary = getDepthGenerator(); break; case XN_NODE_TYPE_IMAGE: g_pPrimary = getImageGenerator(); break; case XN_NODE_TYPE_IR: g_pPrimary = getIRGenerator(); break; case XN_NODE_TYPE_AUDIO: g_pPrimary = getAudioGenerator(); break; } }
void resetAllCropping(int) { if (getDepthGenerator() != NULL) resetDepthCropping(0); if (getImageGenerator() != NULL) resetImageCropping(0); if (getIRGenerator() != NULL) resetIRCropping(0); }
bool captureOpenWriteDevice() { XnStatus nRetVal = XN_STATUS_OK; NodeInfoList recordersList; nRetVal = g_Context.EnumerateProductionTrees(XN_NODE_TYPE_RECORDER, NULL, recordersList); START_CAPTURE_CHECK_RC(nRetVal, "Enumerate recorders"); // take first NodeInfo chosen = *recordersList.Begin(); nRetVal = g_Context.CreateProductionTree(chosen); START_CAPTURE_CHECK_RC(nRetVal, "Create recorder"); g_Capture.pRecorder = new Recorder; nRetVal = chosen.GetInstance(*g_Capture.pRecorder); START_CAPTURE_CHECK_RC(nRetVal, "Get recorder instance"); nRetVal = g_Capture.pRecorder->SetDestination(XN_RECORD_MEDIUM_FILE, g_Capture.csFileName); START_CAPTURE_CHECK_RC(nRetVal, "Set output file"); if (getDevice() != NULL) { nRetVal = g_Capture.pRecorder->AddNodeToRecording(*getDevice(), XN_CODEC_UNCOMPRESSED); START_CAPTURE_CHECK_RC(nRetVal, "add device node"); } if (isDepthOn() && (g_Capture.DepthFormat != CODEC_DONT_CAPTURE)) { nRetVal = g_Capture.pRecorder->AddNodeToRecording(*getDepthGenerator(), g_Capture.DepthFormat); START_CAPTURE_CHECK_RC(nRetVal, "add depth node"); } if (isImageOn() && (g_Capture.ImageFormat != CODEC_DONT_CAPTURE)) { nRetVal = g_Capture.pRecorder->AddNodeToRecording(*getImageGenerator(), g_Capture.ImageFormat); START_CAPTURE_CHECK_RC(nRetVal, "add image node"); } if (isIROn() && (g_Capture.IRFormat != CODEC_DONT_CAPTURE)) { nRetVal = g_Capture.pRecorder->AddNodeToRecording(*getIRGenerator(), g_Capture.IRFormat); START_CAPTURE_CHECK_RC(nRetVal, "add IR stream"); } if (isAudioOn() && (g_Capture.AudioFormat != CODEC_DONT_CAPTURE)) { nRetVal = g_Capture.pRecorder->AddNodeToRecording(*getAudioGenerator(), g_Capture.AudioFormat); START_CAPTURE_CHECK_RC(nRetVal, "add Audio stream"); } return true; }
void drawPointerMode(IntPair* pPointer) { char buf[512] = ""; int nCharWidth = glutBitmapWidth(GLUT_BITMAP_HELVETICA_18, '0'); int nPointerValue = 0; XnDouble dTimestampDivider = 1E6; const DepthMetaData* pDepthMD = getDepthMetaData(); if (pDepthMD != NULL) { // Print the scale black background glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBegin(GL_QUADS); glColor4f(0, 0, 0, 0.7); glVertex2i(0, WIN_SIZE_Y); // lower left glVertex2i(WIN_SIZE_X, WIN_SIZE_Y); glVertex2i(WIN_SIZE_X, WIN_SIZE_Y - 135); glVertex2i(0, WIN_SIZE_Y - 135); glEnd(); glDisable(GL_BLEND); // set a large point size (for the scale) glPointSize(15); // Print the scale data glBegin(GL_POINTS); for (int i = 0; i < pDepthMD->ZRes(); i+=1) { float fNewColor = g_pDepthHist[i]; if ((fNewColor > 0.004) && (fNewColor < 0.996)) { glColor3f(fNewColor, fNewColor, 0); glVertex3f(((i/10)*2), WIN_SIZE_Y - 23, 1); } } glEnd(); // Print the pointer scale data if (pPointer != NULL) { // make sure pointer in on a depth pixel (take in mind cropping might be in place) IntPair pointerInDepth = *pPointer; pointerInDepth.X -= pDepthMD->XOffset(); pointerInDepth.Y -= pDepthMD->YOffset(); if (pointerInDepth.X < (int)pDepthMD->XRes() && pointerInDepth.Y < (int)pDepthMD->YRes()) { nPointerValue = (*pDepthMD)(pointerInDepth.X, pointerInDepth.Y); glBegin(GL_POINTS); glColor3f(1,0,0); glVertex3f(10 + ((nPointerValue/10)*2), WIN_SIZE_Y - 70, 1); glEnd(); } } // Print the scale texts for (int i = 0; i < pDepthMD->ZRes()/10; i+=25) { int xPos = i*2 + 10; // draw a small line in this position glBegin(GL_LINES); glColor3f(0, 1, 0); glVertex2i(xPos, WIN_SIZE_Y - 54); glVertex2i(xPos, WIN_SIZE_Y - 62); glEnd(); // place a label under, and in the middle of, that line. int chars = sprintf(buf, "%d", i); glColor3f(1,0,0); glRasterPos2i(xPos - chars*nCharWidth/2, WIN_SIZE_Y - 40); glPrintString(GLUT_BITMAP_HELVETICA_18,buf); } sprintf(buf, "%s - Frame %4u, Timestamp %.3f", getDepthGenerator()->GetInfo().GetInstanceName(), pDepthMD->FrameID(), (double)pDepthMD->Timestamp()/dTimestampDivider); } const ImageMetaData* pImageMD = getImageMetaData(); if (pImageMD != NULL) { if (buf[0] != '\0') sprintf(buf + strlen(buf), " | "); sprintf(buf + strlen(buf), "%s - Frame %4u, Timestamp %.3f", getImageGenerator()->GetInfo().GetInstanceName(), pImageMD->FrameID(), (double)pImageMD->Timestamp()/dTimestampDivider); } const IRMetaData* pIRMD = getIRMetaData(); if (pIRMD != NULL) { if (buf[0] != '\0') sprintf(buf + strlen(buf), " | "); sprintf(buf + strlen(buf), "%s - Frame %4u, Timestamp %.3f", getIRGenerator()->GetInfo().GetInstanceName(), pIRMD->FrameID(), (double)pIRMD->Timestamp()/dTimestampDivider); } const AudioMetaData* pAudioMD = getAudioMetaData(); if (pAudioMD != NULL) { if (buf[0] != '\0') sprintf(buf + strlen(buf), " | "); sprintf(buf + strlen(buf), "%s - Timestamp %.3f", getAudioGenerator()->GetInfo().GetInstanceName(), (double)pAudioMD->Timestamp()/dTimestampDivider); } int nYLocation = WIN_SIZE_Y - 88; glColor3f(1,0,0); glRasterPos2i(10,nYLocation); glPrintString(GLUT_BITMAP_HELVETICA_18, buf); nYLocation -= 26; if (pPointer != NULL && isStatisticsActive()) { XnPixelStatistics* pStatistics = &g_PixelStatistics[pPointer->Y * pDepthMD->XRes() + pPointer->X]; sprintf(buf, "Collected: %3u, Min: %4u Max: %4u Avg: %6.2f StdDev: %6.2f", pStatistics->nCount, pStatistics->nMin, pStatistics->nMax, pStatistics->dAverage, pStatistics->dStdDev); glRasterPos2i(10,nYLocation); glPrintString(GLUT_BITMAP_HELVETICA_18, buf); nYLocation -= 26; } if (pPointer != NULL) { // Print the pointer text XnUInt64 nCutOffMin = 0; XnUInt64 nCutOffMax = (pDepthMD != NULL) ? g_nMaxDepth : 0; XnChar sPointerValue[100]; if (nPointerValue != g_nMaxDepth) { sprintf(sPointerValue, "%.1f", (float)nPointerValue/10); } else { sprintf(sPointerValue, "-"); } sprintf(buf, "Pointer Value: %s (X:%d Y:%d) Cutoff: %llu-%llu.", sPointerValue, pPointer->X, pPointer->Y, nCutOffMin, nCutOffMax); glRasterPos2i(10,nYLocation); glPrintString(GLUT_BITMAP_HELVETICA_18, buf); nYLocation -= 26; } }
void setIRFPS(int fps) { setFPS(getIRGenerator(), fps); }
void setIRResolution(int res) { setResolution(getIRGenerator(), res); }
void captureSetIRFormat(int format) { captureSetFormat(&g_Capture.IRFormat, format, *getIRGenerator()); }
void resetIRCropping(int) { resetCropping(getIRGenerator()); }