導航:首頁 > 源碼編譯 > 匯編攝像頭源碼

匯編攝像頭源碼

發布時間:2022-08-06 17:34:10

❶ 求一個控制攝像頭小程序的源碼,要求VC下編譯運行

VC-攝像頭控制SDK源碼
#include <windows.h>
#include <stdio.h>
#include <vfw.h>
#pragma comment(lib,"vfw32.lib")

HWND ghWndCap ; //捕獲窗的句柄
CAPDRIVERCAPS gCapDriverCaps ; //視頻驅動器的能力
CAPSTATUS gCapStatus ; //捕獲窗的狀態
char szCaptureFile[] = "MYCAP.AVI";
char gachBuffer[20];

LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);

LRESULT CALLBACK StatusCallbackProc(HWND hWnd,int nID,LPSTR lpStatusText)
{
if(!ghWndCap)return FALSE;//獲得捕獲窗的狀態
capGetStatus(ghWndCap,&gCapStatus,sizeof(CAPSTATUS));//更新捕獲窗的大小
SetWindowPos(ghWndCap,NULL,0,0,gCapStatus.uiImageWidth,gCapStatus.uiImageHeight,SWP_NOZORDER|SWP_NOMOVE);
if(nID==0){//清除舊的狀態信息
SetWindowText(ghWndCap,(LPSTR)"hello");
return (LRESULT)TRUE;
}//顯示狀態ID和狀態文本
wsprintf(gachBuffer,"Status# %d: %s",nID,lpStatusText);
SetWindowText(ghWndCap,(LPSTR)gachBuffer);
return (LRESULT)TRUE;
}
LRESULT CALLBACK ErrorCallbackProc(HWND hWnd,int nErrID,LPSTR lpErrorText)
{
if(!ghWndCap)return FALSE;
if(nErrID==0)return TRUE;//清除舊的錯誤
wsprintf(gachBuffer,"Error# %d",nErrID);//顯示錯誤標識和文本
MessageBox(hWnd, lpErrorText, gachBuffer,MB_OK | MB_ICONEXCLAMATION);
return (LRESULT) TRUE;
}

