Can't input Support vectors to HogDescriptor (opencv/python)
I want to input SVM model to cv2.HogDescriptor.
here is my code
svm = trainSVM() #load image and train cv2.ml.svm
rho, _, _ = svm.model.getDecisionFunction(0)
hog = cv2.HOGDescriptor(winSize,blockSize,blockStride,cellSize,nbins,derivAperture,winSigma,histogramNormType,L2HysThreshold,gammaCorrection,nlevels)
SV = svm.model.getSupportVectors()
To input support vector to HogDescriptor, I used 3 ways.
hog.setSVMDetector(SV)
It returns error
cv2.error: C:\projects\opencv-python\opencv\modules\core\src\matrix.cpp:2558: error: (-215) d == 2 && (sizes[0] == 1 || sizes[1] == 1 || sizes[0]*sizes[1] == 0) in function cv::_OutputArray::create
This post said that I must input -rho to end of the array
http://answers.opencv.org/question/16...
So I tried like this
SV2 = np.insert(SV, 64, h, axis = 1)
hog.setSVMDetector(SV2)
SV2 looks like 2 dimensions array
and SV2 returns the same error
cv2.error: C:\projects\opencv-python\opencv\modules\core\src\matrix.cpp:2558: error: (-215) d == 2 && (sizes[0] == 1 || sizes[1] == 1 || sizes[0]*sizes[1] == 0) in function cv::_OutputArray::create
so I make SV3 like below
SV3 = np.append(SV, -rho)
hog.setSVMDetector(SV3)
SV3 looks like 1 line array
SV3 returns no error message, but it doesn't work. when I use SV3 at Linux, It returns just one line error message.
Maybe there is something wrong with Numpy array... But I don't know what's wrong. How can I solve this problem?
why reinvent the train_hog app ? that already looks silly (sorry)
also, please show, what your
trainHog()
finction does, exactly. it is supposed to deliver a single supprt vector from a linear , regression svm, your output looks wrong.