Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capturing image from WebCam in .Net Core 2.0

I'm developing an app in .Net Core 2.0 to run on a Raspberry Pi, which is running Win 10 IoT. The Pi has a USB WebCam attached and I'm looking to capture a still image from the camera. Unfortunately this is proving somewhat troublesome, to say the least.

Firstly I had a good search through the .Net Core 2.0 libraries to see if there's anything that will provide this functionality, but have not had any luck.

My second line of enquiry was NuGet, to see if any third-party libraries might do the job. EmguCV looked promising for a while, but they do not seem to support .Net Core just yet.

Finally I googled for anything that might do the job and came across the MediaCapture class in Windows.Media.Capture for UWP, but I've had no success referencing this from my .Net Core console app. It seems like you can reference .Net Core assemblies from UWP solutions, but I've not found a way to do it the other way around.

Bearing in mind that I'd prefer to keep my project in .Net Core 2.0, rather than re-writing for UWP, I'm looking for any means of capturing a still image from the WebCam. Any pointers will be gratefully received, as this is proving to be surprisingly frustrating.

like image 803
Pete Avatar asked Sep 05 '17 21:09

Pete


1 Answers

Actually for capturing images and other image processing activities, probably you can try OpenCvSharp.

It has support for .Net core.

https://github.com/shimat/opencvsharp

Nuget Package is available (look for more details in the above link).

Here is an example for capturing video.

https://github.com/shimat/opencvsharp/wiki/%5BCpp%5D-Capturing-Video

if you pass 0 (zero) as input to VideoCapture, it should open the default camera.

Something like this (not tried):

VideoCapture capture = new VideoCapture(0); //assumption based on how actual openCV works.
like image 51
Pavan Chandaka Avatar answered Sep 25 '22 12:09

Pavan Chandaka