I am now facing one problem which to get the live image from Camera (eg. Sony, Canon) into winform and also control the camera capture button from a button in the form.
have Anyone build something like this, or are there any similar project like this which is done in C#?
This hardly depends on the capabilities of the camera and its driver. Your biggest chance might be the Windows Image Acquisition (WIA) framework.
Take a look at this article or the MSDN reference.
Emgu cv is a project that provides all the bindings for OpenCV. I've used it on both Windows and Linux platforms (Mono) with great success.
http://emgu.com/
http://emgu.com/wiki/index.php/Camera_Capture_in_7_lines_of_code
You can also take a look on Intel OpenCV.
It's C++, but you can use use PInvoke to use it from c#
This project supports even high-end PTZ camera. Code Project - Versatile WebCam C# library.
It uses Touchless.Vision and WebCamLib
Related
Having searched high and low for native c# hook to webcam, I found 5 basic ways to interact with the camera.
Video for Windows (VFW)
DirectX
avicap32.dll
WIA
3rd party tools
My requirement is to take a photo. The application will be used on some legacy windows XP and Vista machines, but going forward Windows 7 and greater will be required. So what might the best approach be with the broad install base? Just reading WIA looked like the way to go but looks like some changes were made so it works a little different now (I don't know for sure). I understand that some people have done combos.
Might need to crop photo, but that is really about it.
For school visitor monitoring.
I think the best thing is to use the WIA. I know a third party toolkit that could help you doing your requirements which is leadtools. You can check this Tutorial
I would always try to pick up something already on the web and tweak it to my own needs... some open source project or an example where the mainly portion of my app is already made.
on Codeplex you can find a nice library to work with webcams and it's simply called
WebCam Library for WinForm and WPF with C# and VB.NET
Give that a try, maybe you can even help the project, by contributing your own findings, and everyone is a winner... isn't Open Source a great idea?!
I have done some looking and I can't figure out a good way to write a 2D tile/sprite based game in C# for Win8. According to the MSDN documentation:
You can use managed code languages like C# and Visual Basic to develop 2D (and lightweight 3D) games.
The problem is that I can't figure out how to do this. The reason I would like to use C# is because I already have a lot of code written for Windows Phone that I would like to reuse.
Can anyone point me to how I would write a fairly efficient 2D tile/sprite MetroUI game for Win8? The only thing I can find uses C++ and DirectX.
[EDIT]
To clarify I do not care too much what I use (WinRT, DirectX...) so long as I can submit to the app store, and write my code in C#.
If you are familiar with the DirectX API, you can use SharpDX available via http://sharpdx.org. It is basically exposing DirectX APIs into C#. From my understanding, if you are going to upload apps to the store, the SharpDX should be fine and pass compliance, but I would look into it further before going too deep.
Also, as of this time, not all of the features are available (like Direct2d not fully certified for Win8 Metro).
If your game uses simple graphics, you can use Drawing Library for Modern UI, it exposes a GDI+ like interface to be used in XAML/C#/VB.NET Windows 8 Modern UI applications, it works by drawing to a XAML Canvas.
If you're looking for something quick and easy check out the "Physics Helper XAML" project;
http://physicshelperxaml.codeplex.com/
It's based on the farseer engine, and comes with sample apps. There are a few games already released using it.
http://www.andybeaulieu.com/Home/tabid/67/EntryID/223/Default.aspx
Have a look at:
[XAML images sample] (http://code.msdn.microsoft.com/windowsapps/0f5d56ae-5e57-48e1-9cd9-993115b027b9/sourcecode?fileId=102748&pathId=677969581)
The page and samples give some code for NineGrid and WriteableBitmap Image manipulation.
You can now use Win2D (open source, released by Microsoft for metro/WinRT apps) which provides hardware-accelerated 2D graphics rendering.
I am integrating a video player to an existing .NET WinForms application.
I first tried to use "Windows Media Player Control" which is included in Windows SDK,
but I could not change the playback rate.
The following is the code I wrote to change the rate.
if (axWindowsMediaPlayer1.settings.get_isAvailable("Rate"))
{
axWindowsMediaPlayer1.settings.rate = 3.0;
}
The condition in the if statement always returns "false" no matter what video file I use. Does anyone have any idea why I cannot change the rate? It really needs to be available to change the playback rate, so WMP control seems to be a bad choice if it's impossible to do so.
Or, is there any alternative solution which allows me to change the rate? Preferably a .NET based library which does not involve any unmanaged code.
Thanks!
I ended up using DirectShow.NET (http://directshownet.sourceforge.net/) which is an open-source library. It contains a lot of samples, and it has a sample with playback rate control.
IF a commercial library is an option take a look at http://www.visioforge.com/media-player-sdk-net.html
Another commercial option would be Leadtools MultIMedia SDK - see http://www.leadtools.com/sdk/multimedia.htm#+cp_playback
Is the if statement really necessary?
I could set the rate fine without it..
axWindowsMediaPlayer1.settings.rate = 3.0;
I need to rapidly develop some software that uses a camera as an AV input.
Assuming the drivers are installed for whatever the device that is giving the input I need to be able to capture images and to stream the camera in the winforms window.
I couldn't find a component that I can use, maybe because I don't know the right name for it.
Touchless is under a licence I can't use. If anyone knows of a good compoment/code I can use even if it's for a fee I will appreciate this.
DirectShow.NET library suits the bill here. You can use it to access the webcam directly using the underlaying DirectShow object as in here: http://www.codeproject.com/KB/audio-video/WebcamUsingDirectShowNET.aspx
Also if you consider learning WPF, there is a very neat webcam component here: http://wpfcap.codeplex.com/
It is just like dropping a image control on the worm, but this time in WPF:
Edit: There are also two Winform webcam components as I see now: http://easywebcam.codeplex.com/ and http://www.c-sharpcorner.com/UploadFile/yougerthen/810262008070218AM/8.aspx
This article explains how to access the webcam using Windows Image Aquisition services.
Can anyone tell me how to hook/overlay a DirectX game in C#?
I've tried getting a fullscreen C# window to overlap a game, however it wont.
After researching a little, I found out that I need to hook the game and then display the C# window.
Can anyone explain how I would do this?
Would I be able to display a C# form over a DirectX game?
You can try my example on hooking the Direct3D 9 API using C#. This utilizes EasyHook an open source .NET assembly that allows you to install hooks from managed code into unmanaged functions.
SlimDX is also used - this is an open source managed wrapper around the Direct3D libraries.
The tricky part of the hooking is determining the addresses of a COM objects' virtual functions. This is done in the above example using a small C++ helper DLL that finds the addresses from the VTable. [Update: there is a comment posted that show's how to get the function pointers from the VTable in C# also - given a IntPtr to the com object]
The example hooks the EndScene method of an IDirect3DDevice9, which is also where you would want to draw any overlays. As to displaying a form in the overlay I'm not so sure that will be so easy - I mean you can render the image easily enough, but you will have to capture inputs and manually respond/pass-thru the events to the form in question appropriately. Good luck!
(disclosure: I work for this company)
You can try our Deviare API, it has functionality to hook COM objects from C#.
It's a set of COM objects that can be used from any programming language (supporting COM). An article with source code showing how to capture video and add an overlay is available: instrumenting Direct3D applications to capture video and calculate FPS
COM Spy Console and Direct Sound Capture are two examples that implements a console to hook COM objects like DirectX.
Hope it helps.
Since you don't have direct DirectX Access from C# this may be tricky.
From my limited understanding of the concept:
DirectX Hooks consist of attaching to a DirectX Context and manipulating it, this may/may not require messing with another program's memory, something that's best suited to C/C++
I may be wrong though, however this is an advanced topic and my gut tells me you may have issues under .NET