Page 1 of 1

How do I detect the button input from my webcam?

PostPosted: Thu Aug 01, 2019 4:04 am
by JansenSensei
Hi

I noticed in the one demo it is possible to tell my application that I just pressed the button on my webcam and then it shows the save form. the problem is that I am not making a WinForms application and I can't seem to find any mention on the website, the documentation or even in the code itself how that button press was detected.

Is this something done by AForge or is this something native to WinForms?

I just need to know that my button was pressed and I am trying to install AForge into my application for this sole purpose but I am getting all manner of errors and even copy pasting the code from the demo does not work. I am really struggling here and am at the point where I need to ask for help...

Please, anyone... How can I detect that a button was pressed on my webcam? This Aforge demo is the one and only demo I have found that shows it is possible... I just can't figure out how this demo is doing it. I am thinking it must be WinForms itself that has that functionality built in and not AForge but if I am wrong then someone please show me what I am not seeing :(

Thanks

Re: How do I detect the button input from my webcam?

PostPosted: Thu Aug 01, 2019 7:08 am
by andrew.kirillov
Hello,

It has nothing to do with WinForms. VideoCaptureDevice class provides the SnapshotFrame event, which is triggered when button is pressed on a video camera and a snapshot is made.

Re: How do I detect the button input from my webcam?

PostPosted: Thu Aug 01, 2019 8:53 am
by JansenSensei
Oh thank goodness I finally have a solid lead!!!! :D
Thank you!!! :D

So let me see if I have this right: VideoCaptureDevice will automatically scan for input all the time as long as I have an active instance so all have to do is:
1. Create an instance of it
2. Register to that event
...and that is basically it... Right?

If so then this is going to make a lot simpler for me!
Now I just have a follow up question but I first need to see if this is already asked and possibly create a new question for that... TLDR version: That demo works just fine but when I copy paste teh code to my own project it doesn't detect any input devices of any kind and thus it refuses to create a VideoCapture Device.... :( But yeah, that is a separate question....

Re: How do I detect the button input from my webcam?

PostPosted: Thu Aug 01, 2019 9:01 am
by andrew.kirillov
JansenSensei wrote:1. Create an instance of it
2. Register to that event
...and that is basically it... Right?

You also need to tell that you want getting those snapshots/event. See ProvideSnapshots property.

JansenSensei wrote:That demo works just fine but when I copy paste teh code to my own project it doesn't detect any input devices of any kind and thus it refuses to create a VideoCapture Device....

Maybe the amount of code you've copied is not enough. Maybe you need to copy more. Don't know. Check the demo again, what it does and what is missing in your app.

Re: How do I detect the button input from my webcam?

PostPosted: Thu Aug 01, 2019 9:20 am
by JansenSensei
Ah... An important step I would have missed. Thanks!