日期:2014-05-18 浏览次数:20976 次
/// 原始图像数据流捕获(获取YUV420格式数据流) /// <summary> /// 3.5.2.1注册原始图像数据流回调函数RegisterImageStreamCallback /// 说 明: 注册获取原始图像数据流函数,用户可以获取实时的YUV420格式的预览数据 /// int __stdcall RegisterImageStreamCallback (IMAGE_STREAM_CALLBACK ImageStreamCallback,void *context) /// </summary> /// <param name="ImageStreamCallback">原始图像数据流回调函数 </param> /// <param name="context">设备上下文</param> /// <returns>成功返回0;失败返回错误号</returns> [DllImport("DS40xxSDK.dll")] public static extern int RegisterImageStreamCallback(IMAGE_STREAM_CALLBACK ImageStreamCallback, IntPtr context); 开启及停止原始数据流捕获SetImageStream /// 说明: 开启或停止原始图像数据流捕获,此函数依赖主机的处理速度。DS-4000HS只能捕获不大于CIF格式的数据流 /// /// 函 数: int __stdcall SetImageStream(HANDLE hChannel,BOOL bStart,UINT fps, UINT width,UINT height,unsigned char *imageBuffer) /// </summary> /// <param name="hChannel">通道句柄</param> /// <param name="bStart">是否启动捕获</param> /// <param name="fps">帧率</param> /// <param name="width">图像宽度,必须是4CIF宽度的1/8,1/4,1/2或原始大小704</param> /// <param name="height">图象高度,必须是4CIF高度的1/8,1/4,1/2或原始大小576PAL/480NTSC</param> /// <param name="imageBuffer">数据存储缓存</param> /// <returns>成功返回0;失败返回错误号</returns> [DllImport("DS40xxSDK.dll")] public static extern int SetImageStream(IntPtr hChannel, bool bStart, uint fps, uint width, uint height, ref char[] imageBuffer); /// 原始图像流设置 /// typedef void (*IMAGE_STREAM_CALLBACK)(UINT channelNumber,void *context); /// </summary> /// <param name="channelNumber">通道号</param> /// <param name="context">设备上下文</param> [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void IMAGE_STREAM_CALLBACK(uint channelNumber, IntPtr context); //原始图像回调函数 public void H_IMAGE_STREAM_CALLBACK(uint channelNumber, IntPtr context) { MessageBox.Show("ok"+channelNumber); } 程序如下: //原始图像流注册函数 IntPtr p1=HVisionSDK.ChannelOpen(0); //获取了通道句柄 IMAGE_STREAM_CALLBACK H_ISC = new IMAGE_STREAM_CALLBACK(H_IMAGE_STREAM_CALLBACK); int m = HVisionSDK.RegisterImageStreamCallback(H_ISC, this.Handle); char[] imageBuffer=new char[704*576]; int flag = HVisionSDK.SetImageStream(p1, true, 30, 704, 576, ref imageBuffer);//运行完这句。程序就退出。 int flag = HVisionSDK.SetImageStream(p1, false, 30, 704, 576, ref imageBuffer);//将上面这句这样写,程序不会退出。