private void PopulateDepthMenus(ToolStripMenuItem device_item) { PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc(); desc.group = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR; desc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE; desc.iuid = devices_iuid[device_item]; desc.cuids[0] = PXCMCapture.CUID; DepthMenu.DropDownItems.Clear(); PXCMCapture capture; PXCMCapture.DeviceInfo dinfo2 = GetCheckedDevice(); PXCMSenseManager pp = session.CreateSenseManager(); if (pp == null) { return; } if (pp.Enable3DScan() < pxcmStatus.PXCM_STATUS_NO_ERROR) { return; } PXCM3DScan s = pp.Query3DScan(); if (s == null) { return; } PXCMVideoModule m = s.QueryInstance <PXCMVideoModule>(); if (m == null) { return; } if (session.CreateImpl <PXCMCapture>(desc, out capture) >= pxcmStatus.PXCM_STATUS_NO_ERROR) { PXCMCapture.Device device = capture.CreateDevice(dinfo2.didx); if (device != null) { PXCMCapture.Device.StreamProfileSet profile = new PXCMCapture.Device.StreamProfileSet();; PXCMCapture.Device.StreamProfile color_profile = GetColorConfiguration(); if (((int)dinfo2.streams & (int)PXCMCapture.StreamType.STREAM_TYPE_DEPTH) != 0) { for (int p = 0; ; p++) { if (device.QueryStreamProfileSet(PXCMCapture.StreamType.STREAM_TYPE_DEPTH, p, out profile) < pxcmStatus.PXCM_STATUS_NO_ERROR) { break; } PXCMCapture.Device.StreamProfile sprofile = profile[PXCMCapture.StreamType.STREAM_TYPE_DEPTH]; bool bFound = false; int i = 0; PXCMVideoModule.DataDesc inputs; while ((m.QueryCaptureProfile(i++, out inputs) >= pxcmStatus.PXCM_STATUS_NO_ERROR)) { if ((sprofile.imageInfo.height == inputs.streams.depth.sizeMax.height) && (sprofile.imageInfo.width == inputs.streams.depth.sizeMax.width) && (sprofile.frameRate.max == inputs.streams.depth.frameRate.max) && (color_profile.frameRate.max == inputs.streams.depth.frameRate.max)) { bFound = true; } } if (bFound) { if (sprofile.options != (PXCMCapture.Device.StreamOption) 0x20000) // do not show Depth Confidence { ToolStripMenuItem sm1 = new ToolStripMenuItem(ProfileToString(sprofile), null, new EventHandler(Depth_Item_Click)); profiles[sm1] = sprofile; DepthMenu.DropDownItems.Add(sm1); } } } } device.Dispose(); } capture.Dispose(); } m.Dispose(); pp.Dispose(); if (DepthMenu.DropDownItems.Count > 0) { (DepthMenu.DropDownItems[DepthMenu.DropDownItems.Count - 1] as ToolStripMenuItem).Checked = true; } }
private void PopulateColorMenus(ToolStripMenuItem device_item) { OperatingSystem os_version = Environment.OSVersion; PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc(); desc.group = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR; desc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE; desc.iuid = devices_iuid[device_item]; desc.cuids[0] = PXCMCapture.CUID; profiles.Clear(); ColorMenu.DropDownItems.Clear(); PXCMCapture capture; PXCMCapture.DeviceInfo dinfo2 = GetCheckedDevice(); PXCMSenseManager pp = session.CreateSenseManager(); if (pp == null) { return; } if (pp.Enable3DScan() < pxcmStatus.PXCM_STATUS_NO_ERROR) { return; } PXCM3DScan s = pp.Query3DScan(); if (s == null) { return; } PXCMVideoModule m = s.QueryInstance <PXCMVideoModule>(); if (m == null) { return; } int count = 0; if (session.CreateImpl <PXCMCapture>(desc, out capture) >= pxcmStatus.PXCM_STATUS_NO_ERROR) { PXCMCapture.Device device = capture.CreateDevice(dinfo2.didx); if (device != null) { PXCMCapture.Device.StreamProfileSet profile = new PXCMCapture.Device.StreamProfileSet();; if (dinfo2.streams.HasFlag(PXCMCapture.StreamType.STREAM_TYPE_COLOR)) { for (int p = 0; ; p++) { if (device.QueryStreamProfileSet(PXCMCapture.StreamType.STREAM_TYPE_COLOR, p, out profile) < pxcmStatus.PXCM_STATUS_NO_ERROR) { break; } PXCMCapture.Device.StreamProfile sprofile = profile[PXCMCapture.StreamType.STREAM_TYPE_COLOR]; // Only populate profiles which are supported by the module bool bFound = false; int i = 0; PXCMVideoModule.DataDesc inputs; PXCMImage.PixelFormat format = PXCMImage.PixelFormat.PIXEL_FORMAT_RGB32; if (dinfo2.orientation != PXCMCapture.DeviceOrientation.DEVICE_ORIENTATION_REAR_FACING) { format = PXCMImage.PixelFormat.PIXEL_FORMAT_RGB24; } while ((m.QueryCaptureProfile(i++, out inputs) >= pxcmStatus.PXCM_STATUS_NO_ERROR)) { if ((sprofile.imageInfo.height == inputs.streams.color.sizeMax.height) && (sprofile.imageInfo.width == inputs.streams.color.sizeMax.width) && (sprofile.frameRate.max == inputs.streams.color.frameRate.max) && (sprofile.imageInfo.format == format) && (0 == (sprofile.options & PXCMCapture.Device.StreamOption.STREAM_OPTION_UNRECTIFIED))) { bFound = true; if (dinfo2.orientation != PXCMCapture.DeviceOrientation.DEVICE_ORIENTATION_REAR_FACING) { // Hide rear facing resolutions when the front facing camera is connected... if (sprofile.imageInfo.width == 640) { bFound = false; } } // On Windows 7, filter non-functional 30 fps modes if (Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor == 1) { if (sprofile.frameRate.max == 30) { bFound = false; } } } } if (bFound) { ToolStripMenuItem sm1 = new ToolStripMenuItem(ProfileToString(sprofile), null, new EventHandler(Color_Item_Click)); profiles[sm1] = sprofile; ColorMenu.DropDownItems.Add(sm1); count++; } } } device.Dispose(); } capture.Dispose(); } m.Dispose(); pp.Dispose(); if (count > 0) { (ColorMenu.DropDownItems[ColorMenu.DropDownItems.Count - 1] as ToolStripMenuItem).Checked = true; } }