本文整理汇总了C#中System.Windows.Media.VideoBrush.SetSource方法的典型用法代码示例。如果您正苦于以下问题:C# VideoBrush.SetSource方法的具体用法?C# VideoBrush.SetSource怎么用?C# VideoBrush.SetSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.VideoBrush
的用法示例。
在下文中一共展示了VideoBrush.SetSource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NullSource
public void NullSource ()
{
VideoBrush vb = new VideoBrush ();
Assert.Throws<NullReferenceException> (delegate {
vb.SetSource ((MediaElement) null);
}, "MediaElement");
Assert.Throws<NullReferenceException> (delegate {
vb.SetSource ((CaptureSource) null);
}, "CaptureSource");
}
示例2: OnNavigatedTo
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
// Delayed due to Camera init bug in WP71 SDK Beta 2
// See http://forums.create.msdn.com/forums/p/85830/516843.aspx
Dispatcher.BeginInvoke(() =>
{
// Initialize the webcam
photoCamera = new PhotoCamera();
photoCamera.Initialized += PhotoCameraInitialized;
CameraButtons.ShutterKeyHalfPressed += PhotoCameraButtonHalfPress;
isInitialized = false;
isDetecting = false;
// Fill the Viewport Rectangle with the VideoBrush
var vidBrush = new VideoBrush();
vidBrush.SetSource(photoCamera);
Viewport.Fill = vidBrush;
// Start timer
dispatcherTimer = new DispatcherTimer {Interval = TimeSpan.FromMilliseconds(50)};
dispatcherTimer.Tick += (sender, e1) => Detect();
dispatcherTimer.Start();
});
}
示例3: Load
void Load()
{
if (CaptureDeviceConfiguration.AllowedDeviceAccess ||
CaptureDeviceConfiguration.RequestDeviceAccess())
{
var devices = CaptureDeviceConfiguration.GetAvailableVideoCaptureDevices();
foreach (var device in devices)
{
var videoItem = new VideoItem();
videoItem.Name = device.FriendlyName;
var source = new CaptureSource();
source.VideoCaptureDevice = device;
var videoBrush = new VideoBrush();
videoBrush.SetSource(source);
videoItem.Brush = videoBrush;
this.sources.Add(source);
this.sourceItems.Add(videoItem);
}
this.videoItems.ItemsSource = this.sourceItems;
this.StartAll();
}
}
示例4: StartWebCam
public void StartWebCam()
{
_captureSource = new CaptureSource();
_captureSource.CaptureImageCompleted += new EventHandler<CaptureImageCompletedEventArgs>(_captureSource_CaptureImageCompleted);
_captureSource.VideoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();
try
{
// Start capturing
if (_captureSource.State != CaptureState.Started)
{
// Create video brush and fill the WebcamVideo rectangle with it
var vidBrush = new VideoBrush();
vidBrush.Stretch = Stretch.Uniform;
vidBrush.SetSource(_captureSource);
WebcamVideo.Fill = vidBrush;
// Ask user for permission and start the capturing
if (CaptureDeviceConfiguration.RequestDeviceAccess())
{
_captureSource.Start();
}
}
}
catch (InvalidOperationException)
{
InfoTextBox.Text = "Web Cam already started - if not, I can't find it...";
}
catch (Exception)
{
InfoTextBox.Text = "Could not start web cam, do you have one?";
}
}
示例5: MainPage_Loaded
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
captureSource = new CaptureSource
{
VideoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice()
};
var videoBrush = new VideoBrush();
videoBrush.SetSource(captureSource);
Viewport.Fill = videoBrush;
markerDetector = new CaptureSourceMarkerDetector();
var marker = Marker.LoadFromResource("Bola.pat", 64, 64, 80);
markerDetector.Initialize(captureSource, 1d, 4000d, marker);
markerDetector.MarkersDetected += (obj, args) =>
{
Dispatcher.BeginInvoke(() =>
{
var results = args.DetectionResults;
if (results.HasResults)
{
var centerAtOrigin =
Matrix3DFactory.
CreateTranslation(
-Imagem.ActualWidth*
0.5,
-Imagem.
ActualHeight*
0.5, 0);
var scale =
Matrix3DFactory.CreateScale
(0.5, -0.5, 0.5);
var world = centerAtOrigin*
scale*
results[0].
Transformation;
var vp =
Matrix3DFactory.
CreateViewportTransformation
(Viewport.ActualWidth,
Viewport.ActualHeight);
var m =
Matrix3DFactory.
CreateViewportProjection
(world,
Matrix3D.Identity,
markerDetector.
Projection, vp);
Imagem.Projection =
new Matrix3DProjection
{ProjectionMatrix = m};
}
});
};
}
示例6: UserControl_Loaded
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
// Initialize the webcam
captureSource = new CaptureSource();
captureSource.VideoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();
// Fill the Viewport Rectangle with the VideoBrush
var vidBrush = new VideoBrush();
vidBrush.SetSource(captureSource);
Viewport.Fill = vidBrush;
}
示例7: MainPage
// Constructor
public MainPage()
{
InitializeComponent();
c = new CaptureSource();
c.VideoCaptureDevice = CaptureDeviceConfiguration.GetAvailableVideoCaptureDevices().First();
var vidBrush = new VideoBrush();
vidBrush.SetSource(c);
ViewPort.Fill = vidBrush;
}
示例8: LoadCamera
public void LoadCamera(ICameraCaptureDevice camera)
{
if (VideoBrush == null && camera != null)
{
RunOnUIThread(() =>
{
VideoBrush = new VideoBrush();
VideoBrush.Stretch = Stretch.Uniform;
VideoBrush.SetSource(camera);
Rectangle.Fill = VideoBrush;
});
}
}
示例9: ConnectWebcamToDevice
private void ConnectWebcamToDevice()
{
if (!CaptureDeviceConfiguration.AllowedDeviceAccess)
{
if(!CaptureDeviceConfiguration.RequestDeviceAccess())
return;
}
_cam.VideoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();
var brush = new VideoBrush {Stretch = Stretch.Uniform};
brush.SetSource(_cam);
CamDisplay.Fill = brush;
}
示例10: GetVideoBrush
/// <summary>
/// 获得VideoBrush对象
/// </summary>
/// <returns></returns>
public VideoBrush GetVideoBrush()
{
VideoBrush vBrush = new VideoBrush();
if (_vcDevice != null)
{
_cSource.VideoCaptureDevice = _vcDevice;
vBrush.SetSource(_cSource);//注意,不能在这里直接开启摄像头,必须等到所有设置准备就绪
}
else
{
Console.WriteLine("尚未找到捕捉设备!请确保设备正确安装!");
}
return vBrush;
}
示例11: InitializeVideoRecorder
public void InitializeVideoRecorder()
{
try
{
//fileName = string.Format(@"\Purposecode\Video{0}.mp4", DateTime.Now.ToString("yyyyMMddHHmmss"));
fileName = string.Format("Video{0}.mp4", DateTime.Now.ToString("yyyyMMddHHmmss"));
if (captureSource == null)
{
// Create the VideoRecorder objects.
captureSource = new CaptureSource();
fileSink = new FileSink();
videoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();
// Add eventhandlers for captureSource.
captureSource.CaptureFailed += new EventHandler<ExceptionRoutedEventArgs>(OnCaptureFailed);
// Initialize the camera if it exists on the device.
if (videoCaptureDevice != null)
{
// Create the VideoBrush for the viewfinder.
videoRecorderBrush = new VideoBrush();
videoRecorderBrush.SetSource(captureSource);
// Display the viewfinder image on the rectangle.
viewfinderRectangle.Fill = videoRecorderBrush;
StopPlaybackRecording.IsEnabled = false;
// Start video capture and display it on the viewfinder.
captureSource.Start();
// Set the button state and the message.
UpdateUI(ButtonState.Initialized, "Tap record to start recording...");
}
else
{
// Disable buttons when the camera is not supported by the device.
UpdateUI(ButtonState.CameraNotSupported, "Camera is not supported..");
}
}
}
catch (Exception ex)
{
var test = ex.Message;
}
} //InitializeVideoRecorder()
示例12: StartRecordig
private void StartRecordig()
{
if (m_captureSource == null)
{
m_captureSource = new CaptureSource();
m_captureSource.VideoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();
m_captureSource.AudioCaptureDevice = CaptureDeviceConfiguration.GetDefaultAudioCaptureDevice();
m_sink = new FileSink();
m_sink.CaptureSource = m_captureSource;
m_sink.IsolatedStorageFileName = m_capturedFileName;
}
VideoBrush brush = new VideoBrush();
brush.SetSource(m_captureSource);
CameraPreview.Fill = brush;
m_captureSource.Start();
}
示例13: StartCapture_Click
private void StartCapture_Click(object sender, RoutedEventArgs e)
{
_captureSource.VideoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();
_captureSource.AudioCaptureDevice = CaptureDeviceConfiguration.GetDefaultAudioCaptureDevice();
VideoBrush videoBrush = new VideoBrush();
videoBrush.Stretch = Stretch.Uniform;
videoBrush.SetSource(_captureSource);
_videoStream = new MemoryStream();
RiffAviFileWriter aviFileWriter = new RiffAviFileWriter(_videoStream);
_videoSink = new BufferQueueVideoSink(aviFileWriter)
{
CaptureSource = _captureSource
};
if (CaptureDeviceConfiguration.AllowedDeviceAccess || CaptureDeviceConfiguration.RequestDeviceAccess())
_captureSource.Start();
Video.Fill = videoBrush;
}
示例14: displayPreview
public void displayPreview(String camName, Rectangle videoPanel)
{
// create a new VideoBrush
videoBrush = null;
videoBrush = new VideoBrush();
videoBrush.Stretch = Stretch.Uniform;
// connect the new VideoBrush to the new device
foreach (Webcam wc in webcams)
{
if (wc.toString().Equals(camName))
{
videoBrush.SetSource(wc.getSrc()());
break;
}
}
// connect the VideoPanel to the new VideoBrush
videoPanel.Fill = videoBrush;
}
示例15: InitializeVideoRecorder
private void InitializeVideoRecorder()
{
if (_captureSource == null)
{
_captureSource = new CaptureSource();
_fileSink = new FileSink();
_videoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();
_captureSource.CaptureFailed += OnCaptureSourceOnCaptureFailed;
_captureSource.CaptureImageCompleted += CaptureSourceOnCaptureImageCompleted;
if (_videoCaptureDevice != null)
{
_videoBrush = new VideoBrush();
_videoBrush.SetSource(_captureSource);
ViewFinderRectangle.Fill = _videoBrush;
_captureSource.Start();
}
}
}