Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports AForge.Video.DirectShow
- Public Class Form1
- Private Dispositivos As FilterInfoCollection
- Private FuenteDeVideo As VideoCaptureDevice
- Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
- Dispositivos = New FilterInfoCollection(FilterCategory.VideoInputDevice)
- For Each x As FilterInfo In Dispositivos
- ComboBox1.Items.Add(x.Name)
- Next
- ComboBox1.SelectedIndex = 0
- End Sub
- Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
- FuenteDeVideo = New VideoCaptureDevice(Dispositivos(ComboBox1.SelectedIndex).MonikerString)
- VideoSourcePlayer1.VideoSource = FuenteDeVideo
- VideoSourcePlayer1.Start()
- End Sub
- Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
- VideoSourcePlayer1.SignalToStop()
- End Sub
- Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
- 'DIALOGO PARA SELECCIONAR LA RUTA PARA GUARDAR
- Dim sf As New SaveFileDialog()
- 'FILTO DE IMAGENES JPG
- sf.Filter = "Imagenes JPG | *.jpg"
- 'MOSTRAR DIALOGO
- sf.ShowDialog()
- 'ASEGURAR QUE TIENE UNA RUTA VALIDA
- If sf.FileName IsNot Nothing Then
- 'VARIBALE PARA LA IMAGEN
- Dim img As Bitmap = VideoSourcePlayer1.GetCurrentVideoFrame()
- 'GUARDAR IMAGEN EN LA RUTA
- img.Save(sf.FileName, System.Drawing.Imaging.ImageFormat.Jpeg)
- 'BORRAR IMAGEN DE MEMORIA
- img.Dispose()
- 'PROBAR!!!
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment