Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 2088

Can't input Support vectors to HogDescriptor (opencv/python)

$
0
0
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/161392/hog-descriptor-setsvmdetector-throws-confusing-error/ So I tried like this SV2 = np.insert(SV, 64, h, axis = 1) hog.setSVMDetector(SV2) SV2 looks like 2 dimensions array ![SV2 looks like 2 dimensions array](/upfiles/15271887037366026.png) 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](/upfiles/1527188905263960.png) SV3 returns no error message, but it doesn't work. when I use SV3 at Linux, It returns just one line error message. ![image description](/upfiles/15271889761637864.png) Maybe there is something wrong with Numpy array... But I don't know what's wrong. How can I solve this problem?

Viewing all articles
Browse latest Browse all 2088

Trending Articles