mondwan / cpp-surveillance-cli

16 stars 7 forks source link

Cannot make a wrapper for H264_DVR_CatchPicInBuffer function in C# #1

Open leoquan opened 8 years ago

leoquan commented 8 years ago

I want to capture picture from a camera ip chanel to RAM memory. I found H264_DVR_CatchPicInBuffer function in SDK, but i can't use, because i develope by C#. I saw in the Demo code C++ to use H264_DVR_CatchPicInBuffer function as H264_DVR_API bool CALL_METHOD H264_DVR_CatchPicInBuffer(long lLoginID, int nChannel, char pBuffer, int nBufLen, int pPicLen);

I want to create a wrapper in C# like this [DllImport("NetSdk.dll")] public static extern bool H264_DVR_CatchPicInBuffer(int lLoginID, int nChannel, ???, int nBufLen, ref int pPicLen);

Anyone can help me, please..?

mondwan commented 8 years ago

Hello leoquan,

Sorry, I cannot help much on this issue. I have not studied codes from merchant yet....

Maybe you can try to ask for help from the merchant. There is a link in README.

Fox50 commented 6 years ago

Declaration:

[DllImport("NetSdk.dll")]
public static extern bool H264_DVR_CatchPicInBuffer(int lLoginID, int nChannel, byte[] buffer, int nBufLen, ref int pPicLen);

Use in Code:


Byte[] buffImg = new byte[1024 * 1024]; //1 MB;
int picLen = 0;
var res = XMSDK.H264_DVR_CatchPicInBuffer(m_lLogin, m_iChannel, buffImg, buffImg.Length, ref picLen);
Byte[] imgByte = new byte[picLen];
Array.Copy(buffImg, 0, imgByte, 0, picLen);
using (var ms = new MemoryStream(imgByte))
{
    var img = Image.FromStream(ms);
    img.Save(@".\image.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
}