这几天一直在做海康摄像头的个人开发,是遇到各种问题啊,弄得头都大了根据ip地址,端口等的登录以及开启摄像头进行监控已经实现,现在想实现5次连续延迟抓拍功能,希望各位大神给点参考,
可能很简单,但是现在脑子中一团浆糊,昨晚加班加点完成上述两个功能,今天有点迷糊,所以希望大家说的通俗易懂点,谢谢了首先我的数据库中保存有摄像头的配置信息,ip地址,端口,子网,网关,用户名密码,以及5个延迟时间(mm)100,200,300,400,500本来的功能是根据rfid采集器采集到的long类型的id,现在想先实现点击按钮之后进行抓拍
得到图像以及保存到本地的代码已经完成,这些代码之前的时间之间的判断希望那个大家帮个忙        private void btnJpegCapture_Click(object sender, EventArgs e)
        {
            //四个参数ip,端口,用户名,密码
            int ip=Base.iptoint(this.txtIP.Text);
            int ipport=int.Parse(this.txtIPPort.Text);
            string username=this.txtUserName.Text;
            string userpass=this.txtUserPass.Text;
            //数据库中符合本参数的数据
            tbx_shexiangtou tou=PicManage.GetTouByInfo(ip,ipport,username,userpass);
            
            //tou.yanshi1-----第一个延时时间(mm)
            //tou.yanshi2-----第二个延时时间(mm)
            //tou.yanshi3-----第三个延时时间(mm)
            //tou.yanshi4-----第四个延时时间(mm)
            //tou.yanshi5-----第五个延时时间(mm)            m_bJpegCapture = true;  
            IntPtr ptrJpeg = new IntPtr();
            uint nBuffersize =2 * 1024 * 1024;
            ptrJpeg = Marshal.AllocHGlobal((int)nBuffersize);
            uint dwJpegSize = 0;
            
            if (PlayCtrl.PlayM4_GetJPEG(m_lPort, ptrJpeg, nBuffersize, ref dwJpegSize))
            {
                DebugInfo("PlayM4_GetJPEG succ");
            }
            else
            {
                uint dwErrorNo = PlayCtrl.PlayM4_GetLastError(m_lPort);
                DebugInfo("PlayM4_GetJPEG fail");
            }
            FileStream fs = new FileStream("C:/GetJpegSave.jpg", FileMode.Create);
            byte[] by = new byte[dwJpegSize];
            Marshal.Copy(ptrJpeg, by, 0, (int)dwJpegSize);
            fs.Write(by, 0, (int)dwJpegSize);
            fs.Close();            Marshal.FreeHGlobal(ptrJpeg);
        }希望各位能帮助我一下

解决方案 »

  1.   

    这个你另外开线程搞,把时间间隔放入Queue 队列里线程里执行完,去弹出队列里的时间设置,根据时间去设置线程休眠就ok了
      

  2.   


    我试过了,可是其中用到的摄像头自带的dll中貌似不支持自定义呢??其实我也不知道怎么回事,反正开了之后就是不管用,只能在那段代码之上搞了,你还有什么好方法么?