public void EnableStreamsFromSelection()
        {
            /* Set Color & Depth Resolution and enable streams */
            if (StreamProfileSet != null)
            {
                /* Optional: Filter the data based on the request */
                manager.SenseManager.CaptureManager.FilterByStreamProfiles(StreamProfileSet);

                /* Enable raw data streaming for specific stream types */

                // Set frame Rate, Height and With for all Sterams
                for (int s = 0; s < RS.Capture.STREAM_LIMIT; s++)
                {
                    RS.StreamType    st   = RS.Capture.StreamTypeFromIndex(s);
                    RS.StreamProfile info = StreamProfileSet[st];
                    if (info.imageInfo.format != 0)
                    {
                        /* For simple request, you can also use sm.EnableStream(...) */
                        RS.DataDesc desc = new RS.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;
                        desc.receivePartialSample       = true;
                        RS.SampleReader sampleReader = RS.SampleReader.Activate(manager.SenseManager);
                        sampleReader.EnableStreams(desc);
                    }
                }
            }
        }
Beispiel #2
0
        private void PopulateProfiles(RS.DeviceInfo dinfo)
        {
            RS.SenseManager pp     = RS.SenseManager.CreateInstance();
            RS.Device       device = pp.CaptureManager.Device;
            if (device == null)
            {
                pp.Dispose();
            }
            RS.StreamProfileSet profile = new RS.StreamProfileSet();

            for (int s = 0; s < RS.Capture.STREAM_LIMIT; s++)
            {
                RS.StreamType st = RS.Capture.StreamTypeFromIndex(s);
                if (((int)dinfo.streams & (int)st) != 0)
                {
                    int num = device.QueryStreamProfileSetNum(st);
                    for (int p = 0; p < num; p++)
                    {
                        if (device.QueryStreamProfileSet(st, p, out profile) < RS.Status.STATUS_NO_ERROR)
                        {
                            break;
                        }
                        RS.StreamProfile sprofile = profile[st];
                        string           profNime = ProfileToString(sprofile);
                        profiles[profile] = sprofile;
                        cb_Profile.Items.Add(profNime);
                    }
                }
                else if (((int)dinfo.streams & (int)st) == 0)
                {
                }
            }
        }
 private void StreamButton_Click(object sender, EventArgs e)
 {
     RS.StreamType selected_stream = GetSelectedStream();
     if (selected_stream != streams.StreamType)
     {
         streams.StreamType = selected_stream;
     }
 }
 // The SetStreamProfileSet function configures the streams parameters.
 // All streams must be configured. The device streaming starts after a successful configuration.
 private RS.StreamProfileSet GetStreamSetConfiguration()
 {
     RS.StreamProfileSet streamingProfile = new RS.StreamProfileSet();
     for (int s = 0; s < RS.Capture.STREAM_LIMIT; s++)
     {
         RS.StreamType st = RS.Capture.StreamTypeFromIndex(s);
         streamingProfile[st] = GetStreamConfiguration(st);
     }
     return(streamingProfile);
 }
        private RS.StreamProfile GetStreamConfiguration(RS.StreamType st)
        {
            ToolStripMenuItem menu = streamMenue[RS.Capture.StreamTypeToIndex(st)];

            if (menu != null)
            {
                return(GetStreamProfileConfiguration(menu));
            }
            else
            {
                return(new RS.StreamProfile());
            }
        }
        // Check if Radio Buttons and Menu Selection fit
        private void CheckSelection()
        {
            int sumEnabled = 0;

            for (int s = 0; s < RS.Capture.STREAM_LIMIT; s++)
            {
                if (streamButtons[s] != null && streamString[s] != null)
                {
                    streamButtons[s].Enabled = !streamString[s].Checked;
                    sumEnabled += streamButtons[s].Enabled ? 1 : 0;
                }
            }



            RS.StreamType selectedStream = GetSelectedStream();
            if (selectedStream != RS.StreamType.STREAM_TYPE_ANY && !streamButtons[RS.Capture.StreamTypeToIndex(selectedStream)].Enabled)
            {
                RS.StreamType st = GetUnselectedStream();
                streamButtons[RS.Capture.StreamTypeToIndex(st)].Checked = true;
                streams.StreamType = st;
            }
        }
 private void ResetStreamTypes()
 {
     StreamType = RS.StreamType.STREAM_TYPE_ANY;
 }
 public Streams(Manager mngr)
 {
     StreamProfileSet = null;
     StreamType       = RS.StreamType.STREAM_TYPE_ANY;
     manager          = mngr;
 }
