secile / UsbCamera

C# source code for using usb camera and web camera in WinForms/WPF. With only single CSharp source code. No external library required.
MIT License
179 stars 55 forks source link

On Capture Callback #16

Closed EugeneQilo closed 1 year ago

EugeneQilo commented 1 year ago

Hello @secile, What you have here is gold. Thank you for putting it together.

Is it possible to pass a callback function on capture? This is essential for cameras which have an external capture button. We need to have a way to detect it and either manually trigger a GetBitmap or the event will take one and pass it to the callback function.

secile commented 1 year ago

Hello, EugeneQilo. Thank you! I'm very happy to hear such a word.

I currently have no idea how to support capture button, Please give me some time to research.

Basically, I want to support capture button if possible.

EugeneQilo commented 1 year ago

@secile this article explains it very well... Just needs someone who can understand C++ properly... https://learn.microsoft.com/en-us/windows/win32/directshow/capturing-an-image-from-a-still-image-pin

Don't forget to add a check to see if the Still pin is exposed... it may not be

secile commented 1 year ago

This is developing version. could you test it and please let me know it works fine or not. I uploaded UsbCamera.cs compressed with zip.

UsbCamera.zip

[How to use]

// check still image available
if (camera.StillImageAvailable)
{
    // if you use software trigger, call camera.StillImageTrigger()
    button1.Click += (s, ev) => camera.StillImageTrigger();

    camera.StillImageCaptured += bmp =>
    {
        // called when still image captured.
        pictureBox1.Image = bmp;
    };
}
EugeneQilo commented 1 year ago

@secile thank you very much for the effort.. It will take a me a few days to test this since I don't have a camera with capture button with me at the moment. Will keep you updated.

secile commented 1 year ago

Hello. Does developing version works fine? could you test it and please let me know it works fine or not.