When I use Opencv3 with Python2, my code is to do something with SVM.
But an Error is shown:
svm.train(trainData,responses,params = svm_params) TypeError: only length-1 arrays can be converted to Python scalars
This error occurred because the function was expecting a single array object and trainData
variable contained multiple array objects. There are several ways to solve this, one of them is, say if your input object is:
# Used for creating training samples for a logic gate (eg: xor) NN
trainData = np.random.randint(2,size=2)
# array([ ..some values.. ])
then add [np.newaxis] to it
np.random.randint(2,size=2)[np.newaxis]
# array([[ ..some values.. ]])