Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Cam Capture


Published on

Capturing web cam frames with a .Net application

Published in: Technology, Art & Photos
  • Be the first to comment

  • Be the first to like this

Cam Capture

  1. 4. <ul><li>Incorporating video capturing capabilities into our application. </li></ul><ul><li>Connecting </li></ul><ul><li>Listing available video capture devices </li></ul>
  2. 5. <ul><li>Used to manipulate various windows. </li></ul>
  3. 6. <ul><li>Mechanism of .Net language calling unmanaged functions in DLL’s. </li></ul><ul><li>Calling Windows API functions </li></ul><ul><li>Calling third-party functions provided in DLLs </li></ul>
  4. 7. <ul><li>List all available capture devices installed in the system </li></ul><ul><li>Select the appropriate device </li></ul><ul><li>Create a capture window </li></ul><ul><li>Connect the camera </li></ul><ul><li>Start camera preview and capture </li></ul><ul><li>Disconnect camera </li></ul><ul><li>Stop Recording and release memory </li></ul>
  5. 8. <ul><li>Dim DriverName As String = Space(80) </li></ul><ul><li>Dim DriverVersion As String = Space(80)  </li></ul><ul><ul><li> capGetDriverDescriptionA(0, DriverName, 80,DriverVersion, 80) </li></ul></ul><ul><li>   </li></ul><ul><li>Declare Function capGetDriverDescriptionA Lib &quot;avicap32.dll&quot; _ </li></ul><ul><li> (ByVal wDriverIndex As Short, _ </li></ul><ul><li> ByVal lpszName As String, ByVal cbName As Integer, _ </li></ul><ul><li> ByVal lpszVer As String, _ </li></ul><ul><li>ByVal cbVer As Integer) As Boolean </li></ul>
  6. 10. <ul><li>Private windowHandle As Integer </li></ul><ul><li>Const WS_CHILD = &H40000000 </li></ul><ul><li>Const WS_VISIBLE = &H10000000 </li></ul><ul><li>nID = 0 (index of camera) (eg: index is 1 then nID=1) </li></ul><ul><li>windowHandle = capCreateCaptureWindowA(&quot;My Cam&quot;, WS_CHILD Or WS_VISIBLE, xPos, yPos, wWidth, wHight, parentHandle, nId) </li></ul>
  7. 11. <ul><li>Private Declare Function capCreateCaptureWindowA Lib &quot;avicap32.dll“ (ByVal lpszWindowName As String, ByVal dwStyle As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Short, ByVal hWndParent As Integer, ByVal nID As Integer) As Integer </li></ul>
  8. 12. <ul><li>Const WM_CAP_START = &H400S  </li></ul><ul><li>Const WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10 </li></ul><ul><li>SendMessage(windowHandle, WM_CAP_DRIVER_CONNECT, 0, 0) </li></ul>
  9. 13. <ul><li>Private Declare Function SendMessage Lib &quot;user32&quot; Alias &quot;SendMessageA&quot; (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Int32, ByVal lParam As Int32) As Integer </li></ul>
  10. 14. <ul><li>Const WM_CAP_SET_PREVIEWRATE = WM_CAP_START + 52 </li></ul><ul><li>Const WM_CAP_SET_PREVIEW = WM_CAP_START + 50 </li></ul><ul><li>Private frameRate As Integer = 25 </li></ul><ul><li>'---start previewing the image--- SendMessage(windowHandle, WM_CAP_SET_PREVIEW, 1,0) </li></ul><ul><li>'---set the preview rate ---   </li></ul><ul><li>SendMessage(windowHandle, M_CAP_SET_PREVIEWRATE, frameRate, 0) </li></ul><ul><li>‘ --- Capturing--- </li></ul><ul><li>SendMessage(windowHandle, WM_CAP_SEQUENCE, 0, 0) </li></ul>
  11. 15. <ul><li>SendMessage(windowHandle, WM_CAP_DRIVER_DISCONNECT, 0, 0) </li></ul>
  12. 16. <ul><li>SendMessage(windowHandle, WM_CAP_STOP, 0, 0) </li></ul><ul><li>'-- This function destroys the specified window — </li></ul><ul><li>DestroyWindow(windowHandle) </li></ul><ul><li>Declare Function DestroyWindow Lib &quot;user32&quot; _ (ByVal hndw As Integer) As Boolean </li></ul>