title: Loading OpenCV Image To Scikit Learn
body: <p>I'm programming a machine learning script to take pictures and label it. I have my dataset in a folder and I add them into array and create another array for labels. when i try to use svm.fit it gives the error :</p>
  
  <pre><code>File "scikit.py", line 43, in &lt;module&gt;
      clf.fit(arrayimg, arraylabel)
    File "/home/mkmeral/.local/lib/python2.7/site-packages/sklearn/svm/base.py", line 151, in fit
      X, y = check_X_y(X, y, dtype=np.float64, order='C', accept_sparse='csr')
    File "/home/mkmeral/.local/lib/python2.7/site-packages/sklearn/utils/validation.py", line 521, in check_X_y
      ensure_min_features, warn_on_dtype, estimator)
    File "/home/mkmeral/.local/lib/python2.7/site-packages/sklearn/utils/validation.py", line 405, in check_array
      % (array.ndim, estimator_name))
  ValueError: Found array with dim 3. Estimator expected &lt;= 2.
  </code></pre>
  
  <p>And here is the script I wrote:</p>
  
  <pre><code>import cv2
  import numpy as py
  from sklearn import svm
  
  camera_port = 0
  camera = cv2.VideoCapture(camera_port)
  ramp_frames = 5
  
  def getImage():
      retval, im = camera.read()
      gray_image = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
      return gray_image
  
  def insertToArray(arrayone, arraytwo, no, true):
      if (true==1):
          directory = "/home/mkmeral/Desktop/opencv/strue/"
          arraytwo.append(1)
      else:
          directory = "/home/mkmeral/Desktop/opencv/sfalse/"
          arraytwo.append(0)
  
      im = cv2.imread(directory + str(no) + ".png")
      gray_image = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
      arrayone.append(gray_image)
  
  arrayimg = []
  arraylabel = []
  count = 1
  while (count&lt;43):
      insertToArray(arrayimg, arraylabel, count, 1)
      print("True = " , count)
      count = count + 1
  
  count = 0
  while (count&lt;43):
      insertToArray(arrayimg, arraylabel, count, 0)
      print("False = ", count)
      count = count + 1
  
  print("Done adding to arrays")
  clf = svm.SVC()
  print("Done adding to arrayssss")
  clf.fit(arrayimg, arraylabel)
  
  print("Done fitting")
  for i in xrange(ramp_frames):
      temp = getImage()
  
  testimage = getImage()
  
  clf.predict(testimage)
  </code></pre>
  
  <p>How can I fit those images to Scikit learn and would it make a problem to predict the image taken from webcam?</p>