def deRotate(seg): box_vtx = cap.minAreaRectImage(seg) pts = sorted(box_vtx, key=lambda vtx: vtx[1], reverse=True)[:2] slope = findLineSlope(*pts) if slope < 20.0: seg = doRotate(seg, -slope, fillval=0, resize=True) seg = cap.getSubImage(seg, cap.findNonBlackRect(seg, thresh=1)) return seg
def areafilter(comp): w, h = cap.minAreaRectImage(comp[3], returnPoints=False)[1] return w * h >= minRectArea