This article uses the avicap32.dll library to drive the camera. Supports image capturing and video recording.
Using System;
Using System. Runtime. InteropServices;
Using System. Drawing;
Using System. Drawing. Imaging;
Namespace using System;
Using System. Runtime. InteropServices;
Using System. Drawing;
Using System. Drawing. Imaging;
Namespace PickHead
{
/// <Summary>
/// A class for controlling cameras
/// </Summary>
Public class Pick
{
Private const int WM_USER = 0x400;
Private const int WS_CHILD = 0x40000000;
Private const int WS_VISIBLE = 0x10000000;
Private const int WM_CAP_START = WM_USER;
Private const int WM_CAP_STOP = WM_CAP_START + 68;
Private const int WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10;
Private const int WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11;
Private const int WM_CAP_SAVEDIB = WM_CAP_START + 25;
Private const int WM_CAP_GRAB_FRAME = WM_CAP_START + 60;
Private const int WM_CAP_SEQUENCE = WM_CAP_START + 62;
Private const int WM_CAP_FILE_SET_CAPTURE_FILEA = WM_CAP_START + 20;
Private const int WM_CAP_SEQUENCE_NOFILE = WM_CAP_START + 63;
Private const int WM_CAP_SET_OVERLAY = WM_CAP_START + 51;
Private const int WM_CAP_SET_PREVIEW = WM_CAP_START + 50;
Private const int WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START + 6;
Private const int WM_CAP_SET_CALLBACK_ERROR = WM_CAP_START + 2;
Private const int WM_CAP_SET_CALLBACK_STATUSA = WM_CAP_START + 3;
Private const int WM_CAP_SET_CALLBACK_FRAME = WM_CAP_START + 5;
Private const int WM_CAP_SET_SCALE = WM_CAP_START + 53;
Private const int WM_CAP_SET_PREVIEWRATE = WM_CAP_START + 52;
Private IntPtr hWndC;
Private bool bStat = false;
Private IntPtr mControlPtr;
Private int mWidth;
Private int mHeight;
Private int mLeft;
Private int mTop;
/// <Summary>
/// Initialize the camera
/// </Summary>
/// <Param name = "handle"> control handle </param>
/// <Param name = "left"> left margin of start display </param>
/// <Param name = "top"> top margin </param>
/// <Param name = "width"> width </param>
/// <Param name = "height"> length to be displayed </param>
Public Pick (IntPtr handle, int left, int top, int width, int height)
{
MControlPtr = handle;
MWidth = width;
MHeight = height;
There are 3 pages in this news. Currently, there are 3 pages in 1st.