I
I
Ilya Lopuga2017-05-30 09:12:13
PHP
Ilya Lopuga, 2017-05-30 09:12:13

OpenCV how to find some rectangles?

I will explain what exactly is needed:
The customer wants to give his clients a certain questionnaire (a bunch of printed text, rectangle fields, all sorts of checkboxes, etc.). He also wants to have several certain fields where the client can write something by hand.
All these questionnaires will be subsequently scanned. A file (already a picture) will come to my service, I have to find all the rectangles with handwritten texts in it and save them into separate pictures.
In principle, the text will be handwritten in rectangles or not - it does not matter. I can make these rectangles in the document even with a dotted line, even with a different color.
It is necessary to drip, I suppose, towards opencv.
It is not clear how to convert the document to find the boundaries of the rectangles I need.
What is the best way to style these rectangles in the document so that it is easiest to find them? I can’t figure out what the procedure should be, because I haven’t come across computer vision yet

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
PrAw, 2018-09-10
@Shimpanze

init.php:
include "functions.php";
include "index.php";

I
Ironicman, 2017-06-01
@ironicman

I had a similar task. I was looking for one rectangle of given proportions.
After the initial image processing (filters, binarization, etc.), I searched for contours using the Canny algorithm.
Among the contours, I was looking for those whose compactness falls within a given interval.
Compactness is the ratio of the square of the perimeter to the area. For contours, this is a constant value. So I cut off the extra contours.
In my case, the algorithm gave a stable result if the target rectangle was fatter than the other contours. But I didn’t have scans, but photos: poor lighting, light, shadows, and so on. That is, the selective red filter, for example, did not work, because in the evening lighting or with warm filters in the photo, the overall hue of the picture was reddish and spurious contours could get into focus.
Unfortunately the code is not available. If needed, I can add later.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question