Text Practice Mode
Coding Speed Test with Python
created Aug 14th 2024, 14:02 by Shin4N
2
44 words
14 completed
5
Rating visible after 3 or more votes
saving score / loading statistics ...
00:00
import cv2 as cv
import numpy as np
def __process(_):
try:
_, _img = cv.threshold(cv.cvtColor(cv.GaussianBlur(_, (5, 5), 0), cv.COLOR_BGR2GRAY), 60, 255, cv.THRESH_BINARY)
_, _contours, _ = cv.findContours(_img.copy(), cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE)
_areas = [cv.contourArea(c) for c in _contours]
if _areas:
_max_idx = np.argmax(_areas)
return cv.boundingRect(_contours[_max_idx])
import numpy as np
def __process(_):
try:
_, _img = cv.threshold(cv.cvtColor(cv.GaussianBlur(_, (5, 5), 0), cv.COLOR_BGR2GRAY), 60, 255, cv.THRESH_BINARY)
_, _contours, _ = cv.findContours(_img.copy(), cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE)
_areas = [cv.contourArea(c) for c in _contours]
if _areas:
_max_idx = np.argmax(_areas)
return cv.boundingRect(_contours[_max_idx])
