title: How to convert a csv dataset to a numpy array readable by opencv?
body: <p>I have a csv dataset namely sign language mnist dataset. It contains information of 28x28 images with its pixel information. I would like to convert this dataset into a numpy array that can be read by opencv3. A numpy array where i can manipulate through opencv. I would like to apply histogram of oriented gradients into this dataset through opencv.</p>
  
  <p>I have already successfully converted it into a numpy array and was able to isolate a row and reshape it into a 28x28 array. The row has a label at the beginning and i have also split it with only the 28x28 pixel data. I have used matplotlib to successfully plot it however I can't seem to use cv2.imshow() on the numpy array. I also know that opencv can only read certain datatypes and i have tried converting my data numpy array into both int32 and float but it still didnt work.</p>
  
  <p>Here is how the CSV file looks like:
  <a href="https://i.stack.imgur.com/fJDWk.jpg" rel="nofollow noreferrer">The CSV file showing the first 4 rows</a></p>
  
  <p>Here is the file:
  <a href="https://drive.google.com/file/d/1LczrakCWFxzIpSc6AcbLSIDloUdVfNxl/view?usp=sharing" rel="nofollow noreferrer">Sign Language CSV dataset</a></p>
  
  <p><a href="https://www.kaggle.com/datamunge/sign-language-mnist" rel="nofollow noreferrer">Site Where I got the Dataset[Kaggle.com - Sign Language Mnist]</a></p>
  
  <p>The 1st column is the label for the image and the rest are the pixels. It goes up to the pixel 784 column. </p>
  
  <p>Here is my code:</p>
  
  <pre><code>import cv2
  
  data = np.genfromtxt('sign_mnist_test.csv', delimiter=',', skip_header=1)
  
  labels = data[1:, 0].astype(np.float)
  value1 = data[0, 1:].astype(np.float) #the 1st row of the dataset
  
  reshaped = np.reshape(value1, (28, 28))
  
  cv2.imshow('image', reshaped)
  cv2.waitKey(0)
  cv2.destroyAllWindows()
  </code></pre>
  
  <p>Here is how my numpy array for the 1st row looks like:</p>
  
  <p><a href="https://i.stack.imgur.com/pSaSv.jpg" rel="nofollow noreferrer">Numpy array of the 1st row</a></p>
  
  <p>Here is the output:</p>
  
  <p><a href="https://i.stack.imgur.com/Pp0SQ.jpg" rel="nofollow noreferrer">Output Image</a></p>
  
  <p>I expect it to show a 28x28 training image(a hand image) however it only shows a plain white 28x28 image with no features.</p>
  
  <pre><code>plt.imshow(reshaped, cmap="Greys")
  plt.show()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/tTxhR.jpg" rel="nofollow noreferrer">Output using matplotlib</a></p>
  
  <p>I am using PyCharm as IDE.</p>
  
  <p>I am also looking for alternative options so that i can use my dataset for openCV if there is any solution that is better.</p>