最新消息: USBMI致力于为网友们分享Windows、安卓、IOS等主流手机系统相关的资讯以及评测、同时提供相关教程、应用、软件下载等服务。

图像采集---摄像头取像程序

IT圈 admin 35浏览 0评论

2024年2月17日发(作者:咸映秋)

class WebCamera {

public delegate void RecievedFrameEventHandler(byte[] data); public event RecievedFrameEventHandler RecievedFrame; public IntPtr IwndC; public IntPtr mControlPtr; public int mWidth; public int mHeight; public ventHandler mFrameEventHandler; public void FrameCallBack(IntPtr Iwnd, IntPtr lpVHdr) { DR videoHeader = new DR(); byte[] VideoData; videoHeader = (DR)ucture(lpVHdr, videoHeader); VideoData=new byte[sUsed]; (, VideoData); if (edFrame != null) { edFrame(VideoData); } } public WebCamera(IntPtr handle, int width, int height) { mControlPtr = handle; mWidth = width; mHeight = height; } public void StartWebCam()

{ byte[] abc = new byte[32]; abc[0] = (byte)'u'; abc[1] = (byte)'s'; abc[2] = (byte)'b'; abc[3] = (byte)'C'; abc[4] = (byte)'a'; abc[5] = (byte)'m'; for (int i = 6; i < 32; i++) { abc[i] = (byte)'0'; }

public delegate void FrameEventHandler(IntPtr Iwnd, IntPtr lpVHdr); public static object GetStructure(IntPtr ptr, ValueType structure) { return tructure(ptr, e()); } public static object GetStructure(int ptr, ValueType structure) { return GetStructure(new IntPtr(ptr), structure); } public static void Copy(IntPtr ptr, byte[] data) { (ptr, data, 0, ); } public static void Copy(int ptr, byte[] data) { Copy(new IntPtr(ptr), data); } public static int SizeOf(object structer) { unsafe { return (structer); } } [DllImport("")] public static extern IntPtr capCreateCaptureWindowA(byte[] lpszWindowName, int dwStyle, int x, int y, int nwidth, int nheight, IntPtr hWndParent, int nID); [DllImport("")] public static extern bool SendMessage(IntPtr hWnd, int wMsg, short WParam, int LParam); [DllImport("")] public static extern bool SendMessage(IntPtr hWnd, int wMsg, bool WParam, int LParam); [DllImport("")] public static extern bool SendMessage(IntPtr hWnd,int wMsg,short WParam,FrameEventHandler LParam); [DllImport("")] public static extern bool SendMessage(IntPtr hWnd, int wMsg, int WParam, ref BITMAPINFO LParam); [DllImport("")] public static extern bool SendMessage(IntPtr hWnd, int wMsg, int WParam, ref CAPDRIVERCAPS LParam); [DllImport("")] public static extern bool SendMessage(IntPtr hWnd, int wMsg, int WParam, ref CAPTUREPARMS LParam); [DllImport("")] public static extern bool SendMessage(IntPtr hWnd, int wMsg, int WParam, ref CAPSTATUS LParam); [DllImport("")] public static extern int SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int y, int cx, int cy, int wFlags); [DllImport("")] public static extern int capGetVideoFormat(IntPtr hWnd, IntPtr psVideoFormat, int wSize); public const int WM_CAP_SINGLE_FRAME_OPEN = WM_USER + 70; public const int WM_CAP_SINGLE_FRAME_CLOSE = WM_USER + 71; public const int WM_CAP_SINGLE_FRAME=WM_USER+72; public const int WM_CAP_EDIT_COPY = (WM_USER + 30);

//[DllImport("")] //public static extern bool EmptyClipboard(); //[DllImport("")] //public static extern bool CloseClipboard(); //[DllImport("")] //public static extern bool OpenClipboard(IntPtr hWnd); //[DllImport("")] //public static extern bool IsClipboardFormatAvailable(uint format); //[DllImport("")] //public static extern IntPtr GetClipboardData(uint uFormat); //[DllImport("")] //public static extern IntPtr GlobalLock(IntPtr handle); //[DllImport("")] //public static extern bool GlobalUnlock(IntPtr handle); //[DllImport("")] //public static extern bool CloseClipboard();

[StructLayout(tial)] public struct VIDEOHDR { [MarshalAs(UnmanagedType.I4)] public int lpData; [MarshalAs(UnmanagedType.I4)] public int dwBufferLength; [MarshalAs(UnmanagedType.I4)] public int dwBytesUsed; [MarshalAs(UnmanagedType.I4)] public int dwTimeCaptured; [MarshalAs(UnmanagedType.I4)] public int dwUser; [MarshalAs(rray, SizeConst = 4)] public int[] dwReserved; } [StructLayout(tial)] public struct BITMAPINFOHEADER { [MarshalAs(UnmanagedType.I4)] public Int32 biSize; [MarshalAs(UnmanagedType.I4)] public Int32 biWidth; [MarshalAs(UnmanagedType.I4)] public Int32 biHeight; [MarshalAs(UnmanagedType.I2)] public short biPlanes; [MarshalAs(UnmanagedType.I2)] public short biBitCount; [MarshalAs(UnmanagedType.I4)] public int biCompression; [MarshalAs(UnmanagedType.I4)] public int biSizeImage; [MarshalAs(UnmanagedType.I4)] public int biXpelsPerMeter; [MarshalAs(UnmanagedType.I4)] public int biYPelsPerMeter; [MarshalAs(UnmanagedType.I4)] public int biClrUsed; [MarshalAs(UnmanagedType.I4)] public int biClrImportant; } [StructLayout(tial)] public struct BITMAPINFO { [MarshalAs(, SizeConst = 100)] public BITMAPINFOHEADER bmiHeader; [MarshalAs(rray, SizeConst = 1024)] public int[] bmiColors; } [StructLayout(tial)] public struct CAPDRIVERCAPS { [MarshalAs(UnmanagedType.U2)]

2024年2月17日发(作者:咸映秋)

class WebCamera {

public delegate void RecievedFrameEventHandler(byte[] data); public event RecievedFrameEventHandler RecievedFrame; public IntPtr IwndC; public IntPtr mControlPtr; public int mWidth; public int mHeight; public ventHandler mFrameEventHandler; public void FrameCallBack(IntPtr Iwnd, IntPtr lpVHdr) { DR videoHeader = new DR(); byte[] VideoData; videoHeader = (DR)ucture(lpVHdr, videoHeader); VideoData=new byte[sUsed]; (, VideoData); if (edFrame != null) { edFrame(VideoData); } } public WebCamera(IntPtr handle, int width, int height) { mControlPtr = handle; mWidth = width; mHeight = height; } public void StartWebCam()

{ byte[] abc = new byte[32]; abc[0] = (byte)'u'; abc[1] = (byte)'s'; abc[2] = (byte)'b'; abc[3] = (byte)'C'; abc[4] = (byte)'a'; abc[5] = (byte)'m'; for (int i = 6; i < 32; i++) { abc[i] = (byte)'0'; }

public delegate void FrameEventHandler(IntPtr Iwnd, IntPtr lpVHdr); public static object GetStructure(IntPtr ptr, ValueType structure) { return tructure(ptr, e()); } public static object GetStructure(int ptr, ValueType structure) { return GetStructure(new IntPtr(ptr), structure); } public static void Copy(IntPtr ptr, byte[] data) { (ptr, data, 0, ); } public static void Copy(int ptr, byte[] data) { Copy(new IntPtr(ptr), data); } public static int SizeOf(object structer) { unsafe { return (structer); } } [DllImport("")] public static extern IntPtr capCreateCaptureWindowA(byte[] lpszWindowName, int dwStyle, int x, int y, int nwidth, int nheight, IntPtr hWndParent, int nID); [DllImport("")] public static extern bool SendMessage(IntPtr hWnd, int wMsg, short WParam, int LParam); [DllImport("")] public static extern bool SendMessage(IntPtr hWnd, int wMsg, bool WParam, int LParam); [DllImport("")] public static extern bool SendMessage(IntPtr hWnd,int wMsg,short WParam,FrameEventHandler LParam); [DllImport("")] public static extern bool SendMessage(IntPtr hWnd, int wMsg, int WParam, ref BITMAPINFO LParam); [DllImport("")] public static extern bool SendMessage(IntPtr hWnd, int wMsg, int WParam, ref CAPDRIVERCAPS LParam); [DllImport("")] public static extern bool SendMessage(IntPtr hWnd, int wMsg, int WParam, ref CAPTUREPARMS LParam); [DllImport("")] public static extern bool SendMessage(IntPtr hWnd, int wMsg, int WParam, ref CAPSTATUS LParam); [DllImport("")] public static extern int SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int y, int cx, int cy, int wFlags); [DllImport("")] public static extern int capGetVideoFormat(IntPtr hWnd, IntPtr psVideoFormat, int wSize); public const int WM_CAP_SINGLE_FRAME_OPEN = WM_USER + 70; public const int WM_CAP_SINGLE_FRAME_CLOSE = WM_USER + 71; public const int WM_CAP_SINGLE_FRAME=WM_USER+72; public const int WM_CAP_EDIT_COPY = (WM_USER + 30);

//[DllImport("")] //public static extern bool EmptyClipboard(); //[DllImport("")] //public static extern bool CloseClipboard(); //[DllImport("")] //public static extern bool OpenClipboard(IntPtr hWnd); //[DllImport("")] //public static extern bool IsClipboardFormatAvailable(uint format); //[DllImport("")] //public static extern IntPtr GetClipboardData(uint uFormat); //[DllImport("")] //public static extern IntPtr GlobalLock(IntPtr handle); //[DllImport("")] //public static extern bool GlobalUnlock(IntPtr handle); //[DllImport("")] //public static extern bool CloseClipboard();

[StructLayout(tial)] public struct VIDEOHDR { [MarshalAs(UnmanagedType.I4)] public int lpData; [MarshalAs(UnmanagedType.I4)] public int dwBufferLength; [MarshalAs(UnmanagedType.I4)] public int dwBytesUsed; [MarshalAs(UnmanagedType.I4)] public int dwTimeCaptured; [MarshalAs(UnmanagedType.I4)] public int dwUser; [MarshalAs(rray, SizeConst = 4)] public int[] dwReserved; } [StructLayout(tial)] public struct BITMAPINFOHEADER { [MarshalAs(UnmanagedType.I4)] public Int32 biSize; [MarshalAs(UnmanagedType.I4)] public Int32 biWidth; [MarshalAs(UnmanagedType.I4)] public Int32 biHeight; [MarshalAs(UnmanagedType.I2)] public short biPlanes; [MarshalAs(UnmanagedType.I2)] public short biBitCount; [MarshalAs(UnmanagedType.I4)] public int biCompression; [MarshalAs(UnmanagedType.I4)] public int biSizeImage; [MarshalAs(UnmanagedType.I4)] public int biXpelsPerMeter; [MarshalAs(UnmanagedType.I4)] public int biYPelsPerMeter; [MarshalAs(UnmanagedType.I4)] public int biClrUsed; [MarshalAs(UnmanagedType.I4)] public int biClrImportant; } [StructLayout(tial)] public struct BITMAPINFO { [MarshalAs(, SizeConst = 100)] public BITMAPINFOHEADER bmiHeader; [MarshalAs(rray, SizeConst = 1024)] public int[] bmiColors; } [StructLayout(tial)] public struct CAPDRIVERCAPS { [MarshalAs(UnmanagedType.U2)]

发布评论

评论列表 (0)

  1. 暂无评论