private void ConfigureRealSense() { try { // Create the SenseManager instance sm = PXCMSenseManager.CreateInstance(); // Enable the color stream sm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, ImageWidth, ImageHeight, 30); // Enable person tracking sm.EnablePersonTracking(); personModule = sm.QueryPersonTracking(); PXCMPersonTrackingConfiguration personConfig = personModule.QueryConfiguration(); personConfig.SetTrackedAngles(PXCMPersonTrackingConfiguration.TrackingAngles.TRACKING_ANGLES_ALL); // Enable skeleton tracking - not supported on r200? //PXCMPersonTrackingConfiguration.SkeletonJointsConfiguration skeletonConfig = personConfig.QuerySkeletonJoints(); //skeletonConfig.Enable(); // Enable the face module sm.EnableFace(); PXCMFaceModule faceModule = sm.QueryFace(); PXCMFaceConfiguration faceConfig = faceModule.CreateActiveConfiguration(); faceConfig.SetTrackingMode(PXCMFaceConfiguration.TrackingModeType.FACE_MODE_COLOR_PLUS_DEPTH); faceConfig.strategy = PXCMFaceConfiguration.TrackingStrategyType.STRATEGY_APPEARANCE_TIME; faceConfig.detection.maxTrackedFaces = 1; faceConfig.ApplyChanges(); sm.EnableBlob(); PXCMBlobModule blobModule = sm.QueryBlob(); PXCMBlobConfiguration blobConfig = blobModule.CreateActiveConfiguration(); blobConfig.SetMaxBlobs(4); // 4 is the max blobConfig.SetMaxDistance(2000); // in mm's blobConfig.ApplyChanges(); //initialize the SenseManager sm.Init(); faceData = faceModule.CreateOutput(); blobData = blobModule.CreateOutput(); // Mirror the image sm.QueryCaptureManager().QueryDevice().SetMirrorMode(PXCMCapture.Device.MirrorMode.MIRROR_MODE_HORIZONTAL); // Release resources personConfig.Dispose(); faceConfig.Dispose(); faceModule.Dispose(); blobConfig.Dispose(); blobModule.Dispose(); } catch (Exception) { MessageBox.Show("Unable to configure the RealSense camera. Please make sure a R200 camera is connected.", "System Error"); throw; } }
public MainWindow() { InitializeComponent(); // Configure RealSense session and SenseManager interface session = PXCMSession.CreateInstance(); senseManager = session.CreateSenseManager(); senseManager.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, 640, 480, 30); senseManager.EnableBlob(); senseManager.Init(); //Create blobModule from SenseManager blobModule = senseManager.QueryBlob(); blobConfig = blobModule.CreateActiveConfiguration(); blobConfig.SetMaxBlobs(2); blobConfig.SetMaxDistance(trackingDistance); blobConfig.SetMaxObjectDepth(100); blobConfig.SetMinPixelCount(400); blobConfig.EnableColorMapping(true); blobConfig.ApplyChanges(); blobData = blobModule.CreateOutput(); //Audio WaveOut waveOut; sineWaveProvider.SetWaveFormat(16000, 1); sineWaveProvider.Frequency = 1000; sineWaveProvider.Amplitude = 0; waveOut = new WaveOut(); waveOut.Init(sineWaveProvider); waveOut.Play(); startTime = DateTime.Now; // Start Update thread update = new Thread(new ThreadStart(Update)); update.Start(); }
/// <summary> /// Using PXCMSenseManager to handle data /// </summary> public void SimplePipeline() { session = PXCMSession.CreateInstance(); if (session != null) { instance = session.CreateSenseManager(); if (instance == null) { Debug.Log("Create SenseManager Failure"); return; } pxcmStatus status = instance.EnableBlob(); PXCMBlobModule blobModule = instance.QueryBlob(); if (status != pxcmStatus.PXCM_STATUS_NO_ERROR || blobModule == null) { Debug.Log("Failed Loading Module"); return; } blobConfiguration = blobModule.CreateActiveConfiguration(); blobData = blobModule.CreateOutput(); if (blobConfiguration != null) { blobConfiguration.SetSegmentationSmoothing(1.0f); blobConfiguration.SetMaxDistance(550); blobConfiguration.SetMaxObjectDepth(100); blobConfiguration.SetMaxBlobs(_maxBlobToShow); blobConfiguration.SetContourSmoothing(1.0f); blobConfiguration.EnableContourExtraction(true); blobConfiguration.EnableSegmentationImage(true); blobConfiguration.ApplyChanges(); } if (blobData == null) { Debug.Log("Failed Create Output"); return; } PXCMSenseManager.Handler handler = new PXCMSenseManager.Handler(); handler.onModuleProcessedFrame = new PXCMSenseManager.Handler.OnModuleProcessedFrameDelegate(OnNewFrame); if (instance.Init(handler) == pxcmStatus.PXCM_STATUS_NO_ERROR) { PXCMCapture.DeviceInfo dinfo; instance.QueryCaptureManager().QueryDevice().QueryDeviceInfo(out dinfo); if (dinfo != null && dinfo.model == PXCMCapture.DeviceModel.DEVICE_MODEL_IVCAM) { instance.QueryCaptureManager().QueryDevice().SetMirrorMode(PXCMCapture.Device.MirrorMode.MIRROR_MODE_DISABLED); } /* Set the depth stream confidence threshold value - Any depth pixels with a confidence score below the threshold will be set to the low confidence pixel value*/ instance.QueryCaptureManager().QueryDevice().SetDepthConfidenceThreshold(10); /* Set the smoothing aggressiveness parameter - High smoothing effect for distances between 850mm to 1000mm bringing good accuracy with moderate sharpness level.*/ instance.QueryCaptureManager().QueryDevice().SetIVCAMFilterOption(6); } } else { Debug.Log("Init Failed"); } }