Creating C# application using Hikvision SDK for DS-7116HVI-SL

curiousDev

Young grasshopper
Joined
Aug 16, 2017
Messages
38
Reaction score
2
Hello Adam

You are probably right about it (that it's not a full union anymore).
Can you provide more details where you are going to use it since the sample wasnt so accurate also there was 'using static' which could cause problem when you tried to make instance in main?
If that is not a problem please paste the part from real app where are you using it.

Best regards
curious
 
Joined
Jan 18, 2019
Messages
5
Reaction score
0
Location
UK
Can you provide more details where you are going to use it
Well, I don't have a good answer to your question.

The app (Winforms, VS2015 ) used to be one project and I made a change to the app:
Split the app into two assemblies.
Dynamically load the assembly that contains those structs.
Use reflection to instantiate classes of the loaded assembly.​
In the process of getting types from the loaded assembly, (19) exceptions ware thrown, all of them about the same problem.

Apparently, there are a bunch of structs that aren't defined properly.

For now, I've commented out those structs. The code still compiles and runs successfully (those structs are not referenced by the code).

I haven't mapped all the APIs that use those structs so I don't know what functionality is lost.

The reason I want to fix this and not sweep it under the rug is that I don't know what features I'll need to support in the future.

Also, this file CHCNetSDK.cs is commonly used (I'm hoping), so I would expect other people to encounter this issue. But searching the web yield no results...

Best regards.

Adam.
 

curiousDev

Young grasshopper
Joined
Aug 16, 2017
Messages
38
Reaction score
2
Hey Adam

I did some test and for now I can say I found a solution for it. Tried few things most of them wasnt working at all (ending up with the same error which you came with here).
I noticed that problem is with simple type like uint, int and so on when we try to nest arrays or struct in the same c# 'union'

Code:
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 1, ArraySubType = UnmanagedType.U4)]
public uint[] dwLocalChannel;
In my humble opinion this is more like workaround or even hack but it works.

For testing purposes I used this piece of code:

Code:
NET_DVR_SLAVE_CHANNEL_UNION dvrSlaveChannelUnion = new NET_DVR_SLAVE_CHANNEL_UNION();
uint test = 360789;
byte[] intBytes = BitConverter.GetBytes(test);
byte[] result = intBytes;
dvrSlaveChannelUnion.byRes = result;
dvrSlaveChannelUnion2.struRemoteChannel.byAddress = result;
dvrSlaveChannelUnion2.struRemoteChannel.dwChannel = 123;
uint testConv = dvrSlaveChannelUnion2.dwLocalChannel[0];
//uint testConv = dvrSlaveChannelUnion2.dwLocalChannel[1]; this one will contain 0 (since result is only 4 bytes length)
Best regards
curiousDev
 

pavel63

n3wb
Joined
Feb 5, 2019
Messages
1
Reaction score
0
Location
italy
hello,
i have to decode frames inside the g_RealDataCallBack_V30 to a c# bitmap object converting from pBuffer.
any suggestion?
 

koo9

n3wb
Joined
Feb 26, 2019
Messages
1
Reaction score
0
Location
Canada
Hi mr. Srinivas.
i have problem when preview camera 16 ch in one page on C# cause have Bandwidth so much.
where can i adjust it from program c# ( "public bool StartPlay(Panel PanelName, int PanelNo, int Index" or another place)
and close green box on video preview.
Please help me.
C# SDK from Hikvision.
did you connect directly to the camera or the DVR? I am having trouble displaying the live view but login is fine.
 

NoobNub

n3wb
Joined
Apr 24, 2019
Messages
4
Reaction score
0
Location
Ph
Hi I am so very noob to this. How can I include my sdk? particularly the hikvision sdk?
 
Joined
Jan 18, 2019
Messages
5
Reaction score
0
Location
UK
Hi I am so very noob to this. How can I include my sdk? particularly the hikvision sdk?
I don't know what do you mean by "my SDK", so I explain how I use the SDK.
First I use the SDK to operate an NVR so I'm using the Device Network SDK (for Windows 64-bit).
download the SDK from Hikvision official site download pageSDK - Download - Hikvision
Then I copy the files from the lib directory to my running folder (where my app is run from, usually the bin\debug folder)
make sure to also copy the subfolder HCNetSDKCom, there are important files in it.
Now you can use the SDK by calling functions in the files. see the help at the file "Device Network SDK Programming Manual.chm".
My app is written in C#, so I use the file CHCNetSDK.cs which you can find in one of the demo apps of the SDK C# apps.
this file is very helpful because It defines the functions and structures of the SDK for easy usability.
Also, look in the help and the demo apps for code examples that you can easily cut and paste into your app.
 

NoobNub

n3wb
Joined
Apr 24, 2019
Messages
4
Reaction score
0
Location
Ph
I don't know what do you mean by "my SDK", so I explain how I use the SDK.
First I use the SDK to operate an NVR so I'm using the Device Network SDK (for Windows 64-bit).
download the SDK from Hikvision official site download pageSDK - Download - Hikvision
Then I copy the files from the lib directory to my running folder (where my app is run from, usually the bin\debug folder)
make sure to also copy the subfolder HCNetSDKCom, there are important files in it.
Now you can use the SDK by calling functions in the files. see the help at the file "Device Network SDK Programming Manual.chm".
My app is written in C#, so I use the file CHCNetSDK.cs which you can find in one of the demo apps of the SDK C# apps.
this file is very helpful because It defines the functions and structures of the SDK for easy usability.
Also, look in the help and the demo apps for code examples that you can easily cut and paste into your app.

