2

I'm using the dxSnap sample from the directshownet library http://directshownet.sourceforge.net/about.html to capture an image from my webcam. Does anybody know how to flip the video capture horizontally?

MattBH
  • 1,562
  • 3
  • 24
  • 31

4 Answers4

1

In some cases it is possible by specifying a negative height in the BITMAPINFOHEADER, see Top-Down vs. Bottom-Up DIBs.

Herman
  • 2,738
  • 19
  • 32
1

Look at the DXSnap example in the samples to see how the ISampleGrabber interface is setup... it grabs a sample image from the sample grabber callback... with a little work you can sup an event to get frames as bitmaps...

The correct way to do this would be to create or find a filter to add to your graph that supports flipping the frame... MontiVision makes some great filters...not cheep though.

some camera's actually support this. if you have a logitec you can google for the C# COM interface wrapper that you can add to your graph,most cases the video orientation has to be defined before the graph is started.

devHead
  • 794
  • 1
  • 15
  • 38
1

I achieved your desired effect but I used the AForge Framework (it uses the DirectShow interface to access video sources). All I did was to call an event handler on every new frame and flip those frames horizontally:

private void video_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
    eventArgs.Frame.RotateFlip(RotateFlipType.RotateNoneFlipX);
}
1

Two ways: 1) Add the Sample Grabber filter after the webcam, provide it with a callback and when your callback gets the data just flip them inplace. 2) (easier) After you got the picture, use GDI (BitBlt) or any other methods to flip a picture.

Dee Mon
  • 1,016
  • 6
  • 7