USB Cam Feed Not Displaying In Picturebox Using C# And Aforge

I have a C# Winforms project in which I have to capture an image from an external webcam (Logitech HD Pro C920). I am using the Aforge media library. The list of video input devices are showing up, and the laptop's internal webcam is connecting and the stream is being displayed in the picturebox.

However the stream from the USB cam is not being displayed in the picturebox even though it is listed as a video input device. The relevant code is shown below:

cam = new VideoCaptureDevice(webcam[cbCameras.SelectedIndex].MonikerString);
cam.NewFrame +=new NewFrameEventHandler(cam_NewFrame);
cam.Start();

void cam_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
    Bitmap bit = (Bitmap)eventArgs.Frame.Clone();
    picPhoto.Image = bit;
}

Where am I missing it? Thanks

From the question asked on here before How initialize AForge webcam

public Form1() // init
{
    InitializeComponent();
    {
        VideoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
        foreach (FilterInfo VideoCaptureDevice in VideoCaptureDevices)
        {
            comboBox1.Items.Add(VideoCaptureDevice.Name);
        }
        comboBox1.SelectedIndex = 0;
    }
}

private void button1_Click(object sender, EventArgs e)
{
    FinalVideo = new VideoCaptureDevice(VideoCaptureDevices[comboBox1.SelectedIndex].MonikerString);
    FinalVideo.NewFrame += new NewFrameEventHandler(FinalVideo_NewFrame);
    FinalVideo.Start();
}

void FinalVideo_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
    Bitmap video = (Bitmap)eventArgs.Frame.Clone();
    pictureBox1.Image = video;

}

private void button2_Click(object sender, EventArgs e)
{
    FinalVideo.Stop();
}
}

Display Web Cam Stream on PictureBox – Aforge, Notify me of new posts via email. Categories .NET · ASP · Batch Files · C# · Android  You need to add reference of Aforge Imaging Aforge Imaging Filters Aforge Video Aforge Video DirectShow Reference the following files in your code by the 'using' keyword like: FilterInfoCollection Captures the video devices connected to the machine: VideoCaptureDevice is used to Capture Stream from a FilterInfoCollection object or a cam

Try this:

public VideoCapabilities[] videoCapabilities;
videoCapabilities = Cam.VideoCapabilities;
Cam.VideoResolution = videoCapabilities[0];

C# and USB IR camera, The PictureBox is not a helper but rather a hassle here. For the video feed (video preview) from USB camera, see, for example, these  The list of video input devices are showing up, and the laptop's internal webcam is connecting and the stream is being displayed in the picturebox. However the stream from the USB cam is not being displayed in the picturebox even though it is listed as a video input device.

Finally I found the solution by changing the way I used to select the webcam. Now, I opted for the form provided by AForge (VideoCaptureDeviceForm).

Here is the Code:

private void BtnCamSelection_Click(object sender, RoutedEventArgs e)
{
    VideoCaptureDeviceForm form = new VideoCaptureDeviceForm();
    if(form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
    {
        this.pVideoSource = form.VideoDevice;

    }

}

Then, I loaded the aforge:VideoSourcePlayer with the variable pVideoSource.

[Solved] VB.NET Image Processing from WebCam, Detecting it with a webcam video stream seems like a straightforward approach. I did not have a chance to use this aforge videosurceplayer box that you are talking about, however, NewFrameEventArgs) Handles cam. I've tried the Sub below and again get nothing in my PictureBox To display as  Access to USB cameras and video files using DirectShow. AForge.NET framework provides classes to access USB web cameras and video files using DirectShow API. Since all the classes implement common interface, accessing USB camera is made as easy, as accessing video files or JPEG/MJPEG streams.

Forums • View topic - PictureBox Crash, I'm working with C# and Aforge. (I'm not informatic, I'm hardware electronic). I capture and image from my own usb camera with my own dll that  framework does not handle 16 bpp grayscale images at all, throwing exception when user tries to display them. Color images with 48 bpp and 64 bpp are "kind of" supported, but only maximum of 13 bits for each color plane are allowed.

C# - Experiencing memory issues with filtering 1080P , The program always displays a video feed, and then based on a the code (one using a videosource and picturebox, and the other using a private bool CAMACTV = false; //flag to indicate whether or not the camera should  In most cases this AForge.NET framework will not require other libraries except basic c# libraries. In references you can find some cool things done using Aforge.NET framework. In this post I’m going to explain on very basic application, which allows you to start & stop displaying web cam input and store a captured image.

aforge/Release notes.txt at master · cureos/aforge · GitHub, The version updates licensing of AForge. causing some issue on the USB side, making it hardly possible to gracefully stop Updated project/solution files of all sample to use C# express edition 2010. Issue 216: Camera is not working Issue 227: AccessViolationException when PictureBox displaying 16bpc image. [ Natty] c# USB Cam Feed Not Displaying In Picturebox Using C# And Aforge By: user11773256 4.0; [ Natty ] python Remove everything from a frame in pyqt By: Piontk 3.0 ;

Comments
  • How is the capture part different from the code i posted?
  • Can you please add explanation also?