WebCamera with C# - c#

Hello and thanks always for your help
This time I would like to ask about how to capture an image (from a USB camera) using C#.
I have googled about this and so far I found two examples (plus one that I have in a book here but that is not working) in which they require three layers.
The top layer is the application layer in which the developer writes his code
The medium layer is a C# wrapper of...
The lower layer which is usually implemented as a DLL and is always done in C++. This is the layer that makes calls to DirectShow.
Now, is this how this should be done?? C# can not handle a web camera directly?
An example of what I found is
Yet another web camera control
(Please note that this time I am not able to use OpenCV or libraries like that. In fact I have already developed one program that streams a web camera and captures screenshots using OpenCV some time ago)
Any other comment or advice will be greatly appreciated

I myself used AForge.NET framework it's free and it works very easy.
For audio capture, I used NAudio.
You can you can easily install them with NuGet package manager Console.
Aforge Install-Package AForge
NAudio Install-Package NAudio

Related

Writing a Simple Video Viewer/Frame Grabber in C# for a USB Camera

I'm a complete beginner in C#, but I'm trying to write a very simple application in C# (VS2013) to simply view video stream or capture frames from a Sony FCB-EV7500 camera. The camera connects to a small USB3 board using CN401, and the board connects to the laptop via USB3. I can view video in VLC for example, but i'd like to write code in a C# application to get video/grab frames.
Google searching this brought me to DirectShow which apparently is only a C++ library. There used to be a DirectShow.NET wrapper available here: http://directshownet.sourceforge.net/about.html but it seems they haven't updated the project since 2010 and a lot of functions/interfaces at that time remained untested.
Are there any commonly used libraries for accomplishing this in C#? Perhaps something included in the .NET framework? Thanks for any advice or direction.
You really don't want to be marshaling full frame rate video into a C# application.
You should probably take a look at the .net bindings for gstreamer, I have personally only used the C and python bindings so YMMV. If that doesn't work you will need to:
Use direct show, gstreamer, or ffmpeg to deal with media.
Write a native wrapper around your media handling code.
Write C# code to interop with your wrapper.
depending on if you are using winforms or wpf you will either use a NativeWindow or D3DImageSource as your render target.

Display corrected video stream in .NET 4.0

I have to display a video stream from an ethernet camera into a WinForm C# 4.0 application. I made some tests with the software of the camera and I saw that the image provided by the camera was distorted by lenses.
I know that it's possible to correct the image using a calibration grid.
Do you have any feedback about some image processing libraray that can be use for this purpose? The library not necessary need to be free.
For some other projects I use Halcon or OpenCV, but I don't know witch one is the best for that.
Thanks in advance.
OpenCV can do it without any problem. There are a lot of implementations of camera calibration with OpenCV:
Here you have the official version of EmguCV calibration, it uses the CameraCalibration class
Or you can find the official OpenCV's sample application of camera calibration on OpenCV's GitHub, but this one is a native implementation.

Getting input from webcam

Does .NET have a native support for getting input from webcam?
If not, what is the best/recommended way to get input from webcam using C#/.NET?
.NET does not have a native support for webcams. You can use OpenCV library. Also a .NET wrapper exists for OpenCV - Emgu CV.
You might like to look at the easywebcam codeplex project:
http://easywebcam.codeplex.com/
On the other hand, the "native" option is to develop this using DirectShow. However, there is no (as far as I know), official managed interface for DirectShow, so it can have a steep learning curve to develop with.
This was also asked in How to get web cam images in C#? and you might find the following useful:
I've just released the complete sourcecode of my Windows app CamTimer (written in .NET/C#). Download/view the complete code (with working Webcam examples) at https://github.com/johanssonrobotics/CamTimer
Happy coding!
There is also an SDK called MetriCam. It is supposed for Kinect and Time-of-Flight cameras, but also supports webcams. You can download it for free at http://www.metricam.net
It includes samples and tutorials how to integrate a DirectShow webcam into C#/.NET The webcam tutorial can be watched here: http://www.youtube.com/watch?v=BvnRpby8mSE

FFPlay interface in C#?

I recently found a way to convert video's through the FFMpeg converter through command line, but ive recently been interested in making a video player! and i heard that VLC player and various other systems use FFPlay, and i dont know anything about it! so i have some main points of interest..
Questions:
What exactly does the ffplay.exe do?
If it allows me to stream videos, how would i create an interface to C# to use that
How would i display the video on a windows forms app.
If one of those is not possible, im welcome to other alternatives.. or even perhaps writing my own. Suggestions welcome! :)
Edit: im looking for possible solutions with a framework requirement of 3 or below, and also would perfer to not make them install anything additional to my program.
I am not expert but based on what I know,
You can perhaps look at DirectShow technology for developing your video player as there are managed lib such as directshow.net available for it.
To my knowledge, FFPlay is GUI on top of FFmpeg libraries - the main part of FFmpeg is audio/video codec library supporting many formats including MPEG-4 implementation.
To use FFmpeg via DirectShow, you need another component known as ffdshow.

C# tutorial for "listening" to the line in device

I know the obvious answer is "try google..." but i have and I either end up with graphics or cmd-line tutorials, so...
Can anyone point I in the direction of a c# tutorial for "listening" to the audio line-in? Or is it straight forward with the right namespace included? Is it even possible without using directx or some such.
I want to detect external audio activity and report it on screen.
Cheers,
This code sample looks like it has everything that you need: VolumeMeter
Presumably you just need to change the code so that instead of rendering the current volume levels you could return a flag indicating whether "something" is going on.
It's using the Managed DirectX library, which is a managed code wrapper for the native DirectX APIs.
You need an external library to do that. These have .NET bindings:
FMOD is widely used in games, and has an opensource license (and a paid one).
BASS Audio Library is another choice. It's a bit more lightweight.
IrrKlang I haven't use this one, but I was told it is worth the money
NAudio I found just now, because I forgot the IrrKlang's name, and had to google for it. This one looks promising.
OR MDX can do this I think.
check out the VoiceRecorder sample application on Codeplex which shows how to do this using NAudio. This Coding4Fun article explains it in more detail.

Categories