I need to find boxes in the following images using opencv. I have tried using mser but i am not getting any good results.

My code for MSER:
mser = cv2.MSER_create()
img = cv2.imread('Lines.png')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
I = img.copy()
regions, _ = mser.detectRegions(I)
hulls = [cv2.convexHull(p.reshape(-1, 1, 2)) for p in regions]
mask = np.zeros((img.shape[0], img.shape[1], 1), dtype=np.uint8)
c=0
points=[]
for contour in hulls:
[x, y, w, h] = cv2.boundingRect(contour)
if w < 50 or h < 8 or w>120:
continue
c=c+1
cv2.rectangle(I, (x, y), (x + w, y + h), (255, 0, 255), 0)
plt.figure(1,figsize=(100, 50))
plt.imshow(I)
Result for MSER:



cv::findContoursand keep only contours that can be simplified e.g. with Douglas-Peucker algorithm using 4 points. I am having a code for this but only in C++.