Esempio n. 1
0
        public void Connect(Control control, UpnpCaptureDriver device)
        {
            _currentDevice = device;
            _deviceHandle  = capCreateCaptureWindow(_currentDevice.DeviceIndex.ToString(),
                                                    WsVisible | WsChild,
                                                    0, 0,
                                                    GetControlWidth(control),
                                                    GetControlHeight(control),
                                                    GetControlHandle(control), 0);

            if (SendMessage(_deviceHandle, WmCapDriverConnect, _currentDevice.DeviceIndex, 0) <= 0)
            {
                DestroyWindow(_deviceHandle);
            }
            //set the preview scale
            SendMessage(_deviceHandle, WmCapSetScale, 1, 0);
            //set the preview rate (ms)
            SendMessage(_deviceHandle, WmCapSetPreviewrate, 30, 0);
            //start previewing the image
            SendMessage(_deviceHandle, WmCapSetPreview, 1, 0);

            //resize window to fit in PictureBox control
            SetWindowPos(_deviceHandle, 1, 0, 0,
                         GetControlWidth(control),
                         GetControlHeight(control), (2 | 4));
        }
Esempio n. 2
0
        public Camera()
        {
            //Get device details using the interlop and add each device to the devices list.
            for (byte i = 0; i < _devices.Capacity; i++)
            {
                string deviceName    = null;
                string deviceVersion = null;

                if (!capGetDriverDescription(i, ref deviceName, 80, ref deviceVersion, 80))
                {
                    continue;
                }

                UpnpCaptureDriver device = new UpnpCaptureDriver
                {
                    DeviceIndex = i,
                    Name        = deviceName,
                    Version     = deviceVersion
                };
                _devices.Add(device);
            }
        }