0

I am creating video processing application. The application is written using a mixture of WPF and C++/CLI (a DLL). I currently connect to a machine vision camera and use a few functions in the camera's native driver e.g. I grab image data, I set hardware region-of-interest (roi).

I am currently using windows 10. The application is currently converted to UWP with the Desktop bridge.

What I would like is to use some sort of Hardware-Abstraction-Layer to connect to a range of cameras and to access image data and ROI functions (if available).

I was wondering if someone experienced in this could take me through the options (if they exist) and what are the main considerations.

When I web-search I get lost in the search results (for example, is Windows Media Foundation a possibility, if not why not etc.). Much of the web results are pretty old.

So really I would like someone to give me a few pointers so I can feel sure I am on the right track.

Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
user3079907
  • 133
  • 1
  • 10
  • I can recommend [CaptureManager SDK](https://www.codeproject.com/Articles/1017223/CaptureManager-SDK) - this is COM ActiveX dll which can be used on Windows 7, 8, 8.1, 10. It uses DirectShow and Window Media Foundation. There are Proxy classes for C#, WinRT, Java and Python language and platforms. – Evgeny Pereguda Apr 26 '17 at 11:58
  • Thanks for the link..I will take a look...However, right now I am hoping to avoid 3rd party libraries.... – user3079907 Apr 26 '17 at 12:37
  • You can try [Capturing Live-video from Web-camera on Windows 7 and Windows 8](https://www.codeproject.com/Articles/776058/Capturing-Live-video-from-Web-camera-on-Windows-an) it is C++ code for compiling of static library with some demos - C# DLL proxy, supporting two and more output, water mark injector. – Evgeny Pereguda Apr 26 '17 at 12:48
  • Thanks, it looks like Media Foundation is the way to go then....I will take a look at this other link in more detail later as I am tied up on something else.... – user3079907 Apr 26 '17 at 13:31
  • Thanks for the link. It looks like the call to MFEnumDeviceSources does not detect my usb camera (Thorlabs DCC1545M). I look here [link](http://stackoverflow.com/questions/24612174/mediafoundation-can%C2%B4t-find-video-capture-emulator-driver-but-directshow-does) and it mentions "the device must provide a kernel streaming (KS) minidriver in the video capture category. Media Foundation uses the PnP path to enumerate the device. If the device meets these criteria, there is no need to implement a custom media source.". Would this be why media foundation does not detect? – user3079907 Apr 27 '17 at 08:53
  • Media Foundation supports USB cameras via USB Video Class - UVC 1.1. It is common deriver type for many USB cameras. Only old, or very specific cameras (like USB cameras from Sony for PlayStation) do not support such driver - this driver was introduced since 2003. You wrote `The application is currently converted to UWP` - however, UWP is part of Windows Store platform - and Media Foundation is only way for working with USB cameras. Did you connected with Thorlabs DCC1545M via UWP? – Evgeny Pereguda Apr 27 '17 at 11:28
  • Sorry I had to check whether I could connect to the DCC1545M via UWP (and this took longer than I expected). Yes, I can connect. Actually I tried your software for "Update on C++/CLI, C# and WPF" and it did pick up the device name once but would not connect (e.g. no image capture). However, this happened once and for some reason, I cannot get it to detect again. The DC1545M is showing up in device manager and it says it is working. I use thorlabs software and it connects. Any ideas about how I can identify more information about what is going wrong...???? – user3079907 Apr 28 '17 at 10:46
  • I recommend debug code - each C# project has function `Enable native code debugging`. However, from [DCC1545M-Manual.pdf](https://www.thorlabs.com/drawings/c4f68ae3005282f8-0ADDD1A8-5056-010E-8673809569C84658/DCC1545M-Manual.pdf) I see that it compatible only with DirectShow - Not Media Foundation. Why you would not try SDK from THORLABS - manual is easy understand and it can be easy wrapped by C++/CLI, or by `Old` C code for C# project. More over, manual includes `Programming in C#` section. – Evgeny Pereguda Apr 28 '17 at 11:30
  • Thanks. Yes, I see what you mean. Going back to my original post then...would it be possible to enumerate all DirectShow AND Media Foundation cameras and to connect to either within a UWP app converted with Desktop Bridge. I am guessing that usb cameras will either support DirectShow or Media Foundation. What do you think??? – user3079907 Apr 28 '17 at 12:05
  • It is impossible use DirectShow cameras from UWP - in MSDN [Win32 and COM for Universal Windows Platform (UWP) apps (multimedia)](https://msdn.microsoft.com/en-us/library/windows/apps/mt592899.aspx). You can use DirectShow cameras from direct calling as COM object, but it is workable only on Desktop Windows with full supporting of COM. Universal Windows Platform (UWP) is a platform for programming on Desktop and Mobile - these are Windows with different architecture and UWP is an abstract layer for simple deploying on different platforms - it leads to limit functionality. – Evgeny Pereguda Apr 28 '17 at 12:39
  • Hi...thanks for your help. It would seem that the only way to support DirectShow cameras is to restrict the UWP apps to a desktop app and go through COM. This seems to be a adequate solution. If you like to copy and paste your answer into a post, I will accept as the answer. Thanks for your help. – user3079907 May 02 '17 at 03:20
  • If you have plan use DirectShow camera in WPF C# project - I can recommend project [CaptureManager](https://www.codeproject.com/Articles/1017223/CaptureManager-SDK) - the last version has effective code for rendering video via `System.Windows.Interop.D3DImage`. It allows get WPF Image component, which can be used like any image - as a texture, as brush. – Evgeny Pereguda May 02 '17 at 03:38

1 Answers1

0

It is impossible use DirectShow cameras from UWP - in MSDN Win32 and COM for Universal Windows Platform (UWP) apps (multimedia). You can use DirectShow cameras from direct calling as COM object, but it is workable only on Desktop Windows with full supporting of COM. Universal Windows Platform (UWP) is a platform for programming on Desktop and Mobile - these are Windows with different architecture and UWP is an abstract layer for simple deploying on different platforms - it leads to limit functionality.

Evgeny Pereguda
  • 553
  • 1
  • 4
  • 9