284 potential_figure = original[
285 y - padding : y + h + padding, x - padding : x + w + padding
286 ]
287 # cv2.imwrite("potential_figure.png", potential_figure)288
289 # Go to next figure if the `potential_figure` is empty
290 if potential_figure.size == 0:
271 if min_area < area < max_area and 0.2 < aspect_ratio < 6:
272 # Draw bounding box rectangle, crop using numpy slicing
273 roi_rectangle = convert_coords_to_corners(box)
274 # cv2.rectangle(image, (x, y), (x + w, y + h), (0, 255, 0), 3)275 # cv2.imwrite("rect.png", image)
276 if (
277 y + h >= image_height
255 # min_area_small = cv2.contourArea(approx)
256 figure_contour = approx[:, 0]
257
258 # if not none_tested:259 bounding_box = cv2.boundingRect(figure_contour)
260 x, y, w, h = bounding_box
261 figure = original[
251 and cv2.isContourConvex(approx)
252 and min_area_small < cv2.contourArea(approx) < max_area
253 ):
254 # none_tested = False255 # min_area_small = cv2.contourArea(approx)
256 figure_contour = approx[:, 0]
257
240 output_paths = []
241
242 if large_box_detection:
243 # none_tested = True244 for contour in contours_small:
245 perimeter = cv2.arcLength(contour, True)
246 approx = cv2.approxPolyDP(contour, 0.1 * perimeter, True)
It is recommended to remove any commented code in your codebase.
for item in sequence:
# print(item)
do_something(item)
# def old_function():
# '''Older implementation that has been replaced'''
# data = get_data()
# api.post(data)
for item in sequence:
do_something(item)