public static CameraSettings ReadFrom(PXCMCapture.Device device)
 {
     CameraSettings result = new CameraSettings();
     result.DepthConfidenceThreshold = device.QueryDepthConfidenceThreshold();
     result.IVCAMAccuracy = (int)device.QueryIVCAMAccuracy();
     result.IVCAMFilterOption = device.QueryIVCAMFilterOption();
     result.IVCAMLaserPower = device.QueryIVCAMLaserPower();
     result.IVCAMMotionRangeTradeOff = device.QueryIVCAMMotionRangeTradeOff();
     result.changed = false;
     return result;
 }
 public static CameraSettings ReadDefaultFrom(PXCMCapture.Device device)
 {
     CameraSettings result = new CameraSettings();
     result.DepthConfidenceThreshold = (ushort)device.QueryDepthConfidenceThresholdInfo().defaultValue;
     result.IVCAMAccuracy = (int)device.QueryIVCAMAccuracyDefaultValue();
     result.IVCAMFilterOption = (int)device.QueryIVCAMFilterOptionInfo().defaultValue;
     result.IVCAMLaserPower = (int)device.QueryIVCAMLaserPowerInfo().defaultValue;
     result.IVCAMMotionRangeTradeOff = (int)device.QueryIVCAMMotionRangeTradeOffInfo().defaultValue;
     result.changed = true;
     return result;
 }
 public void WriteTo(PXCMCapture.Device device, CameraSettings oldSettings)
 {
     if (oldSettings.DepthConfidenceThreshold != DepthConfidenceThreshold)
         device.SetDepthConfidenceThreshold(DepthConfidenceThreshold);
     if (oldSettings.IVCAMAccuracy != IVCAMAccuracy)
         device.SetIVCAMAccuracy((PXCMCapture.Device.IVCAMAccuracy)IVCAMAccuracy);
     if (oldSettings.IVCAMFilterOption != IVCAMFilterOption)
         device.SetIVCAMFilterOption(IVCAMFilterOption);
     if (oldSettings.IVCAMLaserPower != IVCAMLaserPower)
         device.SetIVCAMLaserPower(IVCAMLaserPower);
     if (oldSettings.IVCAMMotionRangeTradeOff != IVCAMMotionRangeTradeOff)
         device.SetIVCAMMotionRangeTradeOff(IVCAMMotionRangeTradeOff);
     this.changed = false;
 }
 internal void SetCameraSettings(CameraSettings cs, PXCMCapture.Device.PropertyInfo[] propInfo)
 {
     this.cameraSettings = cs;
     this.Invoke(
         new UpdateFromOtherThreadDelegate(
             delegate()
             {
                 cameraSettings.SetupTrackBars(this.cameraSettingsTrackBars, propInfo);
             }
         )
     );
 }
