0

Does anybody know if there is a working sample of a webcam capture that works in net framework 4?. I tried a lot of samples:

Aforge (in 4.0 it shows me that my camera is not supported)

Emgu (shows me "System.TypeInitializationException")

webcam.dll (the picturebox stays blank)

etc.

But when I change the net framework to 3.5 all the samples works fine.

I just want to capture my webcam into a picture box but its neccesary for me make it work in net framework 4 or even 4.5

Thank you all.

Alan Alvarez
  • 646
  • 2
  • 11
  • 32

1 Answers1

0

This works for me..

Get EMGU using NuGet package manager.

Create a picturebox called PictureBox1

Create a Timer called Timer1

Create a button called Button1

Use this code - click on the button to start the timer which captures the webcam images. If you're ge

Imports Emgu.CV

Public Class Form1
    Dim capturez As Capture = New Capture()
    Dim imagez As Image

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        capturez.Start()
        imagez = CType(capturez.QueryFrame.Bitmap.Clone, Bitmap)
        PictureBox1.Image = imagez
        capturez.Stop()
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Timer1.Enabled = True
    End Sub

End Class
David Wilson
  • 4,369
  • 3
  • 18
  • 31
  • Thanks David, I tried but it shows me: "'System.Runtime.InteropServices.SEHException' en Emgu.CV.World.dll" and External component exception and marks the line: "Dim capturez As Capture = New Capture()" – Alan Alvarez May 27 '16 at 15:02
  • I change it the net framework to 3.5 and worked but is not working on net framwork 4 or 4.5 – Alan Alvarez May 27 '16 at 15:18
  • Hmm. I'm away for the weekend, so not near my pc. Does it make a difference whether you compile for 64 bit or x86? – David Wilson May 27 '16 at 22:36
  • I´m not able to get 64bits equipment :( but I saw something weird, When I try with Aforge to run it from Visual Studio (2015) happens what I told you before, but when I run it from the .exe (in Debug folder) it works, I´m really confused, Is this a bug of Visual Studio? In this thread three people have the same issue with no solution: https://social.msdn.microsoft.com/Forums/es-ES/8d1056a3-c81e-4d9e-b6bf-ecdf1a2e58a7/webcam-con-framework-40?forum=vcses – Alan Alvarez May 29 '16 at 02:08
  • One thing I did find was this post relating to emgu - though I dont know if it will help- http://stackoverflow.com/questions/11369684/emgucv-typeinitializationexception – David Wilson Jun 01 '16 at 07:43