Closed ifangcheng closed 7 years ago
or should be else : cont.append([x, y, w, h]) ?
yes, my mistake , you can make a Pull request if you want or I'll just fix it directly
@bendidi thanks for response! i think you can fix it directly :-D
fixed , thanks !
def extract_boxes(self,new_im): cont = [] new_im=new_im.astype(np.uint8) ret, thresh=cv2.threshold(new_im, 127, 255, 0) p, contours, hierarchy=cv2.findContours( thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) for i in range(0, len(contours)): cnt=contours[i] x, y, w, h=cv2.boundingRect(cnt) if w*h > 30**2 and ((w < new_im.shape[0] and h <= new_im.shape[1]) or (w <= new_im.shape[0] and h < new_im.shape[1])): if self.FLAGS.tracker == "sort": cont.append([x, y, x+w, y+h]) else : cont.append([x, y, x, y]) return cont
this line else : cont.append([x, y, x, y]) is correct? or should be else : cont.append([x, y, x, y])