问题
I am using DirectShow.Net to stream a webcam to my C# (4.0) app for reading QR codes. It is taking a snapshot every .5 seconds to see if it can find any QR codes and decode them. This works great on my dev computer at any resolution I can get my webcam to, but when I try it on a target machine (Panasonic CF-U1 Toughbook - Intel Atom processor) it really starts to bog down when I go to a higher resolutions than 800x600 on the webcam.
I am using the Capture class from the DirectShow.Net DxSnap sample (namespace Snapshot). I am passing in to it a Picturebox to draw the preview on. I am pretty sure this is what is bogging down the system (guessing the video card just isn't up to the task). I need to have the preview drawn (so the users can see what they are trying to scan), but it doesn't have to be at the same resolution as the picture that gets taken to look for a QR code. Since this program is made for devices with low screen resolutions the preview box maxes out at 320 x 240 (I do adjust the aspect ratio in accordance with the resolution selected on the camera).
So I guess what I'm looking for is any of the following:
A way to have two streams going from the same webcam, one at low res for preview and one at high res for capture
Something that equates to that, maybe reducing the resolution right before it gets written to the picture box (once again, using the Capture class from the DxSnap sample from the DirectShow.Net project)
A way to keep the picture box from being refreshed so much
Something other than DirectShow.Net to use for this kind of thing (it has to work with everything from Windows XP to Windows 8 in the desktop space).
Thanks for your help.
回答1:
- You can split the stream using a SmartTee or InfiniteTee, but I'm not sure how to change the resolution after you've split it.
- Not sure how to do this.
- You could capture the images and manually place them into the picture box using a SampleGrabber. Then, you have complete control of when the frames are shown in the picture box.
- If you want XP and up, you'll need to use DirectShow. MediaFoundation (the modern alternative) is only Vista and up.
My application is currently capturing images at a different resolution than the resolution of the video being seen by the user. I'm doing this because the webcam I'm using (Logitech C920) has both a Capture pin and a Still pin, which have different listings of video formats. I'm able to get the set of resolutions for each pin independently, and change the one I need to. My application is only concerned with the Still pin's resolution, so I change that while the Capture pin remains at 640 x 480 at all times. I believe the SmartTee is supposed to do something similar to this without the need of a Still pin, but I'm not a DirectShow guru, so someone else would need to fill you in with that information.
来源:https://stackoverflow.com/questions/18039130/capturing-pictures-from-webcam-at-high-resolution-while-previewing-at-a-lower-on