none
Does .NET (native) have ability to, connect to and manually capture images from webcam? Not looking for 3rd party. RRS feed

  • Question

  • Hi all...

    Does .NET have built in abilities to connect to a webcam and manually stream from it?  As I mentioned in the title, I'm not wanting to use 3rd party libs.  Rather hoping to find something directly from Microsoft that I can use. Business reasons for wanting to stay away from 3rd party.

    If not anything that's C#(managed) what would be the best option from the C++ APIs that could be wrapped with C#?


    Rick

    Monday, February 25, 2019 4:25 AM

All replies

  • C# offers WIA that allow you to capture webcam stream. However the device need to have WIA support.

    Also check DirectShow as mentioned in here, but it requires 3rd party wrapper library (or you can port yourself with the C++ header files in Visual Studio installation).



    Monday, February 25, 2019 5:32 AM
    Answerer
  • That looks like it's all C++.  

    Rick

    Monday, February 25, 2019 5:41 AM
  • That's why a wrapper library is needed.

    Write your own wrapper library if the project cannot include a 3rd party library(DirectShow.NET was released under LGPL) due to licensing restriction, or use 3rd party wrapper library if you don't want to write code yourself.


    Monday, February 25, 2019 6:03 AM
    Answerer
  • Yes, but your initial reply said that C# offered WIA. 

    Rick

    Monday, February 25, 2019 6:49 AM
  • You can use Type.GetTypeFromProgId() with Actuator.CreateInstnace() to use them without C++ library, much like the techniques used here. (I've used something like this before for WIA with still image, so pretty sure it can be called this way without problem)

    However, I'm not sure whether you can do it this way with DirectShow.

    Monday, February 25, 2019 6:57 AM
    Answerer
  • However, I'm not sure whether you can do it this way with DirectShow.

    Yes, I already tested it to enumerate devices

    For example, for : ICreateDevEnum::CreateClassEnumerator

    public enum HRESULT : int { S_OK = 0, S_FALSE = 1, E_NOINTERFACE = unchecked((int)0x80004002), E_NOTIMPL = unchecked((int)0x80004001), E_FAIL = unchecked((int)0x80004005) } [ComImport] [Guid("29840822-5B84-11D0-BD3B-00A0C911CE86")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface ICreateDevEnum { HRESULT CreateClassEnumerator(ref Guid clsidDeviceClass, out IEnumMoniker ppEnumMoniker, int dwFlags); } [ComImport] [Guid("00000102-0000-0000-C000-000000000046")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IEnumMoniker { HRESULT Next(uint celt, out IMoniker rgelt, out uint pceltFetched); HRESULT Skip(uint celt); HRESULT Reset(); HRESULT Clone( out IEnumMoniker ppenum); }

    // etc...




    • Edited by Castorix31 Monday, February 25, 2019 8:21 AM
    Monday, February 25, 2019 8:20 AM
  • And with Google and DirectShow keywords, you can find some samples in C#, like

    DirectXCapture_demo_Enhanced2.zip (or other link)

    (I downloaded it but cannot test it (no Webcam...))



    • Edited by Castorix31 Monday, February 25, 2019 9:47 AM
    Monday, February 25, 2019 9:46 AM
  • check this  pictures



    Tuesday, February 26, 2019 3:34 AM
  • Hi m00n,

    Thank you for posting here.

    For your question, you want to capture images from webcam manually in .NET.

    You could refer to the following link to get it.

    https://www.codeproject.com/Articles/489432/Webcam-in-Csharp-Easiest-Way-to-Capture-Images-fro

    Hope my advice could be helpful.

    Best regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, February 26, 2019 6:31 AM
    Moderator
  • Not a good example because the code uses a 3rd party component to acquire image from WIA, DirectShow and possibly TWAIN (although not listed in the component), but 3rd party solution is explicitly called "not wanted" here.
    Wednesday, February 27, 2019 1:56 AM
    Answerer
  • Hi

    Is your problem solved? If so, please post "Mark as answer" to the appropriate answer, so that it will help other members to find a solution quickly if they face a similar issue.

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Thursday, February 28, 2019 3:22 AM
    Moderator
  • Hi jack, not yet. Thanks for asking though.

    Rick

    Thursday, February 28, 2019 5:06 AM
  • check this  pictures




    Interesting but can it be used in a normal Windows Form app?

    Rick

    Thursday, March 7, 2019 1:57 AM
  • try this

    maybe help

    Camera

    Windows Image Acquisition Architecture

    Thursday, March 7, 2019 2:58 AM
  • try this

    maybe help

    Camera

    Windows Image Acquisition Architecture

    Hey, thanks.  Interesting project!  I might be able to use this as a starting point!. 

    Rick

    Thursday, March 7, 2019 4:15 AM
  • Please remember to click "Mark as Answer" the responses that resolved your issue
    Saturday, March 9, 2019 2:24 AM