473,406 Members | 2,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Onvif IP camera remote configuration in C#

Hi there,


I couple of weeks ago we have installed a new security IP camera (EasyN 187V). In addition to the basic functionalities, it supports Onvif and it has some special features (PTZ, built-in microphone, night vision, motion detection, alarm notification, etc.).

The long and short of it, this is a smart device, but we need some further functionalities, because my boss travels a lot and he wants more control over the surveillance system. I'm in charge of finding out a solution that enables remote configuration.

I've done some research and I came across a Codeproject guide that informed me that an Onvif-compliant camera SDK would be the most effective solution. (I'm not secure in my knowledge, so I need some confirmation.)

So the point is that I checked out the camera SDK that was recommended by the article, and I found a good Onvif C# example on how to configure the IP camera's network settings.

I thought it's worth to share the code snippet related to this issue, because it can be useful for others as well, so if you'are also interested in the remote configuration, take a look at the code below:

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.Windows.Forms;
  5. using Ozeki.Media.MediaHandlers;
  6. using Ozeki.Media.MediaHandlers.IPCamera;
  7. using Ozeki.Media.MediaHandlers.IPCamera.Types;
  8. using Ozeki.Media.MediaHandlers.Video;
  9. using Ozeki.Media.IPCamera;
  10. using Ozeki.Media.IPCamera.Network;
  11. using Ozeki.Media.Video;
  12. using Ozeki.Media.Video.Controls;
  13.  
  14. namespace ConfigureOnvifCameraRemotely07
  15. {
  16.     public partial class Form1 : Form
  17.     {
  18.         private IIPCamera _camera;
  19.         private DrawingImageProvider _imageProvider;
  20.         private MediaConnector _connector;
  21.         private VideoViewerWF _videoViewerWf;
  22.  
  23.         private List<int> _ports;
  24.  
  25.         public Form1()
  26.         {
  27.             InitializeComponent();
  28.             _ports = new List<int>();
  29.             _connector = new MediaConnector();
  30.             _imageProvider = new DrawingImageProvider();
  31.             _videoViewerWf = new VideoViewerWF();
  32.             SetVideoViewer();
  33.         }
  34.  
  35.         private void SetVideoViewer()
  36.         {
  37.             CameraBox.Controls.Add(_videoViewerWf);
  38.             _videoViewerWf.Size = new Size(260, 180);
  39.             _videoViewerWf.BackColor = Color.Black;
  40.             _videoViewerWf.TabStop = false;
  41.             _videoViewerWf.FlipMode = FlipMode.None;
  42.             _videoViewerWf.Location = new Point(30, 30);
  43.             _videoViewerWf.Name = "_videoViewerWf";
  44.         }
  45.  
  46.         private void button_Connect_Click(object sender, EventArgs e)
  47.         {
  48.             _camera = IPCameraFactory.GetCamera("192.168.115.175:8080", "admin", "admin");
  49.  
  50.             _camera.CameraStateChanged += _camera_CameraStateChanged;
  51.  
  52.             _connector.Connect(_camera.VideoChannel, _imageProvider);
  53.             _videoViewerWf.SetImageProvider(_imageProvider);
  54.             _videoViewerWf.Start();
  55.  
  56.             _camera.Start();
  57.         }
  58.  
  59.         private void _camera_CameraStateChanged(object sender, CameraStateEventArgs e)
  60.         {
  61.             if (e.State == IPCameraState.Streaming)
  62.             {
  63.                 InvokeGuiThread(() => groupBox_Network.Enabled = true);
  64.                 ClearGUI();
  65.                 GetNetworkSettings();
  66.                 if (!_camera.NetworkManager.DefaultConfig.UseDHCP)
  67.                     InvokeGuiThread(() => radioButton_Manual.Checked = true );
  68.             }
  69.         }
  70.  
  71.         private void ClearGUI()
  72.         {
  73.             InvokeGuiThread(() =>
  74.             {
  75.                 textBox_IP.Text = String.Empty;
  76.                 textBox_Host.Text = String.Empty;
  77.                 textBox_Netmask.Text = String.Empty;
  78.                 textBox_Gateway.Text = String.Empty;
  79.                 textBox_DNS.Text = String.Empty;
  80.                 textBox_NTP_IP.Text = String.Empty;
  81.  
  82.                 textBox_HTTP.Text = String.Empty;
  83.                 textBox_HTTPS.Text = String.Empty;
  84.                 textBox_RTSP.Text = String.Empty;
  85.                 comboBox_HTTP.Items.Clear();
  86.                 comboBox_HTTPS.Items.Clear();
  87.                 comboBox_RTSP.Items.Clear();
  88.             });
  89.         }
  90.  
  91.         private void GetNetworkSettings()
  92.         {
  93.             InvokeGuiThread(() =>
  94.             {
  95.                 textBox_IP.Text = _camera.NetworkManager.DefaultConfig.IPAddress;
  96.                 textBox_Host.Text = _camera.NetworkManager.DefaultConfig.HostName;
  97.                 textBox_Netmask.Text = _camera.NetworkManager.DefaultConfig.Netmask;
  98.                 textBox_Gateway.Text = _camera.NetworkManager.DefaultConfig.DefaultGateway;
  99.                 textBox_DNS.Text = _camera.NetworkManager.DefaultConfig.DNS;
  100.                 textBox_NTP_IP.Text = _camera.NetworkManager.DefaultConfig.NTP.IPAddress;
  101.  
  102.                 if (_camera.NetworkManager.HttpPort == null)
  103.                     textBox_HTTP.Enabled = false;
  104.                 else
  105.                 {
  106.                     foreach (var ports in _camera.NetworkManager.HttpPort.Port)
  107.                     {
  108.                         comboBox_HTTP.Items.Add(ports);
  109.                     }
  110.                 }
  111.  
  112.                 if (_camera.NetworkManager.HttpsPort == null)
  113.                     textBox_HTTPS.Enabled = false;
  114.                 else
  115.                 {
  116.                     foreach (var ports in _camera.NetworkManager.HttpsPort.Port)
  117.                     {
  118.                         comboBox_HTTPS.Items.Add(ports);
  119.                     }
  120.                 }
  121.  
  122.                 if (_camera.NetworkManager.RtspPort == null)
  123.                     textBox_RTSP.Enabled = false;
  124.                 else
  125.                 {
  126.                     foreach (var ports in _camera.NetworkManager.RtspPort.Port)
  127.                     {
  128.                         comboBox_RTSP.Items.Add(ports);
  129.                     }
  130.                 }
  131.             });
  132.         }
  133.  
  134.         private void button_Apply_Click(object sender, EventArgs e)
  135.         {
  136.             if (radioButton_DHCP.Checked)
  137.             {
  138.                 _camera.NetworkManager.DefaultConfig.UseDHCP = true;
  139.             }
  140.  
  141.             if (radioButton_Manual.Checked)
  142.             {
  143.                 _camera.NetworkManager.DefaultConfig.UseDHCP = false;
  144.  
  145.                 _camera.NetworkManager.DefaultConfig.IPAddress = textBox_IP.Text;
  146.                 _camera.NetworkManager.DefaultConfig.HostName = textBox_Host.Text;
  147.                 _camera.NetworkManager.DefaultConfig.Netmask = textBox_Netmask.Text;
  148.                 _camera.NetworkManager.DefaultConfig.DefaultGateway = textBox_Gateway.Text;
  149.                 _camera.NetworkManager.DefaultConfig.DNS = textBox_DNS.Text;
  150.  
  151.  
  152.                 if (_camera.NetworkManager.HttpPort != null)
  153.                 {
  154.                     _ports.Clear();
  155.                     foreach (var item in comboBox_HTTP.Items)
  156.                     {
  157.                         var ports = Int32.Parse(item.ToString());
  158.                         _ports.Add(ports);
  159.                     }                 
  160.                     _camera.NetworkManager.HttpPort = new CameraPort(CameraProtocolType.HTTP, true, _ports.ToArray());
  161.                 }
  162.  
  163.                 if (_camera.NetworkManager.HttpsPort != null)
  164.                 {
  165.                     _ports.Clear();
  166.                     foreach (var item in comboBox_HTTPS.Items)
  167.                     {
  168.                         var ports = Int32.Parse(item.ToString());
  169.                         _ports.Add(ports);
  170.                     }
  171.                     _camera.NetworkManager.HttpsPort = new CameraPort(CameraProtocolType.HTTPS, true, _ports.ToArray());
  172.                 }
  173.  
  174.                 if (_camera.NetworkManager.RtspPort != null)
  175.                 {
  176.                     _ports.Clear();
  177.                     foreach (var item in comboBox_RTSP.Items)
  178.                     {
  179.                         var ports = Int32.Parse(item.ToString());
  180.                         _ports.Add(ports);
  181.                     }
  182.                     _camera.NetworkManager.RtspPort = new CameraPort(CameraProtocolType.RTSP, true, _ports.ToArray());
  183.                 }
  184.             }
  185.  
  186.             _camera.NetworkManager.ApplyConfig();
  187.         }
  188.  
  189.         private void button_HTTP_Add_Click(object sender, EventArgs e)
  190.         {
  191.             if (!comboBox_HTTP.Items.Contains(textBox_HTTP.Text))
  192.                 comboBox_HTTP.Items.Add(textBox_HTTP.Text);
  193.         }
  194.  
  195.         private void button_HTTPS_Add_Click(object sender, EventArgs e)
  196.         {
  197.             if (!comboBox_HTTPS.Items.Contains(textBox_HTTPS.Text))
  198.                 comboBox_HTTPS.Items.Add(textBox_HTTPS.Text);
  199.         }
  200.  
  201.         private void button_RTSP_Add_Click(object sender, EventArgs e)
  202.         {
  203.             if (!comboBox_RTSP.Items.Contains(textBox_RTSP.Text))
  204.                 comboBox_RTSP.Items.Add(textBox_RTSP.Text);
  205.         }
  206.  
  207.         private void button_HTTP_Delete_Click(object sender, EventArgs e)
  208.         {
  209.             for (int i = 0; i < comboBox_HTTP.Items.Count; i++)
  210.             {
  211.                 if (comboBox_HTTP.Items[i].ToString() == textBox_HTTP.Text)
  212.                     comboBox_HTTP.Items.Remove(comboBox_HTTP.Items[i]);
  213.             }
  214.         }
  215.  
  216.         private void button_HTTPS_Delete_Click(object sender, EventArgs e)
  217.         {
  218.             for (int i = 0; i < comboBox_HTTPS.Items.Count; i++)
  219.             {
  220.                 if (comboBox_HTTPS.Items[i].ToString() == textBox_HTTPS.Text)
  221.                     comboBox_HTTPS.Items.Remove(comboBox_HTTPS.Items[i]);
  222.             }
  223.         }
  224.  
  225.         private void button_RTSP_Delete_Click(object sender, EventArgs e)
  226.         {
  227.             for (int i = 0; i < comboBox_RTSP.Items.Count; i++)
  228.             {
  229.                 if (comboBox_RTSP.Items[i].ToString() == textBox_RTSP.Text)
  230.                     comboBox_RTSP.Items.Remove(comboBox_RTSP.Items[i]);
  231.             }
  232.         }
  233.  
  234.         private void radioButton_Manual_CheckedChanged(object sender, EventArgs e)
  235.         {
  236.             groupBox_Basic.Enabled = true;
  237.             groupBox_Ports.Enabled = true;
  238.         }
  239.  
  240.         private void radioButton_DHCP_CheckedChanged(object sender, EventArgs e)
  241.         {
  242.             groupBox_Basic.Enabled = false;
  243.             groupBox_Ports.Enabled = false;
  244.         }
  245.  
  246.         private void InvokeGuiThread(Action action)
  247.         {
  248.             BeginInvoke(action);
  249.         }
  250.     }
  251. }
