Kris Sarcida
Kris Sarcida

Reputation: 59

record video and capture image using webcam in vb.net

currently, im using a webcam in my thesis. one of my objective is to have a realtime camera that can record/capture a video at the same time can capture image. i dont know how to code it in vb.net. can anyone help me in my problem. thanks in advance.

Upvotes: 0

Views: 2713

Answers (2)

Oshant
Oshant

Reputation: 158

A simply solution is use Aforge lib for vb and c#

with this I get the cameras and resolutions, using 2 comboboxes

For Each x As FilterInfo In Dispositivos
    ComboBox1.Items.Add(x.Name)
Next
ComboBox1.SelectedIndex = 0
FuenteDeVideo = New VideoCaptureDevice(Dispositivos(ComboBox1.SelectedIndex).MonikerString)
For i As Integer = 0 To FuenteDeVideo.VideoCapabilities.Count() - 1
    FuenteDeVideo.VideoCapabilities(i).FrameSize.ToString()

    cbr.Items.Add(FuenteDeVideo.VideoCapabilities(i).FrameSize.ToString())
Next i

To start the video, we have to add a VideoSourcePlayer

FuenteDeVideo.VideoResolution = FuenteDeVideo.VideoCapabilities(cbr.SelectedIndex)
VideoSourcePlayer1.VideoSource = FuenteDeVideo
VideoSourcePlayer1.Start()

and to pic an image:

            Dim img As Bitmap = VideoSourcePlayer1.GetCurrentVideoFrame()
            img.Save(sf.FileName, System.Drawing.Imaging.ImageFormat.Jpeg)

You can find the documentation here http://www.aforgenet.com/

Upvotes: 0

Spiros Souliotis
Spiros Souliotis

Reputation: 175

It is actually the way you think about it.

Lets suppose you have a middle guy that captures your frames and gradually passes them as frames to your video guy.

If you think about buffering the frames in that middle guy, you could ask that middle guy for a specific video frame, while not caring about the guy that builds the video frames onto a video.

You can save that video frame you asked on a variable for example and convert it to a still image.

Upvotes: 1

Related Questions