예제 #1
0
 private void Form1_Load(object sender, EventArgs e)
 {
     //ShimmerDevice = new ShimmerSDBT("Shimmer", ComPort, 20.0,0,0,0,4);
     ShimmerDevice = new ShimmerSDBT("Shimmer", ComPort, 20.0, 0, 0, 0, 4);
     //ShimmerDevice = new ShimmerSDBT("Shimmer", ComPort);
     ShimmerDevice.UICallback += this.HandleEvent;
     populateComPorts();
     //sw.StartNew();
 }
예제 #2
0
        private void Main_Load(object sender, EventArgs e)
        {
            _comPort1 = comboBoxComPorts1.Text;
            _comPort2 = comboBoxComPorts2.Text;
            // btsd changes1
            ShimmerDevice1             = new ShimmerSDBT("Shimmer1", _comPort1);
            ShimmerDevice1.UICallback += this.HandleShimmerEvent;
            String[] names1 = SerialPort.GetPortNames();
            foreach (String s in names1)
            {
                comboBoxComPorts1.Items.Add(s);
            }
            comboBoxComPorts1.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
            comboBoxComPorts1.AutoCompleteSource = AutoCompleteSource.ListItems;

            // btsd changes1
            ShimmerDevice2             = new ShimmerSDBT("Shimmer2", _comPort2);
            ShimmerDevice2.UICallback += this.HandleShimmerEvent;
            String[] names2 = SerialPort.GetPortNames();
            foreach (String s in names2)
            {
                comboBoxComPorts2.Items.Add(s);
            }
            comboBoxComPorts2.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
            comboBoxComPorts2.AutoCompleteSource = AutoCompleteSource.ListItems;

            //List all available video sources. (That can be webcams as well as tv cards, etc)
            FilterInfoCollection videosources = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            //Check if atleast one video source is available
            if (videosources != null)
            {
                //For example use first video device. You may check if this is your webcam.
                _videoSource = new VideoCaptureDevice(videosources[0].MonikerString);

                try
                {
                    //Check if the video device provides a list of supported resolutions
                    if (_videoSource.VideoCapabilities.Length > 0)
                    {
                        string highestSolution = "0;0";
                        //Search for the highest resolution
                        for (int i = 0; i < _videoSource.VideoCapabilities.Length; i++)
                        {
                            if (_videoSource.VideoCapabilities[i].FrameSize.Width >
                                Convert.ToInt32(highestSolution.Split(';')[0]))
                            {
                                highestSolution = _videoSource.VideoCapabilities[i].FrameSize.Width.ToString() + ";" +
                                                  i.ToString();
                            }
                        }
                        //Set the highest resolution as active
                        _videoSource.VideoResolution =
                            _videoSource.VideoCapabilities[Convert.ToInt32(highestSolution.Split(';')[1])];
                    }
                }
                catch (Exception exp)
                {
                    throw;
                }

                //Create NewFrame event handler
                //(This one triggers every time a new frame/image is captured
                _videoSource.NewFrame += _videoSource_NewFrame;


                //Start recording
                _videoSource.Start();
            }
        }