- Quick start
- Download
- Online manual
- Introduction
- Start Onvif programming
- C# Onvif.IP.Camera.Viewer
- C# Onvif IP Camera Viewer Git repository
- IP video camera viewer
- Connect to USB camera
- Connect to RTSP camera
- Connect to ONVIF camera
- Play audio from a camera
- Send audio to a camera
- Query stream parameters
- Resize camera picture
- Mirror the camera picture
- Brightness/Saturation/Contrast
- Control the frame rate
- Setup the white balance
- Backlight compensation
- Change the video resolution
- Concat multiple video source
- PTZ IP camera motion control
- Onvif network video recorder
- Motion detection and alarms
- IP camera to SIP video call
- Configure Onvif IP cam remotely
- Onvif IP camera video server
- Video stream on website
- Onvif Network Video Analytics
- Onvif IP Camera Manager
- Computer Vision Technology
- Motion recognition and analysis
- Object detection
- Object categorization
- Image Manipulation
- Ozeki SDK for Linux
- Community
- Contact
- Product
- Search
- Commercial information
Get started
- Download the SDK
- Copy the C# code example into Visual Studio
- Build your IP Camera project
Did you know?
Did you know, that this SDK was used to build Ozeki Camera Recorder?
If you don't want to write code, it could be just what you need. Download it now from the follolwing page: Download Ozeki Camera Recorder.
How to control the frame rate in C#
In this guide you can find detailed information on how to set the frame rate of your IP camera device. To implement this example, you need to have OZEKI Camera SDK installed, and a reference to OzekiSDK.dll should be added to your Visual Studio project.
How to set the frame rate of an IP camera device using C#?
Windows Form | WPF |
To establish the connection properly between your application and an IP camera you should apply the same code snippet what you have used in the example (How to connect to an IP camera device using C#?). Important: you should study this article in order to find out how to setup your Windows Forms Application correctly.
Getting started
To get started it is recomended to Download and Install the latest version of Ozeki Camera SDK. After installation you can find the example code discussed in this page with full source code in the following location on your harddisk:
Download Ozeki Camera SDK: | http://www.camera-sdk.com/p_13-download-onvif-standard-ozeki-camera-sdk-for-webcam-and-ip-camera-developments-onvif.html |
Windows forms version: | C:\Program Files\Ozeki\Ozeki SDK\examples.zip\Examples\Other\Camera_Viewer_Frame_Rate_WF\Camera_Viewer_Frame_Rate_WF.sln |
To compile this example you will need Microsoft Visual Studio installed on your computer.
The additional statements and methods of this example are the following:
InitializeTrackBar(),
TrackbarPropertiesScroll()
These methods provide the functionality to initialize the value of the trackbar that you can see on
the GUI below, follows all the events belonging to the changes of the camera's attributes and sets the frame rate of the camera
using the trackbar GUI element.
Implement image settings of an IP camera in C#
Form1.cs
using System; using System.Drawing; using System.Windows.Forms; using Ozeki.Media; using Ozeki.Camera; namespace VideoCameraViewer10 { public partial class Form1 : Form { private IIPCamera _camera; private DrawingImageProvider _imageProvider; private MediaConnector _connector; private VideoViewerWF _videoViewerWf; public Form1() { InitializeComponent(); _imageProvider = new DrawingImageProvider(); _connector = new MediaConnector(); _videoViewerWf = new VideoViewerWF(); SetVideoViewer(); } private void SetVideoViewer() { CameraBox.Controls.Add(_videoViewerWf); _videoViewerWf.Size = new Size(260, 180); _videoViewerWf.BackColor = Color.Black; _videoViewerWf.TabStop = false; _videoViewerWf.FlipMode = FlipMode.None; _videoViewerWf.Location = new Point(14, 19); } // Connecting the camera's video channel to the image provider and starting it private void button_Connect_Click(object sender, EventArgs e) { _camera=new IPCamera("192.168.112.109:8080","user","qwe123"); _camera.CameraStateChanged += _camera_CameraStateChanged; _connector.Connect(_camera.VideoChannel, _imageProvider); _videoViewerWf.SetImageProvider(_imageProvider); _videoViewerWf.Start(); _camera.Start(); } private void _camera_CameraStateChanged(object sender, CameraStateEventArgs e) { if (e.State == CameraState.Streaming) { if (_camera.UriType != CameraUriType.RTSP) InitializeTrackBar(); } } private void InitializeTrackBar() { InvokeGuiThread(() => { TrackBarFrameRate.Minimum = 1; TrackBarFrameRate.Maximum = 100; TrackBarFrameRate.Value = (int)_camera.CurrentStream.VideoEncoding.FrameRate; }); } private void InvokeGuiThread(Action action) { BeginInvoke(action); } private void TrackbarPropertiesScroll(object sender, EventArgs e) { if(_camera.CurrentStream.VideoEncoding != null) { _camera.CurrentStream.VideoEncoding.SetAttributes(new IPCameraVideoEncoding { FrameRate = (int)TrackBarFrameRate.Value }); _camera.CurrentStream.VideoEncoding.RefreshProperties(); } } } }
Code 1 - Implement image settings of an IP camera in C#
Please note that none of the cancel and disconnect methods are included in the example because of the demonstrating intent and briefness of the article.
GUI
Figure 1 - The graphical user interface of your application
Finally, please verify what is the maximally allowed frame rate of your IP camera. The example does not check these values so if the provided frame rate is too big it can cause an exception like BadRequest
Below you can find the code that belongs to the interface of the previously presented application. With the help of this section your Windows Forms Application will be able to work properly.
Form1.Designer.cs
namespace VideoCameraViewer10 { partial class Form1 { ////// Required designer variable. /// private System.ComponentModel.IContainer components = null; ////// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code ////// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// #endregion private void InitializeComponent() { this.groupBox1 = new System.Windows.Forms.GroupBox(); this.button_Connect = new System.Windows.Forms.Button(); this.CameraBox = new System.Windows.Forms.GroupBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.TrackBarFrameRate = new System.Windows.Forms.TrackBar(); this.label13 = new System.Windows.Forms.Label(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.TrackBarFrameRate)).BeginInit(); this.SuspendLayout(); // // groupBox1 // this.groupBox1.Controls.Add(this.button_Connect); this.groupBox1.Location = new System.Drawing.Point(10, 10); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(100, 60); this.groupBox1.TabIndex = 0; this.groupBox1.TabStop = false; this.groupBox1.Text = "Connect"; // // button_Connect // this.button_Connect.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); this.button_Connect.ForeColor = System.Drawing.Color.Black; this.button_Connect.Location = new System.Drawing.Point(10, 20); this.button_Connect.Name = "button_Connect"; this.button_Connect.Size = new System.Drawing.Size(80, 23); this.button_Connect.TabIndex = 6; this.button_Connect.Text = "Connect"; this.button_Connect.UseVisualStyleBackColor = true; this.button_Connect.Click += new System.EventHandler(this.button_Connect_Click); // // CameraBox // this.CameraBox.Location = new System.Drawing.Point(10, 85); this.CameraBox.Name = "CameraBox"; this.CameraBox.Size = new System.Drawing.Size(290, 210); this.CameraBox.TabIndex = 3; this.CameraBox.TabStop = false; this.CameraBox.Text = "Live camera "; // // groupBox2 // this.groupBox2.Controls.Add(this.TrackBarFrameRate); this.groupBox2.Controls.Add(this.label13); this.groupBox2.Location = new System.Drawing.Point(10, 300); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(290, 95); this.groupBox2.TabIndex = 7; this.groupBox2.TabStop = false; this.groupBox2.Text = "Image adjustment"; // // TrackBarFrameRate // this.TrackBarFrameRate.Location = new System.Drawing.Point(85, 35); this.TrackBarFrameRate.Name = "TrackBarFrameRate"; this.TrackBarFrameRate.RightToLeftLayout = true; this.TrackBarFrameRate.Size = new System.Drawing.Size(190, 45); this.TrackBarFrameRate.TabIndex = 20; this.TrackBarFrameRate.Scroll += new System.EventHandler(this.TrackbarPropertiesScroll); // // label13 // this.label13.AutoSize = true; this.label13.Location = new System.Drawing.Point(20, 45); this.label13.Name = "label13"; this.label13.Size = new System.Drawing.Size(57, 13); this.label13.TabIndex = 19; this.label13.Text = "Frame rate"; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(309, 404); this.Controls.Add(this.groupBox2); this.Controls.Add(this.CameraBox); this.Controls.Add(this.groupBox1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.Name = "Form1"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "IP Camera Frame Rate Adjustment"; this.groupBox1.ResumeLayout(false); this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.TrackBarFrameRate)).EndInit(); this.ResumeLayout(false); } private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.Button button_Connect; private System.Windows.Forms.GroupBox CameraBox; private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.TrackBar TrackBarFrameRate; private System.Windows.Forms.Label label13; } }
Code 2 - GUI example in C#
DISCLAIMER: Please note that the following features will only work if your IP camera supports the given function. You should check the user manual of your IP camera to make sure it supports the feature that you wish to implement in C#.
Related Pages
FAQ
Below you can find the answers for the most frequently asked questions related to this topic:
-
How can I get the URL of the camera?
You can get the URL from the producer of the camera. (In the 10th tutorial you can find information on how to create an own IP camera discoverer program.)
-
I have not managed to build the solution. How to solve it?
- Please set the Target framework property of the project to .NET 4.0.
- You should add the System.Drawing.dll and OzekiSDK.dll to the references of the solution.
- Please import the missing classes.
-
I tried to give more frame rate value than 24, but it did not work. Why?
Please verify what is the maximally allowed frame rate of your IP camera. The example does not check these values so if the provided frame rate is too big it can cause an exception. In this case you should close the application and start it again.
-
I can not adjust the framerate (the slider is not working).
Some camera types does not support the frame rate adjustment. Make sure that your camera supports it. The example checks your camera and if it finds that the video encoding is not supported, it disables the slider (you can still move it but there will be no changes happening with your viewport.
Home > Online manual > IP video camera viewer > Control the frame rate
Legal |
Privacy |
Terms of use |
6544 54.208.73.179 | 87.229.102.173 | Login |