0

I capture images by a Logitech web camera with the resolution 640x480 in c# using AForge. I get images with low quality relative to the images taken by the Logitech's program with the same camera. The images are with grains and noise and are about 80kb instead of 300kb.

Is there any way to capture images with original quality?

Thanks in advance.

videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
videoSource = new VideoCaptureDevice(videoDevices[0].MonikerString);
videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
videoSource.VideoResolution = videoSource.VideoCapabilities[0];
videoSource.Start();

private void video_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
    img = (Bitmap)eventArgs.Frame.Clone();
    CurrentImagePBX.Image = img;
}

private void WebCamFunction(object source, ElapsedEventArgs e) // on timer
{
    Bitmap CurrentImage = (Bitmap)img.Clone();
    string filename = DateTime.Now.ToString("dd_MM_yyyy_HH_mm_ss") + ".jpg";
    CurrentImage.Save(filename, System.Drawing.Imaging.ImageFormat.Jpeg);
    SavedImagePBX.Image = CurrentImage;
}
Victor
  • 1
  • 4
  • Any particular reason why you are saving a Bitmap into a Jpeg? Possible cause is that you are assuming that the image is a bitmap which is uncompressed unlike jpeg (compressed) – jegtugado Oct 24 '16 at 04:17
  • `Bitmap.Save` has an overload which takes encoder parameters, within which you can set the output quality. Here's a good example from msdn: https://msdn.microsoft.com/library/ytz20d80.aspx – Simon MᶜKenzie Oct 24 '16 at 05:16
  • Thank you. Indeed, I can control the quality according to this example, and it helps. – Victor Oct 25 '16 at 06:03

0 Answers0