Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions eDOCr/tools/box_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ def biggest(rect_list):
Args: rect_list: list of rects
Returns: max_name: rect name
'''
max_size = np.amax(rect_list[:,5].astype(float))
max_index=np.where(rect_list[:,5].astype(float)==max_size)[0][0]
sizes = rect_list[:,3].astype(float) * rect_list[:,4].astype(float)
max_size = np.amax(sizes)
max_index=np.where(sizes==max_size)[0][0]
max_name=rect_list[max_index,0]
return max_name

Expand Down Expand Up @@ -167,9 +168,8 @@ def findrect(img):
crop_img=img[y:y+h,x:x+w] #Crop the rectangle
cv2.putText(img_boxes, 'rect_'+str(r), (x1, y1), cv2.FONT_HERSHEY_SIMPLEX, 1.2, (255, 127, 83), 2) #Add rectangle tag
img_boxes = cv2.drawContours(img_boxes, [cnt], -1, (255, 127, 83), 2) #Plot rectangle contourn in green
size=w*h
rect_list.append(['rect_'+str(r),x,y,w,h]) #Get a list of rectangles
class_list.append(rect('rect_'+str(r),x,y,w,h,size,crop_img,'green')) #Get a list with the rect class
class_list.append(rect('rect_'+str(r),x,y,w,h,crop_img,'green')) #Get a list with the rect class
r=r+1

print('number of rectangles:',len(rect_list))
Expand Down