예제 #1
0
파일: F200.cs 프로젝트: btlorch/MetriCam2
        /// <summary>
        /// Device-specific implementation of Connect.
        /// Connects the camera.
        /// </summary>
        /// <remarks>This method is implicitely called by <see cref="Camera.Connect"/> inside a camera lock.</remarks>
        /// <seealso cref="Camera.Connect"/>
        protected override void ConnectImpl()
        {
            if (deviceInfo.Count == 0)
            {
                ScanForCameras();
            }

            if (deviceInfo.Count == 0)
            {
                log.Error(Name + "No device found.");
                return;
            }

            int deviceIndex = 0;

            ScanForProfiles(deviceIndex);

            /* Create an instance of the PXCSenseManager interface */
            pp = PXCMSenseManager.CreateInstance();

            if (pp == null)
            {
                log.Error(Name + "Failed to create an SDK pipeline object");
                return;
            }

            pp.captureManager.FilterByDeviceInfo(deviceInfo[deviceIndex]);

            //TODO: change this to work with properties
            currentColorProfile = "YUY2 1920x1080x30";
            currentDepthProfile = "DEPTH 640x480x60";
            currentIRProfile    = "Y8 640x480x60";

            PXCMCapture.Device.StreamProfileSet currentProfileSet = new PXCMCapture.Device.StreamProfileSet();
            currentProfileSet[PXCMCapture.StreamType.STREAM_TYPE_COLOR] = profiles[currentColorProfile];
            currentProfileSet[PXCMCapture.StreamType.STREAM_TYPE_DEPTH] = profiles[currentDepthProfile];
            currentProfileSet[PXCMCapture.StreamType.STREAM_TYPE_IR]    = profiles[currentIRProfile];

            /* Set Color & Depth Resolution */
            for (int s = 0; s < PXCMCapture.STREAM_LIMIT; s++)
            {
                PXCMCapture.StreamType           st   = PXCMCapture.StreamTypeFromIndex(s);
                PXCMCapture.Device.StreamProfile info = currentProfileSet[st];
                if (info.imageInfo.format != 0)
                {
                    Single fps = info.frameRate.max;
                    pp.EnableStream(st, info.imageInfo.width, info.imageInfo.height, fps);
                }
            }
            if (pp.Init() >= pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
            }
            else
            {
                log.Error(Name + "An error occured.");
            }
            ActivateChannel(ChannelNames.Intensity);
            ActivateChannel(ChannelNames.ZImage);
        }
예제 #2
0
 private PXCMCapture.Device.StreamProfileSet GetStreamSetConfiguration()
 {
     PXCMCapture.Device.StreamProfileSet profiles = new PXCMCapture.Device.StreamProfileSet();
     for (int s = 0; s < PXCMCapture.STREAM_LIMIT; s++)
     {
         PXCMCapture.StreamType st = PXCMCapture.StreamTypeFromIndex(s);
         profiles[st] = GetStreamConfiguration(st);
     }
     return(profiles);
 }
예제 #3
0
        private void CheckSelection()
        {
            PXCMCapture.Device.StreamProfile dprofile = GetDepthConfiguration();
            //?DepthNone.Enabled = (cprofile.imageInfo.format != 0 || irprofile.imageInfo.format != 0);

            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.group    = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
            desc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;
            desc.iuid     = current_device_iuid;
            desc.cuids[0] = PXCMCapture.CUID;
            PXCMCapture capture;

            PXCMCapture.DeviceInfo dinfo2 = GetCheckedDevice();
            if (session.CreateImpl <PXCMCapture>(desc, out capture) >= pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                using (capture)
                {
                    using (PXCMCapture.Device device = capture.CreateDevice(dinfo2.didx))
                    {
                        if (device != null)
                        {
                            PXCMCapture.Device.StreamProfileSet profile = new PXCMCapture.Device.StreamProfileSet();
                            PXCMCapture.Device.StreamProfileSet test    = new PXCMCapture.Device.StreamProfileSet();

                            /* Loop over all stream types and profiles and enable only compatible in menu */
                            for (int s = 0; s < PXCMCapture.STREAM_LIMIT; s++)
                            {
                                PXCMCapture.StreamType st = PXCMCapture.StreamTypeFromIndex(s);
                                if (((int)dinfo2.streams & (int)PXCMCapture.StreamType.STREAM_TYPE_COLOR) != 0)
                                {
                                    //?test[PXCMCapture.StreamType.STREAM_TYPE_COLOR] = cprofile;
                                    test[PXCMCapture.StreamType.STREAM_TYPE_DEPTH] = dprofile;
                                    //?test[PXCMCapture.StreamType.STREAM_TYPE_IR] = irprofile;
                                    int num = device.QueryStreamProfileSetNum(st);
                                    for (int p = 0; p < num; p++)
                                    {
                                        if (device.QueryStreamProfileSet(st, p, out profile) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                                        {
                                            break;
                                        }
                                        PXCMCapture.Device.StreamProfile sprofile = profile[st];
                                        ToolStripMenuItem sm1 = GetMenuItem(sprofile);
                                        if (sm1 != null)
                                        {
                                            test[st]    = sprofile;
                                            sm1.Enabled = device.IsStreamProfileSetValid(test);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #4
0
 private PXCMCapture.StreamType GetUnselectedStream()
 {
     for (int s = 0; s < PXCMCapture.STREAM_LIMIT; s++)
     {
         if (streamButtons[s] != null && !streamButtons[s].Checked && streamButtons[s].Enabled)
         {
             return(PXCMCapture.StreamTypeFromIndex(s));
         }
     }
     return(PXCMCapture.StreamType.STREAM_TYPE_ANY);
 }
예제 #5
0
        static void enumDevice(PXCMCapture capture)
        {
            for (int i = 0; ; ++i)
            {
                // デバイス情報を取得する
                PXCMCapture.DeviceInfo dinfo;
                var sts = capture.QueryDeviceInfo(i, out dinfo);
                if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    break;
                }

                // デバイス名を表示する
                Console.WriteLine("\t" + dinfo.name);

                // デバイスを取得する
                var device = capture.CreateDevice(i);

                for (int s = 0; s < PXCMCapture.STREAM_LIMIT; ++s)
                {
                    // ストリーム種別を取得する
                    PXCMCapture.StreamType type = PXCMCapture.StreamTypeFromIndex(s);
                    if ((dinfo.streams & type) == 0)
                    {
                        continue;
                    }

                    // ストリーム名を取得する
                    var name = PXCMCapture.StreamTypeToString(type);
                    Console.WriteLine("\t\t" + name);

                    // ストリームのフォーマットを取得する
                    int nprofiles = device.QueryStreamProfileSetNum(type);
                    for (int p = 0; p < nprofiles; ++p)
                    {
                        PXCMCapture.Device.StreamProfileSet profiles;
                        sts = device.QueryStreamProfileSet(type, p, out profiles);
                        if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR)
                        {
                            break;
                        }

                        // ストリームのフォーマットを表示する
                        Console.WriteLine("\t\t\t" + ProfileToString(profiles[type]));
                    }
                }
            }

            Console.WriteLine("");
        }
예제 #6
0
        private void ScanForProfiles(int deviceIndex)
        {
            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.group    = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
            desc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;
            desc.iuid     = devicesUIDs[deviceIndex];
            int current_device_iuid = desc.iuid;

            desc.cuids[0] = PXCMCapture.CUID;

            profiles.Clear();

            List <string> colorStrings = new List <string>();
            List <string> depthStrings = new List <string>();
            PXCMCapture   capture;

            PXCMCapture.DeviceInfo dinfo2 = deviceInfo[deviceIndex];
            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();

                    for (int s = 0; s < PXCMCapture.STREAM_LIMIT; s++)
                    {
                        PXCMCapture.StreamType st = PXCMCapture.StreamTypeFromIndex(s);
                        if (((int)dinfo2.streams & (int)st) != 0)
                        {
                            int num = device.QueryStreamProfileSetNum(st);
                            for (int p = 0; p < num; p++)
                            {
                                if (device.QueryStreamProfileSet(st, p, out profile) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                                {
                                    break;
                                }
                                PXCMCapture.Device.StreamProfile sprofile = profile[st];
                                string profileText = ProfileToString(sprofile);
                                try
                                {
                                    profiles.Add(profileText, sprofile);
                                }
                                catch
                                {
                                }
                                switch (st)
                                {
                                case PXCMCapture.StreamType.STREAM_TYPE_COLOR:
                                    colorStrings.Add(profileText);
                                    break;

                                case PXCMCapture.StreamType.STREAM_TYPE_DEPTH:
                                    depthStrings.Add(profileText);
                                    break;
                                }
                            }
                        }
                    }

                    device.Dispose();
                }
                capture.Dispose();
            }
            colorProfiles = new ListParamDesc <string>(colorStrings)
            {
                Description  = "Color Profiles",
                ReadableWhen = ParamDesc.ConnectionStates.Connected,
            };
            depthProfiles = new ListParamDesc <string>(depthStrings)
            {
                Description  = "Depth Profiles",
                ReadableWhen = ParamDesc.ConnectionStates.Connected,
            };
        }
예제 #7
0
        public void StreamColorDepth() /* Stream Color and Depth Synchronously or Asynchronously */
        {
            try
            {
                bool sts = true;

                /* Create an instance of the PXCMSenseManager interface */
                PXCMSenseManager sm = PXCMSenseManager.CreateInstance();

                if (sm == null)
                {
                    SetStatus("Failed to create an SDK pipeline object");
                    return;
                }

                /* Optional: if playback or recoridng */
                if ((Playback || Record) && File != null)
                {
                    sm.captureManager.SetFileName(File, Record);
                }

                /* Optional: Set Input Source */
                if (!Playback && DeviceInfo != null)
                {
                    sm.captureManager.FilterByDeviceInfo(DeviceInfo);
                }

                /* Set Color & Depth Resolution and enable streams */
                if (StreamProfileSet != null)
                {
                    /* Optional: Filter the data based on the request */
                    sm.captureManager.FilterByStreamProfiles(StreamProfileSet);

                    /* Enable raw data streaming for specific stream types */
                    for (int s = 0; s < PXCMCapture.STREAM_LIMIT; s++)
                    {
                        PXCMCapture.StreamType           st   = PXCMCapture.StreamTypeFromIndex(s);
                        PXCMCapture.Device.StreamProfile info = StreamProfileSet[st];
                        if (info.imageInfo.format != 0)
                        {
                            /* For simple request, you can also use sm.EnableStream(...) */
                            PXCMVideoModule.DataDesc desc = new PXCMVideoModule.DataDesc();
                            desc.streams[st].frameRate.min  = desc.streams[st].frameRate.max = info.frameRate.max;
                            desc.streams[st].sizeMin.height = desc.streams[st].sizeMax.height = info.imageInfo.height;
                            desc.streams[st].sizeMin.width  = desc.streams[st].sizeMax.width = info.imageInfo.width;
                            desc.streams[st].options        = info.options;
                            sm.EnableStreams(desc);
                        }
                    }
                }

                /* Initialization */
                Timer timer = new Timer();
                timer.UpdateStatus += UpdateStatus;

                SetStatus("Init Started");
                if (sm.Init() >= pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    /* Reset all properties */
                    sm.captureManager.device.ResetProperties(PXCMCapture.StreamType.STREAM_TYPE_ANY);

                    /* Set mirror mode */
                    PXCMCapture.Device.MirrorMode mirror = Mirror ? PXCMCapture.Device.MirrorMode.MIRROR_MODE_HORIZONTAL : PXCMCapture.Device.MirrorMode.MIRROR_MODE_DISABLED;
                    sm.captureManager.device.SetMirrorMode(mirror);

                    SetStatus("Streaming");
                    while (!Stop)
                    {
                        /* Wait until a frame is ready: Synchronized or Asynchronous */
                        if (sm.AcquireFrame(Synced).IsError())
                        {
                            break;
                        }

                        /* Display images */
                        PXCMCapture.Sample sample = sm.QuerySample();

                        /* Render streams */
                        EventHandler <RenderFrameEventArgs> render = RenderFrame;
                        PXCMImage image = null;
                        if (ColorPanel != PXCMCapture.StreamType.STREAM_TYPE_ANY && render != null)
                        {
                            image = sample[ColorPanel];
                            render(this, new RenderFrameEventArgs(0, image));
                        }

                        if (DepthPanel != PXCMCapture.StreamType.STREAM_TYPE_ANY && render != null)
                        {
                            render(this, new RenderFrameEventArgs(1, sample[DepthPanel]));
                        }

                        if (IRPanel != PXCMCapture.StreamType.STREAM_TYPE_ANY && render != null)
                        {
                            render(this, new RenderFrameEventArgs(2, sample[IRPanel]));
                        }

                        if (IRLeftPanel != PXCMCapture.StreamType.STREAM_TYPE_ANY && render != null)
                        {
                            render(this, new RenderFrameEventArgs(3, sample[IRLeftPanel]));
                        }

                        if (IRRightPanel != PXCMCapture.StreamType.STREAM_TYPE_ANY && render != null)
                        {
                            render(this, new RenderFrameEventArgs(4, sample[IRRightPanel]));
                        }

                        /* Optional: Set Mirror State */
                        mirror = Mirror ? PXCMCapture.Device.MirrorMode.MIRROR_MODE_HORIZONTAL : PXCMCapture.Device.MirrorMode.MIRROR_MODE_DISABLED;
                        if (mirror != sm.captureManager.device.QueryMirrorMode())
                        {
                            sm.captureManager.device.SetMirrorMode(mirror);
                        }

                        /* Optional: Show performance tick */
                        if (image != null)
                        {
                            timer.Tick(PXCMImage.PixelFormatToString(image.info.format) + " " + image.info.width + "x" + image.info.height);
                        }

                        sm.ReleaseFrame();
                    }
                }
                else
                {
                    SetStatus("Init Failed");
                    sts = false;
                }

                sm.Dispose();
                if (sts)
                {
                    SetStatus("Stopped");
                }
            }
            catch (Exception e) {
                SetStatus(e.GetType().ToString());
            }
        }
예제 #8
0
        private void CheckSelection()
        {
            if (!ModePlayback.Checked)
            {
                PXCMCapture.Device.StreamProfileSet allProfile = new PXCMCapture.Device.StreamProfileSet();
                for (int s = 0; s < PXCMCapture.STREAM_LIMIT; s++)
                {
                    PXCMCapture.StreamType st = PXCMCapture.StreamTypeFromIndex(s);
                    allProfile[st] = GetStreamConfiguration(st);
                }

                PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
                desc.group    = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
                desc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;
                desc.iuid     = current_device_iuid;
                desc.cuids[0] = PXCMCapture.CUID;
                PXCMCapture            capture;
                PXCMCapture.DeviceInfo dinfo2 = GetCheckedDevice();
                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.StreamProfileSet test    = new PXCMCapture.Device.StreamProfileSet();

                        /* Loop over all stream types and profiles and enable only compatible in menu */
                        for (int s = 0; s < PXCMCapture.STREAM_LIMIT; s++)
                        {
                            PXCMCapture.StreamType st = PXCMCapture.StreamTypeFromIndex(s);
                            if (((int)dinfo2.streams & (int)st) != 0)
                            {
                                for (int s1 = 0; s1 < PXCMCapture.STREAM_LIMIT; s1++)
                                {
                                    test[PXCMCapture.StreamTypeFromIndex(s1)] = allProfile[PXCMCapture.StreamTypeFromIndex(s1)];
                                }
                                int num = device.QueryStreamProfileSetNum(st);
                                for (int p = 0; p < num; p++)
                                {
                                    if (device.QueryStreamProfileSet(st, p, out profile) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                                    {
                                        break;
                                    }
                                    PXCMCapture.Device.StreamProfile sprofile = profile[st];
                                    ToolStripMenuItem sm1 = GetMenuItem(st, sprofile);
                                    if (sm1 != null)
                                    {
                                        test[st]    = sprofile;
                                        sm1.Enabled = device.IsStreamProfileSetValid(test);
                                    }
                                }
                            }
                        }
                        Start.Enabled = device.IsStreamProfileSetValid(allProfile);
                        device.Dispose();
                    }
                    capture.Dispose();
                }
            }

            int sumEnabled = 0;

            for (int s = 0; s < PXCMCapture.STREAM_LIMIT; s++)
            {
                if (streamButtons[s] != null && streamNone[s] != null)
                {
                    streamButtons[s].Enabled = !streamNone[s].Checked;
                    sumEnabled += streamButtons[s].Enabled?1:0;
                }
            }
            PIP.Enabled    = (sumEnabled >= 2);
            Mirror.Enabled = !ModePlayback.Checked;

            PXCMCapture.StreamType selectedStream = GetSelectedStream();
            if (selectedStream != PXCMCapture.StreamType.STREAM_TYPE_ANY && !streamButtons[PXCMCapture.StreamTypeToIndex(selectedStream)].Enabled)
            {
                PXCMCapture.StreamType st = GetUnselectedStream();
                streamButtons[PXCMCapture.StreamTypeToIndex(st)].Checked = true;
                streaming.ColorPanel = st;
            }

            //if (PIP.Enabled && streaming.DepthPanel == PXCMCapture.StreamType.STREAM_TYPE_ANY)
            //{
            //    streaming.DepthPanel = GetUnselectedStream();
            //}
        }
예제 #9
0
        private void PopulateColorDepthMenus(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];
            current_device_iuid = desc.iuid;
            desc.cuids[0]       = PXCMCapture.CUID;

            profiles.Clear();
            foreach (ToolStripMenuItem menu in streamMenus)
            {
                if (menu != null)
                {
                    menu.DropDownItems.Clear();
                }
            }

            PXCMCapture capture;

            PXCMCapture.DeviceInfo dinfo2 = GetCheckedDevice();
            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();

                    for (int s = 0; s < PXCMCapture.STREAM_LIMIT; s++)
                    {
                        PXCMCapture.StreamType st = PXCMCapture.StreamTypeFromIndex(s);
                        if (((int)dinfo2.streams & (int)st) != 0 && streamMenus[s] != null)
                        {
                            streamMenus[s].Visible   = true;
                            streamButtons[s].Visible = true;
                            streamPanels[s].Visible  = true;

                            int num = device.QueryStreamProfileSetNum(st);
                            for (int p = 0; p < num; p++)
                            {
                                if (device.QueryStreamProfileSet(st, p, out profile) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                                {
                                    break;
                                }
                                PXCMCapture.Device.StreamProfile sprofile = profile[st];
                                ToolStripMenuItem sm1 = new ToolStripMenuItem(ProfileToString(sprofile), null, new EventHandler(Stream_Item_Click));
                                profiles[sm1] = sprofile;
                                streamMenus[s].DropDownItems.Add(sm1);

                                if (sm1.Text.Contains(default_config[s]))
                                {
                                    default_menu[s] = p;
                                    Debug.WriteLine(s + " : " + p + " : " + ProfileToString(sprofile));
                                }
                            }
                        }
                        else if (((int)dinfo2.streams & (int)st) == 0 && streamMenus[s] != null)
                        {
                            streamMenus[s].Visible   = false;
                            streamButtons[s].Visible = false;
                            streamPanels[s].Visible  = false;
                        }
                    }

                    device.Dispose();
                }
                capture.Dispose();
            }
            for (int i = 0; i < PXCMCapture.STREAM_LIMIT; i++)
            {
                ToolStripMenuItem menu = streamMenus[i];
                if (menu != null)
                {
                    streamNone[i]           = new ToolStripMenuItem("None", null, new EventHandler(Stream_Item_Click));
                    profiles[streamNone[i]] = new PXCMCapture.Device.StreamProfile();
                    menu.DropDownItems.Add(streamNone[i]);
                    if (default_menu[i] != 0)
                    {
                        (menu.DropDownItems[default_menu[i]] as ToolStripMenuItem).Checked = true;
                    }
                    else
                    {
                        streamNone[i].Checked = true;
                    }
                }
            }

            CheckSelection();
        }
예제 #10
0
        private bool PopulateDeviceFromFileMenu()
        {
            devices.Clear();
            devices_iuid.Clear();

            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.group    = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
            desc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;

            PXCMSession.ImplDesc   desc1;
            PXCMCapture.DeviceInfo dinfo;
            PXCMSenseManager       pp = PXCMSenseManager.CreateInstance();

            if (pp == null)
            {
                SetStatus("Init Failed");
                return(false);
            }
            try
            {
                if (session.QueryImpl(desc, 0, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    throw null;
                }
                if (pp.captureManager.SetFileName(streaming.File, false) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    throw null;
                }
                if (pp.captureManager.LocateStreams() < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    throw null;
                }
                pp.captureManager.device.QueryDeviceInfo(out dinfo);
            }
            catch
            {
                pp.Dispose();
                SetStatus("Init Failed");
                return(false);
            }
            DeviceMenu.DropDownItems.Clear();
            ToolStripMenuItem sm1 = new ToolStripMenuItem(dinfo.name, null, new EventHandler(Device_Item_Click));

            devices[sm1]      = dinfo;
            devices_iuid[sm1] = desc1.iuid;
            DeviceMenu.DropDownItems.Add(sm1);

            sm1         = new ToolStripMenuItem("playback from the file : ", null);
            sm1.Enabled = false;
            DeviceMenu.DropDownItems.Add(sm1);
            sm1         = new ToolStripMenuItem(streaming.File, null);
            sm1.Enabled = false;
            DeviceMenu.DropDownItems.Add(sm1);
            if (DeviceMenu.DropDownItems.Count > 0)
            {
                (DeviceMenu.DropDownItems[0] as ToolStripMenuItem).Checked = true;
            }

            /* populate profile menus from the file */
            profiles.Clear();
            foreach (ToolStripMenuItem menu in streamMenus)
            {
                if (menu != null)
                {
                    menu.DropDownItems.Clear();
                }
            }

            PXCMCapture.Device device = pp.captureManager.device;
            if (device == null)
            {
                pp.Dispose();
                SetStatus("Init Failed");
                return(false);
            }

            PXCMCapture.Device.StreamProfileSet profile = new PXCMCapture.Device.StreamProfileSet();

            for (int s = 0; s < PXCMCapture.STREAM_LIMIT; s++)
            {
                PXCMCapture.StreamType st = PXCMCapture.StreamTypeFromIndex(s);
                if (((int)dinfo.streams & (int)st) != 0 && streamMenus[s] != null)
                {
                    streamMenus[s].Visible   = true;
                    streamButtons[s].Visible = true;
                    streamPanels[s].Visible  = true;
                    int num = device.QueryStreamProfileSetNum(st);
                    for (int p = 0; p < num; p++)
                    {
                        if (device.QueryStreamProfileSet(st, p, out profile) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                        {
                            break;
                        }
                        PXCMCapture.Device.StreamProfile sprofile = profile[st];
                        sm1           = new ToolStripMenuItem(ProfileToString(sprofile), null, new EventHandler(Stream_Item_Click));
                        profiles[sm1] = sprofile;
                        streamMenus[s].DropDownItems.Add(sm1);
                        Debug.WriteLine("1: " + ProfileToString(sprofile));
                    }
                }
                else if (((int)dinfo.streams & (int)st) == 0 && streamMenus[s] != null)
                {
                    streamMenus[s].Visible   = false;
                    streamButtons[s].Visible = false;
                    streamPanels[s].Visible  = false;
                }
            }

            for (int i = 0; i < PXCMCapture.STREAM_LIMIT; i++)
            {
                ToolStripMenuItem menu = streamMenus[i];
                if (menu != null)
                {
                    streamNone[i]           = new ToolStripMenuItem("None", null, new EventHandler(Stream_Item_Click));
                    profiles[streamNone[i]] = new PXCMCapture.Device.StreamProfile();
                    menu.DropDownItems.Add(streamNone[i]);
                    (menu.DropDownItems[0] as ToolStripMenuItem).Checked = true;
                }
            }
            Start.Enabled = true;

            CheckSelection();
            pp.Close();
            pp.Dispose();

            StatusLabel.Text = "Ok";
            return(true);
        }