Escolar Documentos
Profissional Documentos
Cultura Documentos
How to implement
CAMERA RECORDING
for USB WEBCAM or IP CAMERA in C#.NET
Welcome to this presentation that explains step-by-step how to develop video
recording feature for your USB webcam and your IP camera / ONVIF IP camera in
C#.NET to be able to capture and save the camera image. Good luck, have fun!
SOURCE CODE:
www.camera-sdk.com
Contents
Prerequisites
Creating a WPF project in Visual Studio
Building a camera viewer
Implementing the video recorder feature
Testing the application
SOURCE CODE:
2 / 17
www.camera-sdk.com
Prerequisites
Windows PC
Broadband Internet connection
USB webcam or IP camera connected to your network
Microsoft Visual Studio + .NET Framework 4.0
OZEKI Camera SDK
Note: Make sure that you have stable Internet connection, and your PC and the camera is connected
to the same network. If it is needed, download and install the IDE and the .NET Framework from
www.microsoft.com and the camera SDK from www.camera-sdk.com, too.
3 / 17
4 / 17
HorizontalAlignment="Left" VerticalAlignment="Top"
Click="DisconnectUSBCamera_Click"/>
</Grid>
</GroupBox>
5 / 17
6 / 17
After you have created the GUI elements that allow the user to be able to connect to a USB or an
IP camera, you need to build a camera box to be able to display the camera image in the GUI:
<Grid Name="CameraBox" Margin="10,105,10,166"/>
7 / 17
Ozeki.Media.IPCamera;
Ozeki.Media.MediaHandlers;
Ozeki.Media.MediaHandlers.Video;
Ozeki.Media.Video.Controls;
After this, you need to add some objects that are needed for displaying the camera image:
private VideoViewerWPF _videoViewerWpf;
private BitmapSourceProvider _provider;
private IIPCamera _ipCamera;
private WebCamera _webCamera;
private MediaConnector _connector;
8 / 17
Create the SetVideoViewer() helpfunction that creates and sets the videoviewer object and add it to the GUI:
private void SetVideoViewer()
{
_videoViewerWpf = new VideoViewerWPF
{
HorizontalAlignment = HorizontalAlignment.Stretch,
VerticalAlignment = VerticalAlignment.Stretch,
Background = Brushes.Black
};
CameraBox.Children.Add(_videoViewerWpf);
_videoViewerWpf.SetImageProvider(_provider);
}
9 / 17
10 / 17
11 / 17
12 / 17
You need to instantiate them at USB webcam connection and IP camera connection as well by
inserting both of the following lines:
Into the USB camera connection section:
_videoSender = _webCamera;
_videoSender = _ipCamera.VideoChannel;
13 / 17
14 / 17
15 / 17
16 / 17
www.camera-sdk.com
or send us an e-mail to:
info@camera-sdk.com
SOURCE CODE:
www.camera-sdk.com