简体   繁体   中英

OpenCV - Identify regular patterns on video frame

I need to identify striped patterns on video sequences.

I'm trying to use the OpenCV Houghlines function to detect the lines of the pattern. Once i have the Houghlines (GREEN_lines) i need to know which are the lines closest to each other and discard all the others. I also need to know how many pairs of dark(RED_line) and light(BLUE_line) stripes are on the image.

Then i need to to know the average luminance of the area inside each "box" formed by the Houghlines.

检测方案

The pattern can appear in video frames on different angles (image on the right).

Any suggestions?

Suppose the lines obtained from applying the Hough Transform are L1, L2, ..., Lk, for k lines that are detected. Let each line, Li be represented by 2 points, ((x1i, y1i), (x2i, y2i)).

First, determine which lines are parallel, and which are perpendicular to each other. You can do this by computing the dot product between the unit direction vector for each pair of line. Pairs of lines which are perpendicular to each other will have dot product 0 (or close to 0 since you detected lines may not be exactly perpendicular due to noise/numerical errors), and dot product close to 1 if they are parallel.

Once you know which lines are parallel, and which are perpendicular, you can sort them based on the x-coordinates (for the "vertical" lines) or y-coordinates (for the 2 "horizontal" lines).

Now you will need to solve for the intersecting points between each "vertical" line and each "horizontal" line, which can be obtained using a little algebra and geometry.

With these points and the lines, you can create a mask to compute the desired values in the image (for eg, the luminance within each box). The sorted lines will also tell you which lines are closest to each other.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM