Почитай сайт http://directshow.wonderu.com/. Если будут проблемы и вопросы, то обращайся. Я уже намучился и реализовал работу с камерами на FASM.
1. Сначала создайте обычное окно. 2. В этом окне создайте фрейм для вывода данных с камеры. Примерно так: Код (Text): .data DLLname db "avicap32.dll",0 p1name db "capCreateCaptureWindowA",0 hCapture dd 0 .code invoke LoadLibrary,addr DLLname mov hLibrary, eax invoke GetProcAddress,hLibrary,addr p1name mov lpMes, eax push 0 push hWnd push 240 push 320 push 20 push 150 push WS_CHILD or WS_VISIBLE push offset CapName call lpMes mov hCapture,eax invoke SendMessage, hCapture, WM_CAP_DRIVER_CONNECT, 0, 0 invoke SendMessage, hCapture, WM_CAP_SET_SCALE, TRUE, 0 invoke SendMessage, hCapture, WM_CAP_SET_PREVIEWRATE, 66, 0 3. Далее, в зависимости от того что вам нужно, граббить видео или картинку, используете различные флаги в SendMessage. Пример для получения картинки: Код (Text): .data szTitle db "Save file as",0 szFilterBMP db "Bitmap files",0,"*.bmp",0,0 szFileName db "c:\1.bmp",0 ;256 dup(0) .data? ofn OPENFILENAME <> .code invoke SendMessage, hCapture, WM_CAP_GRAB_FRAME, 0, 0 invoke FillBuffer,addr szFileName,length szFileName,0 invoke SaveFileName,hWnd,addr szTitle,addr szFilterBMP .if szFileName[0] != 0 invoke SendMessage, hCapture, WM_CAP_SAVEDIB, 0, addr szFileName .endif FillBuffer proc lpBuffer:DWORD,lenBuffer:DWORD,TheChar:BYTE push edi mov edi, lpBuffer ; address of buffer mov ecx, lenBuffer ; buffer length mov al, TheChar ; load al with character rep stosb ; write character to buffer until ecx = 0 pop edi ret FillBuffer endp SaveFileName proc hParent:DWORD,lpTitle:DWORD,lpFilter:DWORD mov ofn.lStructSize, sizeof OPENFILENAME m2m ofn.hWndOwner, hParent m2m ofn.hInstance, hInstance m2m ofn.lpstrFilter, lpFilter m2m ofn.lpstrFile, offset szFileName mov ofn.nMaxFile, sizeof szFileName m2m ofn.lpstrTitle, lpTitle mov ofn.Flags, OFN_EXPLORER or OFN_LONGNAMES invoke GetSaveFileName, addr ofn ret SaveFileName endp
Код (Text): format PE GUI 4.0 entry codestart include 'win32a.inc' IDD_MAIN = 100 WM_CAP_DRIVER_CONNECT = WM_USER + 10 WM_CAP_DRIVER_DISCONNECT = WM_USER + 11 WM_CAP_FILE_SAVEDIB = WM_USER + 25 WM_CAP_SET_PREVIEW = WM_USER + 50 WM_CAP_SET_PREVIEWRATE = WM_USER + 52 WM_CAP_SET_SCALE = WM_USER + 53 ID_START = 201 ID_STOP = 202 ID_CLICK = 203 _camtitle db 'FASMWEBCAM' _filename db 'IMAGE.BMP' ; Filename nDevice dd 0 ; Device Number -> It can range from 0 through 9 nFPS dd 100 ; Frames per second. Must be 1000/FPS. E.g. 20 FPS = 50 section '.data' data readable writeable hInstance dd ? hWebcam dd ? section '.code' code readable executable codestart: invoke GetModuleHandle, 0 mov [hInstance], eax invoke DialogBoxParam, eax, IDD_MAIN, HWND_DESKTOP, MainDlg, 0 invoke ExitProcess, 0 proc MainDlg hdlg, msg, wparam, lparam push ebx esi edi cmp [msg], WM_INITDIALOG je .wminitdlg cmp [msg], WM_COMMAND je .wmcommand cmp [msg], WM_CLOSE je .wmclose xor eax, eax jmp .finish .wminitdlg: invoke capCreateCaptureWindow, _camtitle, WS_VISIBLE + WS_CHILD, 10, 10,\ 266, 252, [hdlg], 0 mov [hWebcam], eax jmp .finish .wmcommand: cmp [wparam], BN_CLICKED shl 16 + ID_START je .startbutton cmp [wparam], BN_CLICKED shl 16 + ID_STOP je .stopbutton cmp [wparam], BN_CLICKED shl 16 + ID_CLICK je .clickbutton .wmclose: invoke SendMessage, [hWebcam], WM_CAP_DRIVER_DISCONNECT, _camtitle, 0 invoke EndDialog, [hdlg], 0 .finish: pop edi esi ebx ret .startbutton: invoke SendMessage, [hWebcam], WM_CAP_DRIVER_CONNECT, [nDevice], 0 invoke SendMessage, [hWebcam], WM_CAP_SET_SCALE, TRUE, 0 invoke SendMessage, [hWebcam], WM_CAP_SET_PREVIEWRATE, [nFPS], 0 invoke SendMessage, [hWebcam], WM_CAP_SET_PREVIEW, TRUE, 0 jmp .finish .stopbutton: invoke SendMessage, [hWebcam], WM_CAP_DRIVER_DISCONNECT, _camtitle, 0 jmp .finish .clickbutton: invoke SendMessage, [hWebcam], WM_CAP_FILE_SAVEDIB, 0, _filename jmp .finish endp section '.idata' import data readable writeable library kernel, 'KERNEL32.DLL',\ user, 'USER32.DLL',\ avicap, 'AVICAP32.DLL' import kernel,\ GetModuleHandle,'GetModuleHandleA',\ ExitProcess, 'ExitProcess' import user,\ DialogBoxParam, 'DialogBoxParamA',\ EndDialog, 'EndDialog',\ SendMessage, 'SendMessageA' import avicap,\ capCreateCaptureWindow, 'capCreateCaptureWindowA' section '.rsrc' resource data readable directory RT_DIALOG, dialogs resource dialogs,\ IDD_MAIN, LANG_ENGLISH + SUBLANG_DEFAULT, main_dialog dialog main_dialog, 'FASM Webcam', 0, 0, 190, 200, WS_CAPTION + WS_POPUP + WS_SYSMENU +\ DS_MODALFRAME + DS_CENTER dialogitem 'BUTTON', 'START', ID_START, 10, 170, 50, 20, WS_VISIBLE + WS_TABSTOP dialogitem 'BUTTON', 'STOP', ID_STOP, 70, 170, 50, 20, WS_VISIBLE + WS_TABSTOP dialogitem 'BUTTON', 'CLICK', ID_CLICK, 130, 170, 50, 20, WS_VISIBLE + WS_TABSTOP enddialog
DirectShow в самый раз. Capture API уже устаревшая технология. Не все камеры поддерживают ее. особенно внешние