Video tutorial on how to implement Pan-Tilt-Zoom (PTZ) control function for your camera viewer application in C#
This video demonstrates how you can control your PTZ supported camera in differenct kind of directions and angles in C#. You will see how you can download the Ozeki Camera SDK from the official website. Then how you can integrate the SDK in a Visual Studio solution as a reference. After this video you will know how you can display the image of the USB and IP camera. Moreover you will able to control Pan-Tilt-Zoom (PTZ) functionality.
Download Video: | TutorialVideo5.zip | |
Download source code: | Basic_CameraViewer_5.zip |
DISCLAIMER: Please note that the following features will only work if your IP camera supports the given functionality. So please check the user manual of your IP camera to make sure it supports the feature that you wish to implement in C#.
Transcript
Welcome to the Ozeki Camera SDK video guide tutorial part five. In this chapter We will create a simple project to connect IP camera and we will move the camera in different kind of directions.
This is the 5. video guide from our C# .NET camera tutorial series, in which we present how to use Ozeki Camera SDK to develop different kinds of camera solutions.
This SDK is:
- ONVIF compliant
- Easy to use
- Powerful
Whether you're a beginner or an experienced C# developer you will certainly be able to implement the solutions presented in these tutorial videos, if you use this Camera SDK. This is gonna be a great video series. They contain short and practical code explanations.
This video will be exciting and fun. I hope you will enjoy it.
In this video the main steps are the following
- First step - Download the sdk from the website
- Second step - Create WPF solution in Visual Studio
- Third step - Implementing the camera viewer application
- Fourth step - Extend the application with PTZ control function.
- and finally the Fifth step - Check the result and we try out our application
And let's start now with the step one.
Before we start developing we will need the Ozeki Camera SDK. You can download it from the www.camera-sdk.com. You need to registrate yourself, which means that you must add a name, email address and a reason why you need this SDK. After that you will get the downloading link. The installation is simple, but if you are not sure you can find a description on the Quick Start section of on our website.
First, we have to create a new WPF solution. Click on the New Project and choose the WPF project and give it a name. Click on the OK button. When the project is opened, we have to add the System.Drawing.dll and the OzekiSDK.dll as a reference. When you find the file click on the OK button. We can see them in the reference list.
We will need some control to handle our project. We need 2 groupbox controls, to separate USB camera and IP camera. The USB camera groupbox has 2 buttons to connect and disconnect the camera.
Moreover, the IP camera groupbox has a little bit more control. We'll need 3 textboxes for authentication. We have to give the current IP address, username and password if it is required. We also have to add 2 buttons to connect and disconnect the camera.
Furthermore, we will create a cameraviewer in the CameraBox control. Finally, we create one more groupbox, for the new features that we will implement in the following tutorials. When the controls are ready, I create the buttons click event. And I resize our application.
We have to add 4 namespaces:
- Ozeki.Media.IPCamera
- Ozeki.Media.MediaHandlers.
- Ozeki.Media.MediaHandlers.Video
- and Ozeki.Media.Video.Controls
We need some variables to handle our application. We initialize the mediaconnector and the bitmapsourceprovider in the main constructor. After that we create and set the cameraviewer control and add it to the grid called Camerabox and we have to set the bitmapsourceprovider instance to the videoviewer control.
Finally, we have to write the connect and the disconnect buttons. We will get the default device to our web camera instance and start the viewer and connect our webcamera to the mediaconnector. In the disconnect_usb_camera_click event, we stop the viewer and the web camera. These were the web camera start and stop methods.
Now we implement the connect and the disconnect buttons for the IP camera. We have to know what is the correct IP adress of the camera. We'll probably need an username and a password for the connection. Based on the given data we connect to the selected IP camera. and start the viewer and the IP camera in the connect button click event. In the disconnect_ip_camera_click event, we stop the viewer and the IP camera. These were the IP camera connect and disconnect methods.
Now I extend the xaml code. I will create 2 groupboxes which are will contain the controls. Movement Groupbox. I define 3 rows and 3 columns in the Grid control and I add buttons now to handle the camera movement directions. We need 2 events for buttons. PreviewMouseLeftButtonDown and PreviewMouseLeftButtonUp so the camera will move to the required directions until I release the button. Zoom Groupbox. I add 2 buttons to zoom in and out in the camera view.
And now I create the events of the buttons. I delete the useless rows. I have to add one more namespace: Ozeki.Media.IPCamera.PTZ and now lets start to write the functions code. I will identify the buttons by name. We need a method, which will separate the directions and move the camera to the required way. I stop the movement in the ControlStop event. This event will execute when I release the button.
Now we are ready, let's try out our application. I try to connect one IP camera. I have to give the correct detailed information. Now the camera image appeared and I can now move the camera in different ways. This is an easy way to create a camera viewer and control the camera movement.
I hope you enjoyed the video.
If you liked this video and you want to learn more about further great solutions provided by Ozeki Camera SDK, then download the trial version from our website www.camera-sdk.com and follow our tutorial videos. For more information check out our website, and if you have any questions, send us an email to info@camera-sdk.com.
In the next chapter David will build a camera image recorder application, that can be used to save the camera image in video to the our computer. It is gonna be exciting and useful. Thanks for watching. See you in the next video. Bye.
More information
- Video tutorial on what is ONVIF and what is ONVIF camera
- Video tutorial on how to find your camera on the network in C#
- Video tutorial on how to create a basic camera viewer in C#
- Video tutorial on how to implement taking snapshot function in C#
- Video tutorial on how to PTZ your camera in C#
- Video tutorial on how to record video in C#
- Video tutorial on how to detect the motion in C#
- How to stream the camera image to a mobile in C#
- Video tutorial on how to stream the image of the camera to a website in C#
- Stream camera image during SIP video call in C#