# Face Recognition Using HOG+SVM

This is my approach

svm = cv2.ml.SVM_create()
svm.setType(cv2.ml.SVM_C_SVC)
svm.setKernel(cv2.ml.SVM_RBF)
svm.trainAuto(data["encodings"], cv2.ml.ROW_SAMPLE,data["names"])


where I get encodings using HOG and names from:

for (i, imagePath) in enumerate(imagePaths):
# extract the person name from the image path
print("[INFO] processing image {}/{}".format(i + 1, len(imagePaths)))
name = imagePath.split(os.path.sep)[-2]


but when I train

'samples is not a numpy array, neither a scalar'

this error appears in the line:

svm.trainAuto(data["encodings"], cv2.ml.ROW_SAMPLE,data["names"])


I think I need to convert the names to a numpy array.

How can I do that?

It's hard to tell exactly what you're asking, and exactly what your data looks like. Nonetheless, I think you're asking how to convert a list to a numpy.array.

Try this:

np.asarray(data["names"])


That depends on the type you are converting it from.

As I currently do not have the information, I will assume the type of data is a pandas dataframe.

In that case you could use something like data["names"].values to convert your data to a numpy array.

• name = imagePath.split(os.path.sep)[-2]-->this is how i get the name,it is a list – Akhil Alexander Sep 25 '18 at 7:53