internal void SetupNode() { if(FContext != null) { if( FContext[0].Configured && (FContext[0].sm != null) && FContext[0].sm.IsConnected() ) { if(FContext[0].Streams.ContainsKey(PXCMCapture.StreamType.STREAM_TYPE_IR)) { Image = FContext[0].Streams[PXCMCapture.StreamType.STREAM_TYPE_IR]; FIR.SliceCount = 1; FIR[0] = Image; FFormatOut.SliceCount = 1; FFormatOut[0] = Image.Format.ToString(); } else FLogger.Log(LogType.Debug,"IR: No STREAM_TYPE_IR found"); } else { Image = null; FIR.SliceCount = 0; FFormatOut.SliceCount = 0; } } else { Image = null; FIR.SliceCount = 0; FFormatOut.SliceCount = 0; } }
public void Evaluate(int SpreadMax) { if( (FContext.SliceCount > 0) && (FContext[0].Configured) ) { processConfig(); // Iterate over blobs from right to left try { Int32 iBlobsNum = FContext[0].blobData.QueryNumberOfBlobs(); FCenter.SliceCount = iBlobsNum; FOuterPoints.SliceCount = iBlobsNum; FInnerPoints.SliceCount = iBlobsNum; FClosest.SliceCount = iBlobsNum; FBlobsCount[0] = iBlobsNum; var ImageSize = FContext[0].DepthImageSize; FImage.SliceCount = iBlobsNum; PXCMBlobData.IBlob[] blobList = new PXCMBlobData.IBlob[iBlobsNum]; for (int i = 0; i < iBlobsNum; i++) { FContext[0].blobData.QueryBlob(i, PXCMBlobData.SegmentationImageType.SEGMENTATION_IMAGE_DEPTH, PXCMBlobData.AccessOrderType.ACCESS_ORDER_NEAR_TO_FAR, out blobList[i]); // handle extracted blob data Int32 nContours = blobList[i].QueryNumberOfContours(); if (nContours > 0) { //contourPts for (int k = 0; k < nContours; ++k) { PXCMBlobData.IContour ContourData; blobList[i].QueryContour(k, out ContourData); int contourSize = ContourData.QuerySize(); PXCMPointI32[] ContourPoints = new PXCMPointI32[contourSize]; ContourData.QueryPoints(out ContourPoints); if(ContourPoints.Length > 0) { if( (ContourData.IsOuter() == true) ) { FOuterPoints[i].SliceCount = ContourPoints.Length; for(int index = 0; index < ContourPoints.Length; index++) FOuterPoints[i][index] = new Vector2D(ContourPoints[index].x / (float)ImageSize.x * 2.0f - 1.0f, 1.0f - ContourPoints[index].y / (float)ImageSize.y * 2.0f); //Parallel.For (0, ContourPoints.Length, index => { FOuterPoints[i][index] = new Vector2D(ContourPoints[index].x / (float)ImageSize.x * 2.0f - 1.0f, 1.0f - ContourPoints[index].y / (float)ImageSize.y * 2.0f); ); } /* else { FInnerPoints[i].SliceCount = ContourPoints.Length; for (int p = 0; p < ContourPoints.Length; p++) { Parallel.For (0, ContourPoints.Length, index => { FInnerPoints[i][index] = new Vector2D(ContourPoints[index].x / (float)ImageSize.x * 2.0f - 1.0f, 1.0f - ContourPoints[index].y / (float)ImageSize.y * 2.0f); } ); } } */ } } PXCMImage BlobImage; if (FContext[0].blobConfig.IsSegmentationImageEnabled() && blobList[i].QuerySegmentationImage(out BlobImage) >= pxcmStatus.PXCM_STATUS_NO_ERROR) { PXCMImage.ImageData BlobImageData; if (BlobImage.AcquireAccess(PXCMImage.Access.ACCESS_READ, PXCMImage.PixelFormat.PIXEL_FORMAT_Y8, out BlobImageData) >= pxcmStatus.PXCM_STATUS_NO_ERROR) { FImage[i] = new RSSDKImage(); FImage[i].Source = BlobImage; FImage[i].Data = BlobImage.GetY8Pixels(); FImage[i].Source = BlobImage; FImage[i].Width = BlobImage.info.width; FImage[i].Height = BlobImage.info.height; FImage[i].Format = PXCMImage.PixelFormat.PIXEL_FORMAT_Y8; BlobImage.ReleaseAccess(BlobImageData); } } } FCenter[i] = blobList[i].QueryExtremityPoint(PXCMBlobData.ExtremityType.EXTREMITY_CENTER).ToVector3D(); FClosest[i] = blobList[i].QueryExtremityPoint(PXCMBlobData.ExtremityType.EXTREMITY_CLOSEST).ToVector3D(); } } catch (Exception) { //Flogger.Log(); } } }
public void DisconnectPin(IPluginIO pin) { if (pin == FContext.PluginIO) { Image = null; FContextChanged = true; FLogger.Log(LogType.Debug, pin.Name + " got disconnected"); } }
internal void SetupNode() { if( (FContext != null) && (FContext.SliceCount > 0) && FContext[0].Configured && (FContext[0].sm != null) && FContext[0].sm.IsConnected() && (FContext[0].Streams.Count > 0) && FContext[0].Streams.ContainsKey(PXCMCapture.StreamType.STREAM_TYPE_DEPTH) ) { Image = FContext[0].Streams[PXCMCapture.StreamType.STREAM_TYPE_DEPTH]; FFocalLengthOut[0] = FContext[0].device.QueryDepthFocalLength().ToVector2D(); FFOVOut[0] = FContext[0].device.QueryDepthFieldOfView().ToVector2D(); FPrincipalPointOut[0] = FContext[0].device.QueryDepthPrincipalPoint().ToVector2D(); FSensorRangeOut[0] = FContext[0].device.QueryDepthSensorRange().ToVector2D(); //mm FDepthUnitOut[0] = FContext[0].device.QueryDepthUnit(); //uint FLowConfidenceValueOut[0] = FContext[0].device.QueryDepthLowConfidenceValue(); FConfidenceThresholdOut[0] = FContext[0].device.QueryDepthConfidenceThreshold(); FFormatOut[0] = FContext[0].Streams[PXCMCapture.StreamType.STREAM_TYPE_DEPTH].Format.ToString(); } else { Image = null; FDepth.SliceCount = 0; } }
internal void SetupNode() { if((FContext != null) && (FContext.SliceCount > 0) && FContext[0].Configured && (FContext[0].sm != null) && FContext[0].sm.IsConnected() ) { if(!FContext[0].Streams.ContainsKey(PXCMCapture.StreamType.STREAM_TYPE_COLOR) ) { FContext[0].cm.CloseStreams(); FContext[0].Status = FContext[0].sm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, 0,0,0); if(FContext[0].Status == pxcmStatus.PXCM_STATUS_NO_ERROR) FLogger.Log(LogType.Debug, "Enabled RGB stream\n\r"); RSSDKImage img = new RSSDKImage(); img.Type = PXCMCapture.StreamType.STREAM_TYPE_COLOR; img.Format = PXCMImage.PixelFormat.PIXEL_FORMAT_RGB32; FContext[0].Streams.Add(PXCMCapture.StreamType.STREAM_TYPE_COLOR, img); //FContext[0].sm.StreamFrames(false); } //??? Image = FContext[0].Streams[PXCMCapture.StreamType.STREAM_TYPE_COLOR]; FFocalLengthOut[0] = FContext[0].device.QueryColorFocalLength().ToVector2D(); FFOVOut[0] = FContext[0].device.QueryColorFieldOfView().ToVector2D(); FPrincipalPointOut[0] = FContext[0].device.QueryColorPrincipalPoint().ToVector2D(); FFormatOut[0] = FContext[0].Streams[PXCMCapture.StreamType.STREAM_TYPE_COLOR].Format.ToString(); FExposureOut[0] = FContext[0].device.QueryColorExposure(); FWhiteBalanceOut[0] = FContext[0].device.QueryColorWhiteBalance(); FBackLightCompensationOut[0] = FContext[0].device.QueryColorBackLightCompensation(); FColorBrightnessOut[0] = FContext[0].device.QueryColorBrightness(); FContrastOut[0] = FContext[0].device.QueryColorContrast(); FColorGainOut[0] = FContext[0].device.QueryColorGain(); FGammaOut[0] = FContext[0].device.QueryColorGamma(); FHueOut[0] = FContext[0].device.QueryColorHue(); FPowerLineFrequencyOut[0] = FContext[0].device.QueryColorPowerLineFrequency(); FSaturationOut[0] = FContext[0].device.QueryColorSaturation(); FSharpnessOut[0] = FContext[0].device.QueryColorSharpness(); FFormatOut[0] = FContext[0].Streams[PXCMCapture.StreamType.STREAM_TYPE_COLOR].Format.ToString(); FAutoExposureOut[0] = FContext[0].device.QueryColorAutoExposure(); FAutoWhiteBalanceOut[0] = FContext[0].device.QueryColorAutoWhiteBalance(); //query properties info var pInfoExposure = FContext[0].device.QueryColorExposureInfo(); FLogger.Log(LogType.Debug, PropertyInfoToString("Exposure", pInfoExposure)); var pInfoWhiteBalance = FContext[0].device.QueryColorWhiteBalanceInfo(); FLogger.Log(LogType.Debug, PropertyInfoToString("WhiteBalance", pInfoWhiteBalance)); var pInfoBackLightCompensation = FContext[0].device.QueryColorBackLightCompensationInfo(); FLogger.Log(LogType.Debug, PropertyInfoToString("BackLightCompensation", pInfoBackLightCompensation)); var pInfoBrightness = FContext[0].device.QueryColorBrightnessInfo(); FLogger.Log(LogType.Debug, PropertyInfoToString("Brightness", pInfoBrightness)); var pInfoContrast = FContext[0].device.QueryColorContrastInfo(); FLogger.Log(LogType.Debug, PropertyInfoToString("Contrast", pInfoContrast)); var pInfoGain = FContext[0].device.QueryColorGainInfo(); FLogger.Log(LogType.Debug, PropertyInfoToString("Gain", pInfoGain)); var pInfoGamma = FContext[0].device.QueryColorGammaInfo(); FLogger.Log(LogType.Debug, PropertyInfoToString("Gamma", pInfoGamma)); var pInfoHue = FContext[0].device.QueryColorHueInfo(); FLogger.Log(LogType.Debug, PropertyInfoToString("Hue", pInfoHue)); var pInfoSaturation = FContext[0].device.QueryColorSaturationInfo(); FLogger.Log(LogType.Debug, PropertyInfoToString("Saturation", pInfoSaturation)); var pInfoSharpness = FContext[0].device.QueryColorSharpnessInfo(); FLogger.Log(LogType.Debug, PropertyInfoToString("Sharpness", pInfoSharpness)); } }
internal bool EnableCaptureStream(PXCMCapture.StreamType st, PXCMCapture.Device.StreamProfile profileInfo) { Single fps = profileInfo.frameRate.max; SenseSession.Status = SenseSession.sm.EnableStream(st, profileInfo.imageInfo.width, profileInfo.imageInfo.height, fps); if(SenseSession.Status == pxcmStatus.PXCM_STATUS_NO_ERROR) { RSSDKImage img = new RSSDKImage(); img.Type = st; img.Format = profileInfo.imageInfo.format; SenseSession.Streams.Add(st, img); return true; } return false; }
public void Evaluate(int SpreadMax) { if( (FContext.SliceCount > 0) && (FContext[0].Configured) && FContext[0].HandEnabled) { processConfig(); /* if (FContext[0].handImage != null) { if (FContext[0].handImage.Source != null) { image = FContext[0].handImage.Source; } } */ try { FID.SliceCount = 0; int numHands = FContext[0].handData.QueryNumberOfHands(); FNumHands[0] = numHands; FJointsPositionImage.SliceCount = numHands; FJointsPositionWorld.SliceCount = numHands; FJointsOrientation.SliceCount = numHands; FJointsConfidence.SliceCount = numHands; FIsCalibrated.SliceCount = numHands; FTracked.SliceCount = numHands; FOutsideFOV.SliceCount = numHands; FMovingTooFast.SliceCount = numHands; FOutsideDepthRange.SliceCount = numHands; FPointingFingers.SliceCount = numHands; FOpen.SliceCount = numHands; FSide.SliceCount = numHands; FPalmOrientation.SliceCount = numHands; FPalmRadiusImage.SliceCount = numHands; FPalmRadiusWorld.SliceCount = numHands; FBBox.SliceCount = numHands; FMassCenterImage.SliceCount = numHands; FMassCenterWorld.SliceCount = numHands; FHasSegmentationImage.SliceCount = numHands; //!!! PXCMRotation rotation; FContext[0].Session.CreateImpl<PXCMRotation>(out rotation); PXCMCapture.Sample HandSample = FContext[0].sm.QueryHandSample(); if (HandSample != null && HandSample.depth != null) { image = HandSample.depth; if(FImage[0] == null) { FImage.SliceCount = 1; FImage[0] = new RSSDKImage(); } } else image = null; for (int j = 0; j < numHands; j++) { int id; FContext[0].handData.QueryHandId(PXCMHandData.AccessOrderType.ACCESS_ORDER_FIXED, j, out id); FID.Add(id); //Get hand by time of appearance PXCMHandData.IHand handInfo; FContext[0].handData.QueryHandData(PXCMHandData.AccessOrderType.ACCESS_ORDER_FIXED, j, out handInfo); if(handInfo != null) { if(FEnableContours[0]) { //Extract Hand Contours int nContours = handInfo.QueryNumberOfContours(); FContour.SliceCount = nContours; for(int contourIndex = 0; contourIndex < nContours; contourIndex++) { PXCMHandData.IContour contourData; handInfo.QueryContour(contourIndex, out contourData); int contourSize = contourData.QuerySize(); if(contourData.IsOuter() && (contourSize>0)) { PXCMPointI32[] ContourPoints = new PXCMPointI32[contourSize]; if(contourData.QueryPoints(out ContourPoints) == pxcmStatus.PXCM_STATUS_NO_ERROR) { FContour[contourIndex].ResizeAndDismiss(ContourPoints.Length); for(int ContourPointIndex = 0; ContourPointIndex < ContourPoints.Length; ContourPointIndex++) { FContour[contourIndex][ContourPointIndex] = new Vector2D(ContourPoints[ContourPointIndex].x / (float)FContext[0].DepthImageSize.x * 2.0f - 1.0f, 1.0f - ContourPoints[ContourPointIndex].y / (float)FContext[0].DepthImageSize.y * 2.0f); } } } } } FIsCalibrated[j] = handInfo.IsCalibrated(); FHasSegmentationImage[j] = handInfo.HasSegmentationImage(); var HasTrackedJoints = handInfo.HasTrackedJoints(); FHasTrackedJoints[j] = HasTrackedJoints; //check status PXCMHandData.TrackingStatusType HandTrackingStatus = (PXCMHandData.TrackingStatusType)handInfo.QueryTrackingStatus(); FTracked[j] = HandTrackingStatus.HasFlag(PXCMHandData.TrackingStatusType.TRACKING_STATUS_GOOD); FOutsideFOV[j] = HandTrackingStatus.HasFlag(PXCMHandData.TrackingStatusType.TRACKING_STATUS_OUT_OF_FOV); FMovingTooFast[j] = HandTrackingStatus.HasFlag(PXCMHandData.TrackingStatusType.TRACKING_STATUS_HIGH_SPEED); FOutsideDepthRange[j] = HandTrackingStatus.HasFlag(PXCMHandData.TrackingStatusType.TRACKING_STATUS_OUT_OF_RANGE); FPointingFingers[j] = HandTrackingStatus.HasFlag(PXCMHandData.TrackingStatusType.TRACKING_STATUS_POINTING_FINGERS); FOpen[j] = (float) handInfo.QueryOpenness() / 100.0; FSide[j] = handInfo.QueryBodySide().ToString(); rotation.SetFromQuaternion(handInfo.QueryPalmOrientation()); FPalmOrientation[j] = rotation.QueryEulerAngles().ToVector3D(); FPalmRadiusImage[j] = handInfo.QueryPalmRadiusImage(); FPalmRadiusWorld[j] = handInfo.QueryPalmRadiusWorld(); FBBox[j] = handInfo.QueryBoundingBoxImage().BBox2DtoVVVV(FContext[0].DepthImageSize); FMassCenterImage[j] = handInfo.QueryMassCenterImage().ToVector2D().Vector2DtoVVVV(FContext[0].DepthImageSize); FMassCenterWorld[j] = handInfo.QueryMassCenterWorld().ToVector3D(); if( HasTrackedJoints) { FJointsPositionImage[j].SliceCount = 0x20; FJointsPositionWorld[j].SliceCount = 0x20; FJointsOrientation[j].SliceCount = 0x20; FJointsConfidence[j].SliceCount = 0x20; //Iterate Joints for (int n = 0; n < 0x20; n++) { PXCMHandData.JointData jointData; handInfo.QueryTrackedJoint((PXCMHandData.JointType)n, out jointData); FJointsPositionImage[j][n] = jointData.positionImage.ToVector3D().Vector3DtoVVVV(FContext[0].DepthImageSize); FJointsConfidence[j][n] = jointData.confidence / 100; FJointsPositionWorld[j][n] = jointData.positionWorld.ToVector3D(); rotation.SetFromQuaternion(jointData.globalOrientation); FJointsOrientation[j][n] = rotation.QueryEulerAngles().ToVector3D(); } // end iterating over joints } else { FJointsPositionImage[j].SliceCount = 0; FJointsPositionWorld[j].SliceCount = 0; FJointsOrientation[j].SliceCount = 0; } // blend images with different colors!!! PXCMImage.ImageData data; if ( (image != null) && (FHasSegmentationImage[j]) && (handInfo.QuerySegmentationImage(out image) >= pxcmStatus.PXCM_STATUS_NO_ERROR)) { //FImage.SliceCount++; if (image.AcquireAccess(PXCMImage.Access.ACCESS_READ, PXCMImage.PixelFormat.PIXEL_FORMAT_Y8, out data) >= pxcmStatus.PXCM_STATUS_NO_ERROR) { if(j == 0) { FImage[0].Source = image; FImage[0].Data = image.GetY8Pixels(); FImage[0].Source = image; FImage[0].Width = image.info.width; FImage[0].Height = image.info.height; FImage[0].Format = PXCMImage.PixelFormat.PIXEL_FORMAT_Y8; } else { var d = image.GetY8Pixels(); for(int e = 0; e < d.Length; e++) FImage[0].Data[e] += d[e]; } image.ReleaseAccess(data); } } } } // if (image != null) // { // image.Dispose(); //} } catch (Exception e) { FLogger.Log(LogType.Debug, "Hand Tracker: " + e.Message.ToString()); } } }