digital-handwritting

How to implement .dat file for handwritten recognition using SVM in Python

萝らか妹 提交于 2021-01-28 06:35:27
问题 I've been trying to train Hand-written Digits using SVM based on the code on OpenCV library. My training part is as follow: import cv2 import numpy as np SZ=20 bin_n = 16 svm_params = dict( kernel_type = cv2.SVM_LINEAR, svm_type = cv2.SVM_C_SVC, C=2.67, gamma=5.383 ) affine_flags = cv2.WARP_INVERSE_MAP|cv2.INTER_LINEAR def deskew(img): m = cv2.moments(img) if abs(m['mu02']) < 1e-2: return img.copy() skew = m['mu11']/m['mu02'] M = np.float32([[1, skew, -0.5*SZ*skew], [0, 1, 0]]) img = cv2