Exemple #5
0
        public void ShowStream()
        {
            bool sts = true;

            /* Create an instance of the PXCSenseManager interface */
            using (PXCMSenseManager pp = PXCMSenseManager.CreateInstance())
            {
                if (pp == null)
                {
                    form.UpdateStatus("Failed to create an SDK pipeline object");
                    return;
                }

                /* Set Input Source */
                PXCMCapture.DeviceInfo dinfo2 = form.GetCheckedDevice();
                if (form.IsModeLive() || form.IsModeRecorded())
                {
                    pp.captureManager.FilterByDeviceInfo(dinfo2);
                }

                /* Set Depth Resolution */
                PXCMCapture.Device.StreamProfile dinfo = form.GetDepthConfiguration();
                if (dinfo.imageInfo.format != 0)
                {
                    Single dfps = dinfo.frameRate.max;
                    pp.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_DEPTH, dinfo.imageInfo.width, dinfo.imageInfo.height, dfps);
                    //: enable also rgb and ir streams:
                    pp.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, dinfo.imageInfo.width, dinfo.imageInfo.height, dfps);
                    pp.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_IR, dinfo.imageInfo.width, dinfo.imageInfo.height, dfps);
                }

                /* Initialization */
                FPSTimer timer = new FPSTimer(form);
                form.UpdateStatus("Init Started");
                if (pp.Init() >= pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    /* Configure the camera to return a non-mirrored image */
                    pp.captureManager.device.SetMirrorMode(PXCMCapture.Device.MirrorMode.MIRROR_MODE_DISABLED);
                    appliedCameraSettings = CameraSettings.ReadFrom(pp.captureManager.device);
                    form.SetCameraSettings(appliedCameraSettings, CameraSettings.ReadPropInfo(pp.captureManager.device));

                    /* For UV Mapping & Projection only: Save certain properties */
                    using (Projection projection = new Projection(pp.session, pp.captureManager.device, dinfo.imageInfo))
                    {
                        form.UpdateStatus("Streaming");
                        int bitmap_width  = dinfo.imageInfo.width;
                        int bitmap_height = dinfo.imageInfo.height;
                        while (!form.GetStopState())
                        {
                            CameraSettings newCameraSettings = form.CameraSettings;
                            if (newCameraSettings.changed)
                            {//: apply new camera settings:
                                newCameraSettings.WriteTo(pp.captureManager.device, this.appliedCameraSettings);
                                this.appliedCameraSettings = newCameraSettings;
                            }

                            //: acquire frame:
                            if (pp.AcquireFrame(true) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                            {
                                break;
                            }

                            //: process frame:
                            GuiParams          guiParams = form.GetParams();
                            PXCMCapture.Sample sample    = pp.QuerySample();
                            projection.SearchForObject(sample, guiParams.processParams);
                            pp.ReleaseFrame();

                            byte[] bitmap_data = projection.GetPixelColors();
                            form.SetPicture(bitmap_width, bitmap_height, bitmap_data);
                            form.UpdatePicture();
                            timer.Tick("Streaming.");
                        }
                    }
                }
                else
                {
                    form.UpdateStatus("Init Failed");
                    sts = false;
                }

                pp.Close();
            }
            if (sts)
            {
                form.UpdateStatus("Stopped");
            }
        }
        public void ShowStream()
        {
            bool sts = true;

            /* Create an instance of the PXCSenseManager interface */
            using (PXCMSenseManager pp = PXCMSenseManager.CreateInstance())
            {
                if (pp == null)
                {
                    form.UpdateStatus("Failed to create an SDK pipeline object");
                    return;
                }

                /* Set Input Source */
                PXCMCapture.DeviceInfo dinfo2 = form.GetCheckedDevice();
                if (form.IsModeLive() || form.IsModeRecorded())
                    pp.captureManager.FilterByDeviceInfo(dinfo2);

                /* Set Depth Resolution */
                PXCMCapture.Device.StreamProfile dinfo = form.GetDepthConfiguration();
                if (dinfo.imageInfo.format != 0)
                {
                    Single dfps = dinfo.frameRate.max;
                    pp.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_DEPTH, dinfo.imageInfo.width, dinfo.imageInfo.height, dfps);
                    //: enable also rgb and ir streams:
                    pp.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, dinfo.imageInfo.width, dinfo.imageInfo.height, dfps);
                    pp.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_IR, dinfo.imageInfo.width, dinfo.imageInfo.height, dfps);
                }

                /* Initialization */
                FPSTimer timer = new FPSTimer(form);
                form.UpdateStatus("Init Started");
                if (pp.Init() >= pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    /* Configure the camera to return a non-mirrored image */
                    pp.captureManager.device.SetMirrorMode(PXCMCapture.Device.MirrorMode.MIRROR_MODE_DISABLED);
                    appliedCameraSettings = CameraSettings.ReadFrom(pp.captureManager.device);
                    form.SetCameraSettings(appliedCameraSettings, CameraSettings.ReadPropInfo(pp.captureManager.device));

                    /* For UV Mapping & Projection only: Save certain properties */
                    using (Projection projection = new Projection(pp.session, pp.captureManager.device, dinfo.imageInfo))
                    {
                        form.UpdateStatus("Streaming");
                        int bitmap_width = dinfo.imageInfo.width;
                        int bitmap_height = dinfo.imageInfo.height;
                        while (!form.GetStopState())
                        {
                            CameraSettings newCameraSettings = form.CameraSettings;
                            if (newCameraSettings.changed)
                            {//: apply new camera settings:
                                newCameraSettings.WriteTo(pp.captureManager.device, this.appliedCameraSettings);
                                this.appliedCameraSettings = newCameraSettings;
                            }

                            //: acquire frame:
                            if (pp.AcquireFrame(true) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                                break;

                            //: process frame:
                            GuiParams guiParams = form.GetParams();
                            PXCMCapture.Sample sample = pp.QuerySample();
                            projection.SearchForObject(sample, guiParams.processParams);
                            pp.ReleaseFrame();

                            byte[] bitmap_data = projection.GetPixelColors();
                            form.SetPicture(bitmap_width, bitmap_height, bitmap_data);
                            form.UpdatePicture();
                            timer.Tick("Streaming.");
                        }
                    }
                }
                else
                {
                    form.UpdateStatus("Init Failed");
                    sts = false;
                }

                pp.Close();
            }
            if (sts)
                form.UpdateStatus("Stopped");
        }