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?
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.
In some cases it is possible by specifying a negative height in the BITMAPINFOHEADER
, see Top-Down vs. Bottom-Up DIBs.
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.
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);
}
精彩评论