Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Show webcam video in GDI window

2012-04-28
2012-10-29
  • Stringtheory
    Stringtheory
    2012-04-28

    I've got a current C# GDI app, and I'd like to be able to display live video
    from a webcam 'under' GDI-based graphics. IOW, overlay the video with GDI-
    drawn lines, etc. Is that possible with DShow.net?

     
  • snarfle
    snarfle
    2012-04-28

    Have you checked out the DxText sample?

     
  • Stringtheory
    Stringtheory
    2012-04-28

    I will, thanks.

     
  • snarfle
    snarfle
    2012-04-28

    There are some limitations to this approach to writing GDI. In particular, the
    graph must be running (not paused or stopped).

     
  • Stringtheory
    Stringtheory
    2012-04-29

    I figured there would be complications, hence the question. I haven't worked
    with DirectShow for ages, and when I did, there was nothing overlaying the
    video, so no continual GDI redraw concerns on each frame. I was curious about
    whether there was a (possibly hardware-access based?) mechanism to draw the
    DirectShow video and GDI each in a separate 'layer'. That's probably wishful
    thinking.

     
  • snarfle
    snarfle
    2012-04-29

    By doing the steps in DxText, you are actually modifying the frames in the
    stream. If your graph ends up writing to disk, the modified frames are what
    get written.

    Alternately, you can draw things on the window. You've got the window handle
    to the panel, so it should be do-able.

    I'm not enough of a graphics expert to talk about hardware-access based video
    functions. However like I say, if you aren't interested in actually modifying
    the stream, just changing what is on the display...

     

  • Anonymous
    2012-04-30

    I don't need to save the video stream, just monitor it. So maybe the direct
    route would work. It seems that I would have to redraw the overlayed graphics
    at the video framerate though. I was hoping that there was some sort of
    overlay scheme that would allow the video to procede independantly 'under' the
    GDI layer. But I'll see if I can refresh the graphics fast enough. Maybe with
    reduced framerate that would work.

     

  • Anonymous
    2012-04-30

    PS: I will need to eventually freeze the frame and capture a still jpg, but
    that's another thing entirely.

    And I presume that most machines won't do the video watermark thing at full
    30fps framerate.

     
  • snarfle
    snarfle
    2012-04-30

    Would you really have to draw at the framerate? As I said, I'm no expert on
    graphics drawing, but I'd think you could do something using transparency.

    Unless you are doing a lot of drawing, I don't believe watermarking will be
    the burden you are thinking.

     

  • Anonymous
    2012-04-30

    Would you really have to draw at the framerate? As I said, I'm no expert on
    graphics drawing, but I'd think you could do something using transparency

    I'm curious about how that would work. The incoming video frame will write all
    the pixels, correct? If multiple layers are not available, that would seem to
    continually overwrite any graphics within that screen area. Transparency in
    GDI is normally just an Alpha value that exists as the 4th byte within the RGB
    pixel (one byte per color), so the Alpha would be overwritten along with
    everything else.

     
  • snarfle
    snarfle
    2012-04-30

    And what if you have 2 panels overlapping?