title: OpenCV assertion failed in function 'setData'
body: <p>I read this <strong>SOF</strong> page <a href="https://stackoverflow.com/questions/9413216/simple-digit-recognition-ocr-in-opencv-python?rq=1">Simple Digit Recognition OCR in OpenCV-Python</a></p>
  
  <p>Then I tried to run the below code by myself:</p>
  
  <pre><code> import cv2
   import numpy as np
  
  
   samples = np.loadtxt('generalsamples.data',np.float32)
   responses = np.loadtxt('generalresponses.data',np.float32)
   responses = responses.reshape((responses.size,1))
  
   print "samples: \n",samples
   print "respnses: \n",responses
  
   model = cv2.ml.KNearest_create() 
   model.train(samples,cv2.ml.ROW_SAMPLE,responses)
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>samples:
  
  [ 1.   1.   1.   1.   1.   1.   1.   1.   1.  65.   0.   0.   0.   0.   0.
    0.   0.   1.  65.   0.   0.   0.   0.   0.   0.   0.   1.  49.  16.   0.
    0.   0.   0.   0.   0.   1.   1.  65.   0.   0.   0.   0.   0.   0.   1.
    1.  65.   0.   0.   0.   0.   0.   0.   0.   1.  65.   0.   0.   0.   0.
    0.   0.   0.   1.  65.   0.   0.   0.   0.   0.   0.   0.   1.  65.   0.
    0.   0.   0.   0.   0.   0.   1.  11.  55.   0.   0.   0.   0.   0.   0.
    1.   4.  62.   0.   0.   0.   0.   0.   0.   0.]
  
  respnses:
  [[ 7.]]
  </code></pre>
  
  <p><strong>Error:</strong></p>
  
  <pre><code>Traceback (most recent call last):
    File "test.py", line 10, in &lt;module&gt;
      model.train(samples,cv2.ml.ROW_SAMPLE,responses)
  cv2.error: OpenCV(4.0.0-pre) /home/shajal/opencv/opencv/modules/ml/src/data.cpp:259: error: (-215:Assertion failed) samples.type() == 5 || samples.type() == 4 in function 'setData'
  </code></pre>
  
  <p>What should I do?</p>
  
  <p>I have reinstalled Opencv on my Ubuntu machine to resolve this.</p>