Display corrected video stream in .NET 4.0 - c#

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.

Related

WebCamera with 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

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.

Metro MediaCapture MFT Effect Explaination

I'm trying to apply an effect on a mediacapture stream for a WPF app I'm porting over to Metro. In the WPF app I used Pixel shaders to modify a bitmap whose source was set to the stream of a webcam, but since effects have been dropped for Metro I'm looking for an alternative solution.
The best, and most Metro standards compliant, way of doing this that I've found is building my own MFTs and adding them to my MediaCapture element via the addEffectAsync() method. I've downloaded the MFTGrayscale and MediaExtension examples which show how to apply these effects to a MediaCapture element, but I'm having an issue understanding the actual C++ MFT code. Can someone point me to or give a decent walkthrough/explanation of how I'd go about building my own MFT effect from the ground up? I don't know too much C/C++, just enough to understand some of the example code. I'm really having trouble with the conceptual and architectural aspects of MFT, and hence am very confused by the source code.
Your help is very much appreciated.
EDIT:
Another option I'd consider is using SharpDX. However I'm having issues getting a stream of the MediaCapture object to display on a xaml image element. Any help would be appreciated. Thanks.
You should absolutely have a look at the following git repo: https://github.com/mmaitre314/VideoEffect
It shows how to apply image effects from the Lumia Imaging SDK, Win2D, and DirectX HLSL pixel shaders to videos in Universal Store Apps for Windows Phone 8.1 and Windows 8.1.
Effects can be applied via MediaTranscoder, MediaComposition, MediaCapture, or MediaElement. And the binaries are available via NuGet.
I ended up getting answer on the MSDN forums. It's not an ideal answer, but it's what I'd been fearing all along.
http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/f3a6934e-df7a-44da-bfd8-7b95d494ff43/#90690f89-e57d-4043-9881-60fcc587f736
This is totally doable... I've just rewritten one of the MF transforms from the samples to use the Nokia Imaging SDK and apply filters in real-time to webcam video. You can see how I did it at the link below (plus download some source code). It's not exactly what you need to do, but in the wiki page I explain what you need to change from the boilerplate sample that MS provided.
http://developer.nokia.com/community/wiki/Template_universal_app_for_video_recording_with_MediaCapture_using_Imaging_SDK_Filters

Kinect recording a video in C# WPF

I want to record my kinect camera vision.I have searched, but I couldn't find any C# same core codes. Do you have same simple codes or same suggestions? thanks.
I believe the AForge library may be of use to you. Here: http://www.aforgenet.com/framework/features/ffmpeg.html you can see how you can instantiate a VideoFileWriter and write individual frames into it.
I am using this kinect record library for the kinect Kinect toolbox library
http://kinecttoolbox.codeplex.com/
and here is a tutorial
http://blogs.msdn.com/b/eternalcoding/archive/2011/07/04/gestures-and-tools-for-kinect.aspx

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

Categories