Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to capture an image from an USB WebCam?

How to capture an image from an USB WebCam?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    Is there any way to capture an image from an USB WebCam?

    G C 2 Replies Last reply
    0
    • A Anonymous

      Is there any way to capture an image from an USB WebCam?

      G Offline
      G Offline
      GermanGeorge
      wrote on last edited by
      #2

      yes there is. here is what you have to do: 1) use the code you find below 2) create a BITMAPINFOHEADER 3) write the BITMAPINFOHEADER and the bitmap, that is captured below to a file. hdcScreen = CreateDC("DISPLAY", NULL, NULL, NULL); hdcCompatible = CreateCompatibleDC(hdcScreen); hbmScreen = CreateCompatibleBitmap(hdcScreen, Videobild.right, Videobild.bottom); if (hbmScreen == NULL) MessageBox("Bmp konnte nicht erstellt werden"); hbmScreen = ::CreateDIBSection(dc.GetSafeHdc(), (LPBITMAPINFO) m_dibFile.m_lpBMIH,DIB_RGB_COLORS, (LPVOID*) &m_dibFile.m_lpImage, NULL, 0); GDIObject=SelectObject(hdcCompatible, hbmScreen); if(GDIObject==NULL) MessageBox("Object konnte nicht selected werden"); if (!BitBlt(hdcCompatible, 0,0, Videobild.right, Videobild.bottom, hdcScreen, Videobild.left,Videobild.top, SRCCOPY)) MessageBox("Object konnte nicht geBitBltet werden");

      1 Reply Last reply
      0
      • A Anonymous

        Is there any way to capture an image from an USB WebCam?

        C Offline
        C Offline
        c mora
        wrote on last edited by
        #3

        There is always a way. I haven't actually looked at it for 2 years, so I can't help you directly. You'll probably want to look at DirectShow, everything that you want should be there. I believe I remember an example program in the SDK called Stillcap. Anyway good luck.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups