Beispiel #1
0
        private void InitializeCamera()
        {
            // すべてのキャプチャデバイスを取得
            VideoCapture capture = new VideoCapture();
            List<CaptureDevice> devices = capture.Devices;

            if (devices != null)
            {
                int selected = 0;
                if (devices.Count > 1)
                {
                    var names = from c in devices
                                select c.Name;
                    var form = new CameraSelectorForm(names.ToArray());
                    form.ShowDialog();
                    selected = form.SelectedIndex;
                }
                camera = devices[selected];
                camera.Activate();
                bmp = new Bitmap(camera.DeviceWidth, camera.DeviceHeight);
                this.Text = camera.Name;
            }
            else
            {
                MessageBox.Show("キャプチャデバイスが見つかりませんでした", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(-1);
            }
        }
        /// <summary>
        /// �R���X�g���N�^
        /// </summary>
        /// <param name="name">�J�����f�o�C�X��/param>
        public CaptureCamera(String name)
        {
            ArrayList devs = GetDevices();
            ArrayList list = GetDeviceNames();

            int index = list.IndexOf(name);
            dev = new JUNKBOX.IO.CaptureDevice((DsDevice)devs[index]);
        }
 /// <summary>
 /// �R���X�g���N�^
 /// </summary>
 /// <param name="index">�J�����f�o�C�X�̈ꗗ�̃C���f�b�N�X</param>
 public CaptureCamera(int index)
 {
     ArrayList devs = GetDevices();
     dev = new JUNKBOX.IO.CaptureDevice((DsDevice)devs[index]);
 }
Beispiel #4
0
        /// <summary>
        /// キャプチャデバイスの列挙
        /// </summary>
        private List<CaptureDevice> FindDevices()
        {
            //DirectX ver 8.1以上が正常にインストールされているか?
            if (!DsUtils.IsCorrectDirectXVersion())
            {
                MessageBox.Show("アプリケーションの動作にはDirectX ver 8.1以上が必要です.");
                return null;
            }

            //PCに接続されているキャプチャデバイス(USBカメラなど)のリストを取得.
            ArrayList captureDevices;
            if (!DsDev.GetDevicesOfCat(FilterCategory.VideoInputDevice, out captureDevices))
            {
                MessageBox.Show("ビデオキャプチャ可能なデバイスが見つかりません");
                return null;
            }

            List<CaptureDevice> devices = new List<CaptureDevice>();

            // デバイスを列挙
            foreach (DsDevice device in captureDevices)
            {
                if (device != null)
                {
                    CaptureDevice cap = new CaptureDevice(device);
                    devices.Add(cap);
                }
            }
            if (devices.Count == 0) return null;

            return devices;
        }