c 實現攝象頭拍照

2021-04-22 19:35:39 字數 2901 閱讀 1639

form1.cs**

using system;

using system.drawing;

using system.collections;

using system.componentmodel;

using system.windows.forms;

using system.data;

using capturemovie;

namespace capturemovie

private void form1_load(object sender, system.eventargs e)

private void b_stop_click(object sender, system.eventargs e)

private void b_play_click(object sender, eventargs e)

private void button1_click(object sender, eventargs e)

catch (exception se)

}    }}

form1.designer.cs

namespace capturemovie

base.dispose(disposing);

}#region windows 窗體設計器生成的**

#endregion

private system.windows.forms.button button1;

private system.windows.forms.groupbox groupbox1;

private system.windows.forms.button button3;

private system.windows.forms.button button2;}}

program.cs

using system;

using system.collections.generic;

using system.windows.forms;

namespace capturemovie

[structlayout(layoutkind.sequential)]

public struct bitmapinfoheader

[structlayout(layoutkind.sequential)]

public struct bitmapinfo

public delegate void frameeventhandler(intptr lwnd, intptr lpvhdr);

// public methods

public static object getstructure(intptr ptr, valuetype structure)

public static object getstructure(int ptr, valuetype structure)

public static void copy(intptr ptr, byte data)

public static void copy(int ptr, byte data)

public static int sizeof(object structure)

}//web camera class

public class webcamera

// delegate for frame callback

public delegate void recievedframeeventhandler(byte data);

public event recievedframeeventhandler recievedframe;

private intptr lwndc; // holds the unmanaged handle of the control

private intptr mcontrolptr; // holds the managed pointer of the control

private int mwidth;

private int mheight;

private showvideo.frameeventhandler mframeeventhandler; // delegate instance for the frame callback - must keep alive! gc should not collect it

showvideo.capgetdriverdescriptiona(0, lpszname, 100, lpszver, 100);

this.lwndc = showvideo.capcreatecapturewindowa(lpszname, showvideo.ws_visible + showvideo.ws_child, 0, 0, mwidth, mheight, mcontrolptr, 0);

///   要儲存bmp檔案的路徑

public void grabimage(intptr hwndc, string path)

// private functions

private bool capdriverconnect(intptr lwnd, short i)

private bool capdriverdisconnect(intptr lwnd)

private bool capsetcallbackonframe(intptr lwnd, showvideo.frameeventhandler lpproc)

private bool capsetvideoformat(intptr hcapwnd, ref showvideo.bitmapinfo bmpformat, int capformatsize)

private void framecallback(intptr lwnd, intptr lpvhdr)}}

c 實現攝像頭拍照功能示例

複製 如下 using system.drawing using system.drawing.imaging using system using system.runtime.interopservices 複製 如下 private const int wm user 0x400 privat...

用python實現自動拍照專案

當下,python是熱門語言之一,python可以實現各種各樣的功能,從而在現實生活中幫助我們。專案全部 import cv2 import time def snapshotct camera idx 1 camera idx的作用是選擇攝像頭。如果為0則使用內建攝像頭,比如筆記本的攝像頭,用1或...

通過html和cgi實現拍照顯示功能

華清遠見嵌入式培訓中心 講師。1.編寫html網頁 video.html。網頁內容如下 example video cgi程式內容如下 include include cgic.h include include include include include include include inc...