LRESULT CALLBACK FrameCallbackProc(HWND hWnd,LPVIDEOHDR lpVHdr)
{
FILE *fp;
fp=fopen("caram.dat","w");
if(!ghWndCap)return FALSE;//假設fp為一打開的.dat文件指針
fwrite(lpVHdr->lpData,1,lpVHdr->dwBufferLength,fp);
return (LRESULT)TRUE;
}

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,PSTR szCmdLine,int iCmdShow)
{
static TCHAR szAppName[]=TEXT("HelloWin");
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
wndclass.style=CS_HREDRAW|CS_VREDRAW;
wndclass.lpfnWndProc=WndProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=szAppName;
if(!RegisterClass(&wndclass))
{
MessageBox(NULL,TEXT("This program requires WindowsNT!"),szAppName,MB_ICONERROR);
return 0;
}
hwnd=CreateWindow(szAppName,TEXT("The Hello Program"),WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,iCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
switch(message)
{
case WM_CREATE:
{
ghWndCap=capCreateCaptureWindow((LPSTR)"Capture Window",WS_CHILD|WS_VISIBLE,0,0,300,240,(HWND)hwnd,(int)0);
capSetCallbackOnError(ghWndCap,(FARPROC)ErrorCallbackProc);
capSetCallbackOnStatus(ghWndCap,(FARPROC)StatusCallbackProc);
capSetCallbackOnFrame(ghWndCap,(FARPROC)FrameCallbackProc);
capDriverConnect(ghWndCap,0); // 將捕獲窗同驅動器連接
//獲得驅動器的能力,相關的信息放在結構變數gCapDriverCaps中
capDriverGetCaps(ghWndCap,&gCapDriverCaps,sizeof(CAPDRIVERCAPS));
capPreviewRate(ghWndCap, 66); // 設置Preview模式的顯示速率
capPreview(ghWndCap, TRUE); //啟動Preview模式
if(gCapDriverCaps.fHasOverlay) //檢查驅動器是否有疊加能力
capOverlay(ghWndCap,TRUE); //啟動Overlay模式
if(gCapDriverCaps.fHasDlgVideoSource)capDlgVideoSource(ghWndCap); //Video source 對話框
if(gCapDriverCaps.fHasDlgVideoFormat)capDlgVideoFormat(ghWndCap); // Video format 對話框
if(gCapDriverCaps.fHasDlgVideoDisplay)capDlgVideoDisplay(ghWndCap); // Video display 對話框
capFileSetCaptureFile( ghWndCap, szCaptureFile); //指定捕獲文件名
capFileAlloc(ghWndCap, (1024L * 1024L * 5)); //為捕獲文件分配存儲空間
capCaptureSequence(ghWndCap); //開始捕獲視頻序列
capGrabFrame(ghWndCap); //捕獲單幀圖像

}

return 0;
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
GetClientRect(hwnd,&rect);
DrawText(hdc,TEXT("Hello,Windows98!"),-1,&rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER);
EndPaint(hwnd,&ps);
return 0;
case WM_DESTROY:
{
capSetCallbackOnStatus(ghWndCap,NULL);
capSetCallbackOnError(ghWndCap,NULL);
capSetCallbackOnFrame(ghWndCap,NULL);
capCaptureAbort(ghWndCap);//停止捕獲
capDriverDisconnect(ghWndCap); //將捕獲窗同驅動器斷開
PostQuitMessage(0);
}
return 0;
}
return DefWindowProc(hwnd,message,wParam,lParam);
}

❷ 易語言怎麼做視頻監控求源碼!QAQ

首先,易語言高!成千上萬的源碼可以借鑒!
其次夠底層,直接嵌入匯編!用上黑月插件,編譯夠小!
易語言的獨特模塊,拿來就用!
_
破解,病毒,游戲輔助,基本都是在反編譯,掌握了程序基本情況之後,在寫程序!!
寫內存,讀內存,進程注入,這些技術在其他編程語言實現你的看各種文檔! 而易語言,各種注入模塊,驅動讀寫內存,都是現成的!
而其他語言,如C語言,你寫的時候,很多時間,都是在了解c的各種庫。本來你只想吃饅頭,用c你就得了解包頭的烹飪方法!如果,你還需要互動的界面的話......成本太高了!
易語言很多時候其實只是負責UI,很多動態庫都是其他語言編寫的,易語言負責調用整合!
可以說,易語言,在開發小程序,有天然的優勢!

❸ vb6 無驅攝像頭編程 求源碼

發下是我幾年前寫的(參照)一個VB驅動攝像頭的代碼,不知道現在還能不能用,因為文件總的很長,這只是其中的一小部分,希望對你有所用.(要不就和我聯系,給你源碼)
Private Sub Form_Load()
On Error Resume Next
Dim retVal As Boolean
Dim numDevs As Long
bCaramaPlaying = True
'load trivial settings first
Me.BackColor = Val(GetSetting(App.Title, "preferences", "backcolor", "&H404040")) 'default to dk gray

numDevs = VBEnumCapDrivers(Me)
If 0 = numDevs Then
MsgBox "沒有找到視頻捕捉設備!", vbCritical, App.Title
' frmPlayer.Visible = True
' If bIsVisible = True And vbPlayFormIsVisible = True And vbFrmPlayFrameHided = False Then
' frmPlayFrame.Visible = True
' End If
Unload Me
Exit Sub
End If
nDriverIndex = Val(GetSetting(App.Title, "driver", "index", "0"))
'if invalid entry is in registry use default (0)
If mnuDriver.UBound < nDriverIndex Then
nDriverIndex = 0
End If
mnuDriver(nDriverIndex).Checked = True
'//Create Capture Window
'Call capGetDriverDescription( nDriverIndex, lpszName, 100, lpszVer, 100 '// Retrieves driver info
hCapWnd = capCreateCaptureWindow("VB CAP WINDOW", WS_CHILD Or WS_VISIBLE, 0, 0, 160, 120, Me.hWnd, 0)
If 0 = hCapWnd Then
MsgBox "不能創建捕捉窗口!", vbCritical, App.Title
Exit Sub
End If
retVal = ConnectCapDriver(hCapWnd, nDriverIndex)
If False = retVal Then
MsgBox "不能連接到視頻設備!", vbInformation, App.Title
Else
#If USECALLBACKS = 1 Then
' if we have a valid capwnd we can enable our status callback function
Call capSetCallbackOnStatus(hCapWnd, AddressOf StatusProc)
Debug.Print "---Callback set on capture status---"
#End If
End If
'// Set the video stream callback function
' capSetCallbackOnVideoStream lwndC, AddressOf MyVideoStreamCallback
' capSetCallbackOnFrame lwndC, AddressOf MyFrameCallback

Dim bPlayFrameTop As Boolean
bPlayFrameTop = GetSetting(MyName, "setting" & "-" & Trim(Str(App.Major)) & "-" & Trim(Str(App.Minor)), "bPlayFrameTop", "False")
If bPlayFrameTop = True Then
Me.mnuOptionTop.Checked = True
'放在最前
SetWindowPos Me.hWnd, HWND_TOPMOST, Me.Left / Screen.TwipsPerPixelX, Me.Top / Screen.TwipsPerPixelY, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY, &H20
Else
Me.mnuOptionTop.Checked = False
'不放在最前
SetWindowPos Me.hWnd, HWND_NOTOPMOST, Me.Left / Screen.TwipsPerPixelX, Me.Top / Screen.TwipsPerPixelY, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY, &H20
End If
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) / 2
Me.picShowMenu.ZOrder 0

End Sub

'以下是一個模塊文件
Option Explicit

'application specific routines are here

Public Const ONE_MEGABYTE As Long = 1048576
'Public Const MMSYSERR_NOERROR As Long = 0
Public Const INDEX_15_MINUTES As Long = 27000 '(30fps * 60sec * 15min)
Public Const INDEX_3_HOURS As Long = 324000 ' (30fps * 60sec * 60min * 3hr)

Public Function GetFreeSpace() As Long
'this function gets the amount of free disk space and adds the size
'of the current capture file
Dim freedisk As Long
Dim path As String

'get Cap File length
path = capFileGetCaptureFile(frmCaramaMain.capwnd)
If path <> "" Then
On Error Resume Next
freedisk = FileLen(path)
freedisk = freedisk / ONE_MEGABYTE
End If

'now get free disk space from that drive
path = Left$(path, 3)
GetFreeSpace = freedisk + vbGetAvailableMBytes(path)

End Function

Sub ResizeCaptureWindow(ByVal hCapWnd As Long)
Dim retVal As Boolean
Dim capStat As CAPSTATUS

'Get the capture window attributes
retVal = capGetStatus(hCapWnd, capStat)

If retVal Then
'Resize the main form to fit
Call SetWindowPos(frmCaramaMain.hWnd, _
0&, _
0&, _
0&, _
capStat.uiImageWidth + (frmCaramaMain.XBorder * 2), _
capStat.uiImageHeight + (frmCaramaMain.YBorder * 4) _
+ frmCaramaMain.CaptionHeight + frmCaramaMain.MenuHeight, _
Swp_nomove Or SWP_NOZORDER Or SWP_NOSENDCHANGING)
'Resize the capture window to format size
Call SetWindowPos(hCapWnd, _
0&, _
0&, _
0&, _
capStat.uiImageWidth, _
capStat.uiImageHeight, _
Swp_nomove Or SWP_NOZORDER Or SWP_NOSENDCHANGING)
End If
Call frmCaramaMain.Form_Resize
End Sub

Public Function VBEnumCapDrivers(ByRef frm As frmCaramaMain) As Long
'/*
' * Enumerate the potential capture drivers and add the list to the Options
' * menu. This function is only called once at startup.
' * Returns 0 if no drivers are available.
' */
Const MAXVIDDRIVERS As Long = 9
Const CAP_STRING_MAX As Long = 128
Dim numDrivers As Long
Dim driverStrings(0 To MAXVIDDRIVERS - 1) As String
Dim Index As Long
Dim Device As String
Dim Version As String
Dim menu As VB.menu

Device = String$(CAP_STRING_MAX, 0)
Version = String$(CAP_STRING_MAX, 0)
numDrivers = 0
For Index = 0 To (MAXVIDDRIVERS - 1) Step 1
If 0 <> capGetDriverDescription(Index, _
Device, _
CAP_STRING_MAX, _
Version, _
CAP_STRING_MAX) _
Then
'extend the menu
If Index > 0 Then
Load frm.mnuDriver(Index)
End If
Set menu = frm.mnuDriver(Index) 'get an object pointer to the new menu
'Concatenate the device name and version strings to the new menu item
menu.Caption = Left$(Device, InStr(Device, vbNullChar) - 1)
menu.Caption = menu.Caption & " "
menu.Caption = menu.Caption & Left$(Version, InStr(Version, vbNullChar) - 1)
menu.Enabled = True
numDrivers = numDrivers + 1
End If

