How to search for screen image in C #?

I want to search for an image on the screen using C # or other .NET languages ​​(e.g. powershell). Something like I give the location of the image in the file system, and the code considers the whole screen as an image and looks for the image in the file system on a large image (screen), and then returns the position of the image on the screen. I cannot find such things in .net classes.

Thanks.

+6
c # image-recognition
source share
2 answers

This is a rather specific problem, so you will not find it in the .NET Framework. You need to break your problem in smaller parts:

Download image from file to disk

Use System.Drawing.Image.FromFile () .

Get a screen image, i.e. a screenshot

Use System.Drawing.Graphics.CopyFromScreen () :

Bitmap CaptureScreen() { var image = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb); var gfx = Graphics.FromImage(image); gfx.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy); return image; } 

Find image inside image

See the answer to this question .

+19
source share

I made a program that used lib i encoded in C #, which will return the x and y value of a small image inside a larger image (screenshot), you can see all the details here https://www.nulled.io/topic/22223- an-advanced-image-search-library-saeedsearchdll /

-one
source share

All Articles