Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
OCR
X = []
for i in range(len(x)):
# print(i)
img = x[i]
img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
threshold_image = cv2.threshold(img_gray, 0, 255, cv2.THRESH_BINARY_INV|cv2.THRESH_OTSU)[1]
threshold_image = cv2.resize(threshold_image, (32, 32))
X.append(threshold_image)
print(len(X))
label_encoder = LabelEncoder()
y = label_encoder.fit_transform(y)
print(len(y))
X_train, X_test, Y_train, Y_test = train_test_split(X, y, test_size=0.2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment