Foxtable(狐表)用户栏目专家坐堂 → 海康抓图


  共有2539人关注过本帖树形打印复制链接

主题:海康抓图

帅哥哟,离线,有人找我吗?
aidimeng
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:798 积分:7677 威望:0 精华:0 注册:2015/9/14 14:26:00
海康抓图  发帖心情 Post By:2019/4/29 10:46:00 [显示全部帖子]

c#的调用语句

 

private void btnJPEG_Click(object sender, EventArgs e)
        {
            int lChannel = iChannelNum[(int)iSelIndex]; //通道号 Channel number

            CHCNetSDK.NET_DVR_JPEGPARA lpJpegPara = new CHCNetSDK.NET_DVR_JPEGPARA();
            lpJpegPara.wPicQuality = 0; //图像质量 Image quality
            lpJpegPara.wPicSize = 0xff; //抓图分辨率 Picture size: 0xff-Auto(使用当前码流分辨率)
            //抓图分辨率需要设备支持,更多取值请参考SDK文档

            //JPEG抓图保存成文件 Capture a JPEG picture
            string sJpegPicFileName;
            sJpegPicFileName = "filetest.jpg";//图片保存路径和文件名 the path and file name to save

            if (!CHCNetSDK.NET_DVR_CaptureJPEGPicture(m_lUserID, lChannel, ref lpJpegPara, sJpegPicFileName))
            {
                iLastErr = CHCNetSDK.NET_DVR_GetLastError();
                str = "NET_DVR_CaptureJPEGPicture failed, error code= " + iLastErr;
                DebugInfo(str);
                return;
            }
            else
            {
                str = "NET_DVR_CaptureJPEGPicture succ and the saved file is " + sJpegPicFileName;
                DebugInfo(str);
            }

            //JEPG抓图,数据保存在缓冲区中 Capture a JPEG picture and save in the buffer
            uint iBuffSize = 400000; //缓冲区大小需要不小于一张图片数据的大小 The buffer size should not be less than the picture size
            byte[] byJpegPicBuffer = new byte[iBuffSize];
            uint dwSizeReturned = 0;

            if (!CHCNetSDK.NET_DVR_CaptureJPEGPicture_NEW(m_lUserID, lChannel, ref lpJpegPara, byJpegPicBuffer, iBuffSize, ref dwSizeReturned))
            {
                iLastErr = CHCNetSDK.NET_DVR_GetLastError();
                str = "NET_DVR_CaptureJPEGPicture_NEW failed, error code= " + iLastErr;
                DebugInfo(str);
                return;
            }
            else
            {
                //将缓冲区里的JPEG图片数据写入文件 save the data into a file
                string str = "buffertest.jpg";
                FileStream fs = new FileStream(str, FileMode.Create);
                int iLen = (int)dwSizeReturned;
                fs.Write(byJpegPicBuffer, 0, iLen);
                fs.Close();

                str = "NET_DVR_CaptureJPEGPicture_NEW succ and save the data in buffer to 'buffertest.jpg'.";
                DebugInfo(str);
            }

            return;
        }

 

以下是转换的

 

Dim lChannel As Integer = iChannelNum(CInt(iSelIndex))
    Dim lpJpegPara As CHCNetSDK.NET_DVR_JPEGPARA = New CHCNetSDK.NET_DVR_JPEGPARA()
    lpJpegPara.wPicQuality = 0
    lpJpegPara.wPicSize = &HfF
    Dim sJpegPicFileName As String
    sJpegPicFileName = "filetest.jpg"

    If Not CHCNetSDK.NET_DVR_CaptureJPEGPicture(m_lUserID, lChannel, lpJpegPara, sJpegPicFileName) Then
        iLastErr = CHCNetSDK.NET_DVR_GetLastError()
        str = "NET_DVR_CaptureJPEGPicture failed, error code= " & iLastErr
        DebugInfo(str)
        Return
    Else
        str = "NET_DVR_CaptureJPEGPicture succ and the saved file is " & sJpegPicFileName
        DebugInfo(str)
    End If

    Dim iBuffSize As UInteger = 400000
    Dim byJpegPicBuffer As Byte() = New Byte(iBuffSize - 1) {}
    Dim dwSizeReturned As UInteger = 0

    If Not CHCNetSDK.NET_DVR_CaptureJPEGPicture_NEW(m_lUserID, lChannel, lpJpegPara, byJpegPicBuffer, iBuffSize, dwSizeReturned) Then
        iLastErr = CHCNetSDK.NET_DVR_GetLastError()
        str = "NET_DVR_CaptureJPEGPicture_NEW failed, error code= " & iLastErr
        DebugInfo(str)
        Return
    Else
        Dim str As String = "buffertest.jpg"
        Dim fs As FileStream = New FileStream(str, FileMode.Create)
        Dim iLen As Integer = CInt(dwSizeReturned)
        fs.Write(byJpegPicBuffer, 0, iLen)
        fs.Close()
        str = "NET_DVR_CaptureJPEGPicture_NEW succ and save the data in buffer to 'buffertest.jpg'."
        DebugInfo(str)
    End If

 

各种报错,引用方面没事,我能处理。应该怎么修改才能正常使用啊


 回到顶部
帅哥哟,离线,有人找我吗?
aidimeng
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:798 积分:7677 威望:0 精华:0 注册:2015/9/14 14:26:00
  发帖心情 Post By:2019/4/29 12:47:00 [显示全部帖子]

比如  

iLastErr = CHCNetSDK.NET_DVR_GetLastError()

转换前后没什么变化,系统会报错  ilasterr 未声明

 

 

 Dim iBuffSize As UInteger = 400000
    Dim byJpegPicBuffer As Byte() = New Byte(iBuffSize - 1) {}
    Dim dwSizeReturned As UInteger = 0

    If Not CHCNetSDK.NET_DVR_CaptureJPEGPicture_NEW(m_lUserID, lChannel, lpJpegPara, byJpegPicBuffer, iBuffSize, dwSizeReturned) Then

提示一维数组不能转换成string

[此贴子已经被作者于2019/4/29 12:50:07编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
aidimeng
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:798 积分:7677 威望:0 精华:0 注册:2015/9/14 14:26:00
  发帖心情 Post By:2019/4/29 13:47:00 [显示全部帖子]

好像不是前缀的问题

 


图片点击可在新窗口打开查看此主题相关图片如下:qq截图20190429134356.jpg
图片点击可在新窗口打开查看

 回到顶部