How to detect change on the screen? - c#

I have a question that How to detect the change on the screen? Its position is not necessary but is possible to get its position it will be helpful. I searched it on the internet but not found any suitable answer. Now, I am making a program in C# and I have to detect a change on the screen. I tried to capture four screen shots per second and compare them. This method works but it badly effect on the performance of the PC.
I think it is easy to do in C or Assembly language (x86) because in assembly we can get access to video memory directly.
Is it possible to do in C#?
Code sample will be appreciated.
Project: Detect any change on full Screen camera monitoring software.

Are you really looking just for simple difference of what you see on your monitor? I doubt that would do the job.
For motion detection from cam input you can take a look at Motion Detection Algorithms article on CodeProject.

Aside from taking screen captures and comparing them at some time intervals (which would cause performance issues),
The only solution i can think of is hooking up to system events, the "redraw" kind of events.
You will need to choose which events to hook your program with.
This codeproject tutorial might help-
http://www.codeproject.com/KB/system/WilsonSystemGlobalHooks.aspx

Related

How to get a screenshot from the background window DirectX

I was looking for examples of how to make a screenshot of an inactive window, but I did not find it. I want to take a screenshot of the game that works in the window, and not in full screen mode.
Which can be blocked by other windows.
I found some examples on the Internet, but could not implement in my project.
Could you set an example of how to do this with the help of EasyHook and SharpDX (or SlimDX) on language C#?
I'll be very grateful!
I created an example project for this on GitHub, https://github.com/spazzarama/Direct3DHook
Allows screen capture and drawing an overlay into the Direct3D target application using C#, EasyHook and SharpDX.
Keep in mind that some games will employ anti-injection/hooking techniqiues that may block EasyHook.
In addition this usually won’t work for minimised applications as it is best practice to pause your render loop when minimised.

How to intercept each trying to use API function in C#?

i need to block any screen capture software on the computer from taking screen shots. Since all of them are work on standard API-functions, i think i could monitor and block them.
I need to use C#.
All i have found is how to monitor and block them in a certain program (screen capture program). They are looking for a function in the program, then they change it address on mine function address.
But how can i do it, if i haven't any certain programs? I need to block anyone which tries to take a screenshot.
If your final goal is possible or not I don't know, but for the hooking the API portion I can help you out.
I have used the library EasyHook many times in the past, this will let you hook and intercept system function calls from C# code fairly easily. Just read through the PDF tutorial for setup instructions.
For actually finding the API's I recommend Rohitab's API Monitor, it's still in Alpha stages but it works really well and is free. You just hook it on to a processes and it tells you every external DLL call it makes (with the parameters it passed if you have the xml definition file for the DLL, the program comes with almost all of the windows API dll's pre-defined).
The combination of EasyHook and API Monitor is a great 1-2 punch for mucking with other program's calls.
It is not possible to prevent screenshots from being taken. The battle is already lost because of the DWM (Desktop Window Manager). It's lower level than Win32 and device contexts.
If you want to protect the text in your program, there are a lot easier ways to extract it than doing screenshots and OCR. TextOut and/or Direct2D hooking and accessibility APIs.
If there's a lot of IP in your program. Then don't make it all available onscreen. Make sure it's tedious to crawl the GUI for text, and hard to automate it. And don't load whole texts in memory of the program.
Possible solutions:
1. To prevent copying of text. Draw the text as an image.
2. To prevent accessibility technologies, like screen readers - override WndProc in your control, handle and ignore the window message WM_GETOBJECT.
3. To make it harder if they try to use OCR. Draw graphics behind the text. Human readable, but much harder for a machine to interpret it.
Neither of these methods are invasive for the user.
** A very invasive suggestion **:
If you are really serious about preventing anyone from "stealing" your content.
Implement mouse and keyboard hooks. Filter out typical copy shortcuts. Prevent the mouse from leaving the boundaries of your application.
Allow your application to only run when the OS runs well-known processes and services.
If any process starts which you don't recognize, black out the application and notify the user about it, and request the user to close it. And ofc make sure someone is not just spoofing a well-known process.
Monitor the clipboard as you suggested yourself.
You can ofc soften some of these suggestions based on the context of your application.
As Scott just posted it likely can be prevented with API hooks to see that paint events only go to desktop bound handles and not others, and refuse to paint otherwise. However, you need to consider the following scenarios and see if they're relevant threat to your approach or not:
Your software may be running in a virtual machine like VMWare. Such software has capapbilities to capture screen that does so at "virtual hardware" level, and your API hooks will not be able to discern it - and this would be the easiest way approach if I wanted to bypass your protections.
As a post suggests here, nothing also prevents someone to take monitor cable and plug it into another computer's capture card, and take screenshot that way. Again, your hooks will be helpless here.
Bottom line, you can make it somewhat harder to do, but bypassing such protection may be pretty trivial thing to do.
My 2c.

