There is a changing background and sometimes a rectangle with text. What are the ways / algorithms for determining that a rectangle appeared?

Note: the rectangle is uneven (the form does not change), the text is Russian (the same text does not change).

I have the same text, I don’t need to recognize it at all. You just need to know that the rectangle with the text appeared or it does not exist.

  • Specify the question, how I did not try, I understood absolutely nothing. - Zowie
  • The question for psychics is the same .... - Gorets
  • rough, text Russian xDDD @nbit - now everything fell into place - Zowie
  • You can even without a text, I thought, the more information I give the more opportunities to determine the presence of a figure. @Gorets @AlexWindHope You would delete messages from the flood, won @ Kotik_hoche_kushat for example, clarified and erased. - Merlin
  • @nbit - where figures? Where does it come from? What do you know about her? etc. And what do you mean by "appeared"? The fact that the text is Russian, and the rectangle is uneven is, of course, great, but not the information that is needed to get an answer. - Zowie

1 answer 1

The CV library called Aforge.NET has a ShapeChecker class that can help you achieve your goal.

Also, probably, similar functionality is implemented in the Emgu.CV library .


Usage example and corresponding code

 static void Main(string[] args) { // Open your image string path = "test.png"; Bitmap image = (Bitmap)Bitmap.FromFile(path); // locating objects BlobCounter blobCounter = new BlobCounter(); blobCounter.FilterBlobs = true; blobCounter.MinHeight = 5; blobCounter.MinWidth = 5; blobCounter.ProcessImage(image); Blob[] blobs = blobCounter.GetObjectsInformation(); // check for rectangles SimpleShapeChecker shapeChecker = new SimpleShapeChecker(); foreach (var blob in blobs) { List<IntPoint> edgePoints = blobCounter.GetBlobsEdgePoints(blob); List<IntPoint> cornerPoints; // use the shape checker to extract the corner points if (shapeChecker.IsQuadrilateral(edgePoints, out cornerPoints)) { // only do things if the corners form a rectangle if (shapeChecker.CheckPolygonSubType(cornerPoints) == PolygonSubType.Rectangle) { // here i use the graphics class to draw an overlay, but you // could also just use the cornerPoints list to calculate your // x, y, width, height values. List<Point> Points = new List<Point>(); foreach (var point in cornerPoints) { Points.Add(new Point(point.X, point.Y)); } Graphics g = Graphics.FromImage(image); g.DrawPolygon(new Pen(Color.Red, 5.0f), Points.ToArray()); image.Save("result.png"); } } } } 

Work results

alt text

alt text

  • in order to eliminate ambiguity in the example, it would be better to write the following List <System.Drawing.Point> Points = new List <System.Drawing.Point> (); - Merlin