Skip to content

Instantly share code, notes, and snippets.

@Yuvnish017
Created July 13, 2021 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yuvnish017/4869f8a51d2026fa00da49b9174a2f66 to your computer and use it in GitHub Desktop.
Save Yuvnish017/4869f8a51d2026fa00da49b9174a2f66 to your computer and use it in GitHub Desktop.
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