(Source: http://www.camera-sdk.com/p_22-how-t...ely-onvif.html)

It works well, but unfortunately this SDK is not free. Now I use its free trial version, but it will expire soon. Can anybody recommend me an alternative SDK to this one? Or any other C#-based suggestion would be appreciated related to remote IP camera configuration.

I’m looking forward to your answers here! Thank you so much in advance!

All the best,
Curt
Oct 16 '14 #1
0 1626

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Newbie | last post by:
I am doing some robotics projects but my main area of interest is trying out several algorithms for the processing of the stream of data coming from the video. I am wondering what type of camera...
2
by: David Wagner | last post by:
Hi, I am looking at wanting to configure and manage some Performance Monitor logs through a C# application. Specifically, I want to be able to define and configure named performance log...
1
by: Paul Fi | last post by:
I have this problem with .NET remoting: my remote class is called RemoteHandler which implements an interface called IEazyRemoting which has only one method to be implemented which is my server...
2
by: gilberto ramirez | last post by:
I want to create an ASP application in the following way: PC1 - Windows XP (SP1) with VS .NET (and everything needed) - im programming with C# .NET SRV1 - ISA SERVER - Windows 2000 (SP3) SRV2...
3
by: Matthew Louden | last post by:
My ASP.NET application is running without error in my local machine (IIS PWS). However, once I upload all the ASPX files to the remote IIS machine with Windows Server 2003 OS, it no longer works. ...
1
by: IMRAN SAROIA | last post by:
Hi, I am getting message shown below when I tested a simple web application on production Remote Server which has ASP.net enabled for IIS. Please advise! I have tried the resolution...
9
by: RvGrah | last post by:
After much hair-pulling, I've finally found the answer to a problem that many are fighting with, difficulty connecting from Sql 2005 Server Management or VS2005 to a remote Sql Server running Sql...
7
by: Arno R | last post by:
Hi all, I am sending mail from my apps with CDO nowadays. However I have one client where this will not work until now. I am thinking this is related to the provider where the client has his...
0
by: SayamiSuchi | last post by:
Hi, I have made one web application using Asp dot net 2005 and sql server 2005.The sql server i am connecting is the remote sql server..When i run my application in my computer and in LAN, it...
2
by: SayamiSuchi | last post by:
-------------------------------------------------------------------------------- Hi, I have made one web application using Asp dot net 2005 and sql server 2005.The sql server i am connecting is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.