Resources for learning to deal with audio in .net?

I'm not fully sure what I'm looking for so I was hoping to gain some insight. I'm brainstorming an application I want to write, but I've never dealt with this type of project. I was wondering if any of you knew of any resources, both literature and libraries/APIs that could lead me down the path to creating an application that involves the playback of audio, visualization of audio (like displaying the waveform with a scrolling position), setting playback points, maybe some effects like fade in and out, maybe even beat mapping; all in .net
For example, an application that displays a waveform and has a position indicator that moves with playback. It allows you to visually set multiple start and stop points, etc.
Any suggestions?
Check out http://naudio.codeplex.com/

Detecting beats in a song

I'm working on a project which requires me to add beat detection when a song is playing in the application (WinForms - C#).
I'm currently using NAudio.NET for playing the song & displaying details about the song.
Is there a library that would allow me to do this or some way to detecting this manually? I'm not expecting a finished solution but pointers in the right direction. Ideally I would like this to be a real-time detection but it is not essential.
This question has already been asked; check out this StackOverflow thread. Some of the answers include explicit beat detection algorithms and links.
GameDev.net - Algorithm Summary
Comb Filters
More algorithms are on that StackOverflow thread
You can use this BPM Detection Library
Besides BPM calculation it also allows you to get every beat, so you could for example adjust your visualisation, if that is the case.
I've used FMOD to do exactly what you're doing. They don't have annoying popups. You can check out this link to a GitHub project that uses it in c#. Fmod licensing is a little odd, based on what the program's budget is. If your budget is under 500k, you can use it for free, but are supposed to display their logo somewhere, either in a splash screen or credits screen.

How to draw an unfilled square on top of a stream video using a mouse and track the object enclosed in the square automatically in C#?

I am making an object tracking application. I have used Emgucv 2.1.0.0
to load a video file
to a picturebox. I have also taken the video stream from a web camera.
Now, I want
to draw an unfilled square on the video stream using a mouse and then track the object enclosed
by the unfilled square as the video continues to stream.
This is what people have suggested so far:-
(1) .NET Video overlay drawing(DirectX) - but this is for C++ users, the suggester
said that there are .NET wrappers, but I had a hard time finding any.
(2) DxLogo sample
DxLogo – A sample application showing how to superimpose a logo on a data stream.
It uses a capture device for the video source, and outputs the result to a file.
Sadly, this does not use a mouse.
(3) GDI+ and mouse handling - this area I do not have a clue.
And for tracking the object in the square, I would appreciate if someone give me some research paper links to read.
Any help as to using the mouse to draw on a video is greatly appreciated.
Thank you for taking the time to read this.
Many Thanks
It sounds like you want to do image detection and / or tracking.
The EmguCV ( http://www.emgu.com/wiki/index.php/Main_Page ) library provides a good foundation for this sort of thing in .Net.
e.g. http://www.emgu.com/wiki/index.php/Tutorial#Examples
It's a pretty meaty subject with quite a few years and different branches of research associated with it so I'm not sure anyone can give the definitive guide to such things but reading up neural networks and related topics would give you a pretty good grounding in the way EmguCV and related libraries manage it.
It should be noted that systems such as EmguCV are designed to recognise predefined items within a scene (such as a licence plate number) rather than an arbitory feature within a scene.
For arbitory tracking of a given feature, a search for research papers on edge detection and the like (in combination with a library such a EmguCV) is probably a good start.
(You also may want to sneak a peek at an existing application such as http://www.pfhoe.com/ to see if it fits your needs)

Categories

Resources