'Find squares / rectangles from image that has overlay using opencv

I am trying to find squares of an image based on overlays that streamers use to stream in applications like OBS, and I would like to know if someone knows a better approach than the one that I am doing.

Example of image and result of my code using cv2 and python (notice that I am not allowed to add images, so link is provided instead):

enter image description here

enter image description here

My strategy is:

  • Resize and blur the image
  • Find all lines in the image based on cv2.HoughLinesP
  • Get common lines and then get points from them
  • Try to find possible squares / rectangles from points

I'm trying to find all squares/rectangles and then retrieve only the big one, but I'm not having good results. Does someone know any library or strategy that could I use to get biggest square/rectangle from image that has an overlay.



Solution 1:[1]

Found the problem!

ax = sns.lineplot(x = x, y = y , data = dataset)

This line was calling other dataset named "dataset" already inside the function

sns.set_palette('Accent')
sns.set_style('darkgrid')
ax = sns.lineplot(x = x, y = y , data = **dataset**)
ax.figure.set_size_inches(12,6)
ax.set_title(title, loc='left', fontsize = 18)
ax.set_xlabel(labelx, fontsize = 14)
ax.set_ylabel(labely, fontsize = 14)
ax = ax

Newbie me

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Guilherme Matte