OCR Hand written data showing error in svm.train()
<p>I am using OpenCV3.1.0 with Python2.7 .
I have implemented code of OCR Hand Written Data from <a href="https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_ml/py_svm/py_svm_opencv/py_svm_opencv.html#svm-opencv" rel="nofollow">here</a>.</p>

<pre><code>responses = np.float32(np.repeat(np.arange(10),250)[:,np.newaxis])
svm.train(trainData,cv2.ml.ROW_SAMPLE, responses)
</code></pre>

<p>and getting these error</p>

<blockquote>
  <p>svm.train(trainData,cv2.ml.ROW_SAMPLE, responses)
  cv2.error: C:\builds\master_PackSlaveAddon-win64-vc12-static\opencv\modules\ml\src\svm.cpp:1618: error: (-5) in the case of classification problem the responses must be categorical; either specify varType when creating TrainData, or pass integer responses in function cv::ml::SVMImpl::train</p>
</blockquote>

<p>Note: Since working on opencv3.x I have used cv2.ml.svm wherever necessary and rest is same</p>

<p>And if using</p>

<pre><code>responses = np.int32(np.repeat(np.arange(10),250)[:,np.newaxis])
</code></pre>

<p>getting 0 accuracy</p>

<p>Try using <code>pytesseract</code>. It is much better than training an SVM classifier. If you want to check it out, follow this <a href="https://pypi.python.org/pypi/pytesseract/0.1)" rel="nofollow">link</a>. Also for an advanced example check out this <a href="https://realpython.com/blog/python/setting-up-a-simple-ocr-server/" rel="nofollow">site</a> as well.</p>

python opencv svm ocr categorical-data