Next
VBEnumCapDrivers = numDrivers
End Function

Public Function ConnectCapDriver(ByVal hCapWnd As Long, ByVal nDriverIndex As Long) As Boolean
Dim retVal As Boolean
Dim Caps As CAPDRIVERCAPS
Dim i As Long

Debug.Assert (nDriverIndex < 10) And (nDriverIndex >= 0)
'// Connect the capture window to the driver
retVal = capDriverConnect(hCapWnd, nDriverIndex)
If False = retVal Then
'return False
Exit Function
End If
'// Get the capabilities of the capture driver
retVal = capDriverGetCaps(hCapWnd, Caps)

If False <> retVal Then
'reset menus (very app-specific)
With frmCaramaMain
For i = 0 To .mnuDriver.UBound
.mnuDriver(i).Checked = False 'make sure all drivers are unchecked
Next
.mnuDriver(nDriverIndex).Checked = True 'then check the new driver
'disable all hardware feature menu items
.mnuSource.Enabled = False
.mnuFormat.Enabled = False
.mnuDisplay.Enabled = False
.mnuOverlay.Enabled = False
'Then enable the ones which are supported by the new driver
If Caps.fHasDlgVideoSource <> 0 Then .mnuSource.Enabled = True
If Caps.fHasDlgVideoFormat <> 0 Then .mnuFormat.Enabled = True
If Caps.fHasDlgVideoDisplay <> 0 Then .mnuDisplay.Enabled = True
If Caps.fHasOverlay <> 0 Then .mnuOverlay.Enabled = True

End With
End If
'// Set the preview rate in milliseconds
Call capPreviewRate(hCapWnd, 66) '15 FPS

'// Start previewing the image from the camera
Call capPreview(hCapWnd, True)
'default to showing a preview each time
frmCaramaMain.mnuPreview.Checked = True

'// Resize the capture window to show the whole image
Call ResizeCaptureWindow(hCapWnd)
ConnectCapDriver = True
End Function
Public Function StatusProc(ByVal hCapWnd As Long, ByVal StatusCode As Long, ByVal lpStatusString As Long) As Long
Select Case StatusCode
Case 0 'this is recommended in docs
'when zero is sent, clear old status messages
'frmCaramaMain.Caption = App.Title
Case IDS_CAP_END ' Video Capture has finished
frmCaramaMain.Caption = App.Title
Case IDS_CAP_STAT_VIDEOAUDIO, IDS_CAP_STAT_VIDEOONLY
MsgBox LPSTRtoVBString(lpStatusString), vbInformation, App.Title
Case Else
'use this function if you need a real VB string
'frmCaramaMain.Caption = LPSTRtoVBString(lpStatusString)

'or, just pass the LPCSTR to a WINAPI function
Call SetWindowTextAsLong(frmCaramaMain.hWnd, lpStatusString)
End Select
Debug.Print "Driver returned code " & StatusCode & " to StatusProc"
StatusProc = -(True) '- converts Boolean to C BOOL
End Function

❹ C# 代碼驅動攝像頭

using System; using System.Runtime.InteropServices; using System.Drawing; using System.Drawing.Imaging; using System.Data.SqlTypes; namespace CamVision1 { /// 《summary》 /// 攝像顯示區域數據結構設置 /// 《/summary》 public struct CamStruct { public IntPtr handle; public int left; public int top; public int width; public int height; } /// 《summary》 /// 攝像頭驅動程序類 /// 《/summary》 public class Cam { 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; public const int WM_CAP_GET_CAPSTREAMPTR = WM_CAP_START + 1; public const int WM_CAP_SET_CALLBACK_STATUS = WM_CAP_START + 3; public const int WM_CAP_SET_CALLBACK_YIELD = WM_CAP_START + 4; public const int WM_CAP_SET_CALLBACK_WAVESTREAM = WM_CAP_START + 7; public const int WM_CAP_GET_USER_DATA = WM_CAP_START + 8; public const int WM_CAP_SET_USER_DATA = WM_CAP_START + 9; public const int WM_CAP_DRIVER_GET_NAME = WM_CAP_START + 12; public const int WM_CAP_DRIVER_GET_VERSION = WM_CAP_START + 13; public const int WM_CAP_DRIVER_GET_CAPS = WM_CAP_START + 14; public const int WM_CAP_FILE_SET_CAPTURE_FILE = WM_CAP_START + 20; public const int WM_CAP_FILE_GET_CAPTURE_FILE = WM_CAP_START + 21; public const int WM_CAP_FILE_ALLOCATE = WM_CAP_START + 22; public const int WM_CAP_FILE_SAVEAS = WM_CAP_START + 23; public const int WM_CAP_FILE_SET_INFOCHUNK = WM_CAP_START + 24; public const int WM_CAP_FILE_SAVEDIB = WM_CAP_START + 25; public const int WM_CAP_EDIT_COPY = WM_CAP_START + 30; public const int WM_CAP_SET_AUDIOFORMAT = WM_CAP_START + 35; public const int WM_CAP_GET_AUDIOFORMAT = WM_CAP_START + 36; public const int WM_CAP_DLG_VIDEOFORMAT = WM_CAP_START + 41; public const int WM_CAP_DLG_VIDEOSOURCE = WM_CAP_START + 42; public const int WM_CAP_DLG_VIDEODISPLAY = WM_CAP_START + 43; public const int WM_CAP_GET_VIDEOFORMAT = WM_CAP_START + 44; public const int WM_CAP_SET_VIDEOFORMAT = WM_CAP_START + 45; public const int WM_CAP_DLG_VIDEOCOMPRESSION = WM_CAP_START + 46; public const int WM_CAP_GET_STATUS = WM_CAP_START + 54; public const int WM_CAP_SET_SCROLL = WM_CAP_START + 55; public const int WM_CAP_GRAB_FRAME_NOSTOP = WM_CAP_START + 61; public const int WM_CAP_SET_SEQUENCE_SETUP = WM_CAP_START + 64; public const int WM_CAP_GET_SEQUENCE_SETUP = WM_CAP_START + 65; public const int WM_CAP_SET_MCI_DEVICE = WM_CAP_START + 66; public const int WM_CAP_GET_MCI_DEVICE = WM_CAP_START + 67; public const int WM_CAP_ABORT = WM_CAP_START + 69; public const int WM_CAP_SINGLE_FRAME_OPEN = WM_CAP_START + 70; public const int WM_CAP_SINGLE_FRAME_CLOSE = WM_CAP_START + 71; public const int WM_CAP_SINGLE_FRAME = WM_CAP_START + 72; public const int WM_CAP_PAL_OPEN = WM_CAP_START + 80; public const int WM_CAP_PAL_SAVE = WM_CAP_START + 81; public const int WM_CAP_PAL_PASTE = WM_CAP_START + 82; public const int WM_CAP_PAL_AUTOCREATE = WM_CAP_START + 83; public const int WM_CAP_PAL_MANUALCREATE = WM_CAP_START + 84; // Following added post VFW 1.1 public const int WM_CAP_SET_CALLBACK_CAPCONTROL = WM_CAP_START + 85; // Defines end of the message range public const int WM_CAP_END = WM_CAP_SET_CALLBACK_CAPCONTROL; private IntPtr hWndC ; private bool bStat; private IntPtr mControlPtr; private int mWidth; private int mHeight; private int mLeft; private int mTop; [DllImport("avicap32.dll")] private static extern IntPtr capCreateCaptureWindowA(byte[] lpszWindowName, int dwStyle,int x,int y,int nWidth,int nHeight, IntPtr hWndParent , int nID); [DllImport("avicap32.dll")] private static extern int capGetVideoFormat(IntPtr hWnd, IntPtr psVideoFormat, int wSize); [DllImport("User32.dll")] private static extern bool SendMessage(IntPtr hWnd, int wMsg, int wParam, long lParam); public bool capDlgVideoFormat() { return SendMessage(hWndC, WM_CAP_DLG_VIDEOFORMAT, 0, 0); } public bool capDlgVideoSource() { return SendMessage(hWndC, WM_CAP_DLG_VIDEOSOURCE, 0, 0); } public bool capDlgVideoDisplay() { return SendMessage(hWndC, WM_CAP_DLG_VIDEODISPLAY, 0, 0); } public bool capDlgVideoCompression() { return SendMessage(hWndC, WM_CAP_DLG_VIDEOCOMPRESSION, 0, 0); } /// 《summary》; /// 初始化攝像頭 /// 《/summary》 /// 《param name="handle"》控制項的句柄《/param》 /// 《param name="left"》開始顯示的左邊距《/param》 /// 《param name="top"》開始顯示的上邊距《/param》 /// 《param name="width"》要顯示的寬度《/param》 /// 《param name="height"》要顯示的長度《/param》 public Cam(CamStruct camStruct) { mControlPtr = camStruct.handle;; mWidth = camStruct.width; mHeight = camStruct.height; mLeft = camStruct.left; mTop = camStruct.top; } /// 《summary》 /// 開始顯示圖像 /// 《/summary》 public void Start() { if( bStat ) { return; } bStat = true; byte[] lpszName=new byte[99]; hWndC = capCreateCaptureWindowA(lpszName, WS_CHILD | WS_VISIBLE, mLeft, mTop, mWidth, mHeight, mControlPtr, 0); if (hWndC.ToInt32() != 0 ) { SendMessage(hWndC, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0); SendMessage(hWndC, WM_CAP_SET_CALLBACK_ERROR, 0, 0); SendMessage(hWndC, WM_CAP_SET_CALLBACK_STATUSA, 0, 0); SendMessage(hWndC, WM_CAP_DRIVER_CONNECT, 0, 0); SendMessage(hWndC, WM_CAP_SET_SCALE, 1, 0); SendMessage(hWndC, WM_CAP_SET_PREVIEWRATE, 66, 0); SendMessage(hWndC, WM_CAP_SET_OVERLAY, 1, 0); SendMessage(hWndC, WM_CAP_SET_PREVIEW, 1, 0); } return; } /// 《summary》 /// 停止顯示 /// 《/summary》 public void Stop() { SendMessage(hWndC, WM_CAP_DRIVER_DISCONNECT, 0, 0); bStat = false; } /// 《summary》 /// 抓圖 /// 《/summary》 /// 《param name="path"》要保存bmp文件的路徑《/param》 public void GrabImage(string path) { IntPtr hBmp= Marshal.StringToHGlobalAnsi(path); SendMessage(hWndC, WM_CAP_SAVEDIB, 0, hBmp.ToInt64()); } /// 《summary》 /// 錄像 /// 《/summary》 /// 《param name="path"》要保存avi文件的路徑《/param》 public void Kinescope(string path) { IntPtr hBmp = Marshal.StringToHGlobalAnsi(path); SendMessage(hWndC, WM_CAP_FILE_SET_CAPTURE_FILEA, 0, hBmp.ToInt64()); SendMessage(hWndC, WM_CAP_SEQUENCE, 0, 0); } /// 《summary》 /// 停止錄像 /// 《/summary》 public void StopKinescope() { SendMessage(hWndC, WM_CAP_STOP, 0, 0); } } }

❺ 最近,想用MFC編個對話框,能夠實時顯示攝像頭捕捉的鏡頭!誰有源代碼,能否發我一份吧!感激涕零啊……

現在在vc上採集視頻常用的方法有三:vfw,directshow,opencv

你是要進行圖像處理的話推薦opencv(具體參考:於仕琪,opencv教程基礎篇中的例3-6,稍作修改,估計就能用於你的工程)

下面貼出我自己編的一個小工程:如有疑問,E-mail:[email protected]
進行opencv的預備操作你要看那本書和逛opencv中文網

如有問題可以和我討論(我也是菜鳥,剛為解決了這個問題竊喜不已)。
1.新建mfc對話框工程,在其中添加一個picture控制項,除了ID以外什麼都不用改

2.在對話框頭文件(沒有Dlg那個)中添加(最好是在「#include "resource.h" // main symbols之後」):
#include "cxcore.h"
#include "cvcam.h"
#include "windows.h"
#include "cv.h"
#include "highgui.h"
3.在工程-》設置-》選擇所有配置-》link(連接)-》對象/庫模塊-》中添加:
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cxcore.lib cv.lib ml.lib cvaux.lib highgui.lib cvcam.lib

4.在需要觸發攝像頭顯示的地方添加:
void CVideomfcDlg::OnButton1()
{
// TODO: Add your control notification handler code here

int ncams = cvcamGetCamerasCount( );//返回可以訪問的攝像頭數目
HWND MyWin=::GetDlgItem(m_hWnd,IDC_VIDEO); //獲得控制項句柄(IDC_VIDEO就是圖片控制項)
cvcamSetProperty(0, CVCAM_PROP_ENABLE, CVCAMTRUE); //選擇第一個攝像頭
int width=240;
int height=240;

cvcamSetProperty(0,CVCAM_PROP_WINDOW, &MyWin); // Selects a window for
cvcamSetProperty(0,CVCAM_RNDWIDTH, &width);
cvcamSetProperty(0,CVCAM_RNDHEIGHT, &height);
cvcamSetProperty(0, CVCAM_PROP_CALLBACK, callback1);
//回調函數將處理每一幀

cvcamInit( );
cvcamStart( );

}
5.改變顯示的圖像序列大小,在窗口屬性設定了以後,添加如下代碼:
int width=320; //這個就是需要顯示的窗口大小
int height=240; //根據自己需要選擇
cvcamSetProperty(0,CVCAM_RNDWIDTH, &width);
cvcamSetProperty(0,CVCAM_RNDHEIGHT, &height);

6.在對話框類中添加callback成員函數(注意,在添加函數的時候,一定要選擇static,不選的話你就自己郁悶去吧,反正我是為了這個郁悶了2個禮拜)
void CVideomfcDlg::callback1(IplImage *image)
{

IplImage* image1 = image;
int i,j;

assert (image);
//獲取當前系統時間
SYSTEMTIME st2=;
GetLocalTime(&st2);
char sss[18]=; //這個是用來存儲所要保存的圖片名的,用的是一個笨辦法,先定義,再修改其中的數組值。

sss[7]=st2.wHour/10+48; //獲取系統當前小時
sss[8]=st2.wHour%10+48;

sss[9]=st2.wMinute/10+48; //獲取系統當前分鍾
sss[10]=st2.wMinute%10+48;

sss[11]=st2.wSecond/10+48; //獲取系統當前秒
sss[12]=st2.wSecond%10+48;

cvSaveImage(sss,image1); //使用系統當前時間為名稱(XXXXXX.jpg)存儲圖片
}
ps:你還需要在c盤根目錄下建立一個叫1的文件夾保存圖片。
祝你成功!

android 實時監控硬體攝像頭如何實現 求個源碼

實時監控還是比較厲害的,後台拍攝記錄?不懂是個什麼意思,程序調用攝像頭拍照還是比較簡單的。

❼ 求「VC++實現的支持攝像頭和圖像的人臉識別系統」源碼和報告

實現支技攝像頭和八圖像人臉識別二維碼掃描器實現夢想的聲音好大。

❽ 求 在網頁中打開查看區域網內的攝像頭的監控畫面 的例子(源碼),請不吝賜教,在下感激不盡。

這是正解。。。。

那個監視系統要兼容你用網頁打開的操作。
如果不兼容,打死我也沒辦法,你用的那個軟體,如果支持這種調用,應該會寫出來。並且會寫出詳細調用方法、提供源碼或直接提供一個網頁。
你的監視器是什麼埠?網路攝像頭么。。
廠商不是傻X,有網頁調用的方法,絕對會立刻發布。。。
lz,偶愛莫能助。。。。

閱讀全文

與匯編攝像頭源碼相關的資料

熱點內容
androidapp調用另一個app 瀏覽:621
數控銑床法蘭克子程序編程 瀏覽:173
linux打包命令targz 瀏覽:996
抖音app是哪個 瀏覽:407
蘋果app怎麼上架 瀏覽:255
NA伺服器地址 瀏覽:427
我的世界如何初始化伺服器 瀏覽:97
哪個手機app天氣預報最准 瀏覽:752
怎樣把視頻壓縮至25m 瀏覽:570
vivox27文件夾怎麼改變 瀏覽:727
新手玩狼人殺用什麼app 瀏覽:615
pdf在線查看 瀏覽:954
安卓tv90如何關閉後台 瀏覽:683
php讀取word亂碼 瀏覽:755
minicom源碼 瀏覽:1001
海爾冷櫃壓縮機 瀏覽:416
聯通伺服器如何調試信號 瀏覽:136
stata新命令 瀏覽:941
單調棧演算法python 瀏覽:606
微信解壓游戲怎麼下載 瀏覽:962