Silverlight调用摄像头

 CaptureSource source = new CaptureSource();
        private void UserControl_Loaded_1(object sender, RoutedEventArgs e)
        {
            VideoCaptureDevice vcd;
            //话筒就换成这个类 AudioCaptureDevice 
            vcd = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();

            source.VideoCaptureDevice = vcd;

            VideoBrush video = new VideoBrush();
            video.SetSource(source);
            rectangle1.Fill = video;

            //截图的回调 
            source.CaptureImageCompleted += new EventHandler(source_CaptureImageCompleted);
        }
      
        //截图调用 source.CaptureImageAsync(); 
        void source_CaptureImageCompleted(object sender, CaptureImageCompletedEventArgs e)
        {
            WriteableBitmap img = e.Result;
        }
       
        //此处开始启动
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            if (CaptureDeviceConfiguration.AllowedDeviceAccess || CaptureDeviceConfiguration.RequestDeviceAccess())
            {
                //启动摄像头 /麦克风以及其他操作 
                source.Start();
            }
        }

你可能感兴趣的:(Silverlight)