问题
I want to use DirectShow.Net to capture the stream from a webcam.
What type of UI control can I use to display a the webcam video capture?
I have seen an example that uses the whole window of a Form, but are there any other controls I can use: a Panel, PictureBox?
回答1:
yes. you can use pictureboxes or forms or panels.
You need to call and use IVideoWindow. you can cast the directshow.net graph that is streaming/capturing to the IVideoWindow and then you can set it to being owned by whatever object you want to put your video stream into. just have to give it the objects handle and then set its windowstyle to child of the parent object.
IVideoWindow videowindow;
videowindow = FirstGraph as IVideoWindow;
videowindow.put_Owner(panel1.Handle);
videowindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipChildren);
回答2:
http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C - its not formatted, but it has a code that actually implants what you need.
来源:https://stackoverflow.com/questions/6737581/c-sharp-control-to-display-camera-video-with-directshow-net