(image_path)
| 30 | |
| 31 | |
| 32 | def cut_slide(image_path): |
| 33 | image = cv2.imread(image_path) |
| 34 | gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) |
| 35 | _, thresh = cv2.threshold(gray, 50, 255, cv2.THRESH_BINARY) |
| 36 | contours, _ = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) |
| 37 | |
| 38 | for cnt in contours: |
| 39 | x, y, w, h = cv2.boundingRect(cnt) |
| 40 | image = image[y:y + h, x:x + w] |
| 41 | |
| 42 | cv2.imwrite('./slide.png', image) |
| 43 | |
| 44 | |
| 45 | def pass_captcha(): |