So I am using this one library that I found online that is supposed to make it super easy to use my webcam with C#, so I decided to give it a go. The project I am mimicing is using WPF or WinForms, there are two of them. I decided I wanted to create a console version of this, now there are a few minor issue, regarding controls and what not but I seem to be all of that under control the issue I am facing is that it's stepping out of its logic for reasons unknown.
This is how it's supposed to flow. (and it does in WPF)
webcam.Start(); -> webcam.Start(0); Starts the webcam here -> webcam_ImageCaptured() -> LoadBitmap() -> webcam_ImageCaptured() -> LoadBitmap() -> webcam_ImageCaptured() and loop through those last two
And here is what mine does (Console Application)
webcam.Start(); -> webcam.Start(0); Starts the webcam here -> and then it steps out of webcam.Start(); and closes.
I have no idea what so ever to why it behaves like this and I would really like to know, Been debugging back and forth but I really cant seem to solve the mystery here.
Here is the Console applications Main
class Program
{
static WebCam webcam;
static System.Windows.Controls.Image image = new System.Windows.Controls.Image();
[STAThread]
static void Main(string[] args)
{
webcam = new WebCam();
webcam.InitializeWebCam(ref image);
webcam.Start();
}
}
And the WebCam class https://ghostbin.com/paste/kvvx2
And the Helper class https://ghostbin.com/paste/vk8qz
And this is the Main for the WPF application
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
WebCam webcam;
private void mainFrm_Loaded(object sender, RoutedEventArgs e)
{
webcam = new WebCam();
webcam.InitializeWebCam(ref imgMain);
}
private void btnCapture_Click(object sender, RoutedEventArgs e)
{
webcam.Start();
}
}
Here is the original post where I found everything https://sites.google.com/site/webcamlibrarydotnet/wpf-and-csharp-sample-code-and-download