Beispiel #9
0
        public void StreamColorDepth() /* Stream Color and Depth Synchronously or Asynchronously */
        {
            try
            {
                bool sts = true;

                /* Create an instance of the RS.SenseManager interface */
                RS.SenseManager sm = RS.SenseManager.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 < RS.Capture.STREAM_LIMIT; s++)
                    {
                        RS.StreamType    st   = RS.Capture.StreamTypeFromIndex(s);
                        RS.StreamProfile info = StreamProfileSet[st];
                        if (info.imageInfo.format != 0)
                        {
                            /* For simple request, you can also use sm.EnableStream(...) */
                            RS.DataDesc desc = new RS.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;
                            desc.receivePartialSample       = true;
                            RS.SampleReader sampleReader = RS.SampleReader.Activate(sm);
                            sampleReader.EnableStreams(desc);
                        }
                    }
                }

                /* Initialization */


                SetStatus("Init Started");
                if (sm.Init() >= RS.Status.STATUS_NO_ERROR)
                {
                    /* Reset all properties */
                    sm.CaptureManager.Device.ResetProperties(RS.StreamType.STREAM_TYPE_ANY);

                    /* Set mirror mode */
                    RS.MirrorMode mirror = Mirror ? RS.MirrorMode.MIRROR_MODE_HORIZONTAL : RS.MirrorMode.MIRROR_MODE_DISABLED;
                    sm.CaptureManager.Device.MirrorMode = mirror;

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

                        /* Display images */
                        RS.Sample sample = sm.Sample;

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

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

                        /* Optional: Set Mirror State */
                        mirror = Mirror ? RS.MirrorMode.MIRROR_MODE_HORIZONTAL : RS.MirrorMode.MIRROR_MODE_DISABLED;
                        if (mirror != sm.CaptureManager.Device.MirrorMode)
                        {
                            sm.CaptureManager.Device.MirrorMode = mirror;
                        }

                        /* Optional: Show performance tick */



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

                sm.Dispose();
                if (sts)
                {
                    SetStatus("Stopped");
                }
            }
            catch (Exception e)
            {
                SetStatus(e.GetType().ToString());
            }
        }
        // Get entries for color Streams
        private void PopulateColorDepthMenus(ToolStripMenuItem device_item)
        {
            RS.ImplDesc desc = new RS.ImplDesc();
            desc.group          = RS.ImplGroup.IMPL_GROUP_SENSOR;
            desc.subgroup       = RS.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;
            desc.iuid           = devices_iuid[device_item];
            current_device_iuid = desc.iuid;
            desc.cuids[0]       = RS.Capture.CUID;

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

            RS.Capture    capture;
            RS.DeviceInfo dinfo2 = GetCheckedDevice();
            if (manager.Session.CreateImpl <RS.Capture>(desc, out capture) >= RS.Status.STATUS_NO_ERROR)
            {
                RS.Device device = capture.CreateDevice(dinfo2.didx);
                if (device != null)
                {
                    RS.StreamProfileSet streamProfileSet = new RS.StreamProfileSet();

                    for (int s = 0; s < RS.Capture.STREAM_LIMIT; s++)
                    {
                        RS.StreamType streamType = RS.Capture.StreamTypeFromIndex(s);
                        if (((int)dinfo2.streams & (int)streamType) != 0 && streamMenue[s] != null)
                        {
                            streamMenue[s].Visible   = true;
                            streamButtons[s].Visible = true;
                            int num = device.QueryStreamProfileSetNum(streamType);
                            for (int p = 0; p < num; p++)
                            {
                                if (device.QueryStreamProfileSet(streamType, p, out streamProfileSet) < RS.Status.STATUS_NO_ERROR)
                                {
                                    break;
                                }
                                RS.StreamProfile  streamProfile = streamProfileSet[streamType];
                                ToolStripMenuItem sm1           = new ToolStripMenuItem(ProfileToString(streamProfile), null, new EventHandler(Stream_Item_Click));
                                profiles[sm1] = streamProfile;
                                streamMenue[s].DropDownItems.Add(sm1);
                            }
                        }
                        else if (((int)dinfo2.streams & (int)streamType) == 0 && streamMenue[s] != null)
                        {
                            streamMenue[s].Visible   = false;
                            streamButtons[s].Visible = false;
                        }
                    }

                    device.Dispose();
                }
                capture.Dispose();
            }
            for (int i = 0; i < RS.Capture.STREAM_LIMIT; i++)
            {
                ToolStripMenuItem menu = streamMenue[i];
                if (menu != null)
                {
                    streamString[i]           = new ToolStripMenuItem("None", null, new EventHandler(Stream_Item_Click));
                    profiles[streamString[i]] = new RS.StreamProfile();
                    menu.DropDownItems.Add(streamString[i]);
                    if (menu == colorMenu)
                    {
                        (menu.DropDownItems[0] as ToolStripMenuItem).Checked = true;
                    }
                    else
                    {
                        streamString[i].Checked = true;
                    }
                }
            }

            CheckSelection();
        }
Beispiel #11
0
 public void ResetStreamTypes()
 {
     StreamType = RS.StreamType.STREAM_TYPE_ANY;
 }