i hope you don't mind but I always ended up in to error error.png




even though I already added all the files in lib folder here in latest SDK of Hikvision to bin folder of my Project.

copy.png

can you help me what should be the problem in here??
 
Joined
Jan 18, 2019
Messages
5
Reaction score
0
Location
UK
i hope you don't mind but I always ended up in to error View attachment 41983




even though I already added all the files in lib folder here in latest SDK of Hikvision to bin folder of my Project.

View attachment 41984

can you help me what should be the problem in here??
It seems that the file is not located where it should be.
when I run the demo app of the SDK my "running folder" also known as "execution folder" is:

"C:\\Users\\adamg.P-CIM\\Desktop\\VideoAnalyse-master\\NVRCsharpDemo\\bin"

You can see that if you call the static property System.Environment.CurrentDirectory

In the CHCNetSDK.cs file, the external method are declared and the path to the dll is defined:
[DllImport(@"..\bin\HCNetSDK.dll")]
this is a relative path. so you can use the method of GetFullPath to retrive the full path:
Path.GetFullPath(@"..\bin")
in my case the method return :
"C:\\Users\\adamg.P-CIM\\Desktop\\VideoAnalyse-master\\NVRCsharpDemo\\bin"

So if I look in C:\Users\adamg.P-CIM\Desktop\VideoAnalyse-master\NVRCsharpDemo\bin
I can see the files are in there. note that also the directory HCNetSDKCom is there
upload_2019-4-30_14-48-48.png
 

paulkovacs

n3wb
Joined
Oct 7, 2019
Messages
1
Reaction score
0
Location
Romania
Hello. This is my first project with HIKVision NET cameras. Whenever I try to use NET_DVR_GetDeviceConfig it returns 23. I have no idea why. Do you have any suggestions ?

PS: I don't even know if this is the right path to follow. I only need two things :
1 - to change the resolution and the encoding quality.
2 - to detect motion

Many thanks for your help.
 
Joined
Dec 16, 2019
Messages
1
Reaction score
0
Location
Malaysia
hello,
i have to decode frames inside the g_RealDataCallBack_V30 to a c# bitmap object converting from pBuffer.
any suggestion?
Hey guys,

I need help to decode pBuffer too, anyone has idea how to do it? But i need to convert it to JPEG instead.

Thank you
 

eltsov_da

n3wb
Joined
May 18, 2020
Messages
1
Reaction score
0
Location
Russia
Hi guys. I am novice in a hikvison sdk. Please tell me, how you create c# wrappers?
By hands based on CHCNetSDK.cs files in examples or may be exist some Swig interface file or some other technology?
 

NoFate

Getting the hang of it
Joined
Oct 24, 2020
Messages
479
Reaction score
63
Location
Belgium
yeah, gonna try this also, can this SDK also be used to make scripts? for linux/windows so without GUI?
i have downloaded Visual studio community edition, but seems hard to make those scripts? i also need some kind of MFC application?
so i started a new C++ project, attached the HCNet.h header file , but get all kind of errors when compiling/building

whats the correct procedure to start with this?
 
Joined
Oct 7, 2022
Messages
1
Reaction score
0
Location
India
It seems that the file is not located where it should be.
when I run the demo app of the SDK my "running folder" also known as "execution folder" is:

"C:\\Users\\adamg.P-CIM\\Desktop\\VideoAnalyse-master\\NVRCsharpDemo\\bin"

You can see that if you call the static property System.Environment.CurrentDirectory

In the CHCNetSDK.cs file, the external method are declared and the path to the dll is defined:
[DllImport(@"..\bin\HCNetSDK.dll")]
this is a relative path. so you can use the method of GetFullPath to retrive the full path:
Path.GetFullPath(@"..\bin")
in my case the method return :
"C:\\Users\\adamg.P-CIM\\Desktop\\VideoAnalyse-master\\NVRCsharpDemo\\bin"

So if I look in C:\Users\adamg.P-CIM\Desktop\VideoAnalyse-master\NVRCsharpDemo\bin
I can see the files are in there. note that also the directory HCNetSDKCom is there
View attachment 41992
Below is my code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace hikdemo
{
public partial class Preview : System.Windows.Forms.Form
{
private bool m_bInitSDK = false;

CHCNetSDK.REALDATACALLBACK RealData = null;
public CHCNetSDK.NET_DVR_PTZPOS m_struPtzCfg;

/private System.ComponentModel.Container components = null;

public Preview()
{
InitializeComponent();

m_bInitSDK = CHCNetSDK.NET_DVR_Init();
if (m_bInitSDK == false)
{
MessageBox.Show("NET_DVR_Init error!");
return;
}
else
{
/±£´æSDKÈÕÖ¾ To save the SDK log
CHCNetSDK.NET_DVR_SetLogToFile(3, "C:\\SdkLog\\", true);
}
}
}

when i'm running it i'm getting this error:

1665148884430.png

I'm new to this hikvision camera intregation and your reply help me a lot.

Well i'm trying to build a Video wall where i have to Run around 17 Hikvision camera and 6 UNV camera, i used the VLC plugins but the video is blur not satifactory and i'm not able to control it so i'm trying to imporove it by using OEM SDK. any help will be a great.

Regards,
Prashant
 
Top