Ask Your Question

isaacperez's profile - activity

2016-07-21 06:08:47 -0600 asked a question HOG svm type

Hi.

Do HOG detectMultiScale function uses linear svm for detections in OpenCV 3.0?

I need to pass the support vector of linear svm to hog.setSVM() or can I make a polynomial detector but not with hog.detectMultiScale?

Thanks!

2016-07-20 03:31:09 -0600 commented question HOG setSVMDetector slow

Thanks for your help! I found that it give me 39802 detections without activate mean-shift!

2016-07-19 03:17:40 -0600 commented question HOG setSVMDetector slow

I see that if I don't put rho in setSVMDetector and I put in detectMultiScale in hitThreshold with -3.8 it take me ~6 s and for example 4 take me ~64 ms... WTF?

2016-07-19 02:06:54 -0600 commented question HOG setSVMDetector slow

Hi LorenaGdL I have seen http://stackoverflow.com/questions/21... If I put rho as an argument in HOGDescriptor::detectMultiScale call it take me about 64 ms so it's ok but I don't understand why

2016-07-19 01:46:13 -0600 commented question HOG setSVMDetector slow

Ok. Done !

2016-07-18 09:29:14 -0600 received badge  Editor (source)
2016-07-18 08:28:10 -0600 asked a question HOG setSVMDetector slow

I'm using HOG with custom svm. I've used https://github.com/opencv/opencv/blob... but my feature vector has 2268 features and get_svm_detector() give me 2269 support vectors, this don't give me error but hog.detectMultiScale is very slow ( ~ 6 s), why?

With svmLight I get 2268 support vectors and hog.detectMultiScale takes about ~64 ms.

I Add the code:

Ptr<SVM> svm;
Ptr<TrainData> trainData = TrainData::loadFromCSV("./trainData.csv");    

svm = SVM::create();
svm->setType(SVM::C_SVC);
svm->setKernel(SVM::LINEAR);
svm->setTermCriteria(TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, (int)1000, 1e-3));

svm->trainAuto(trainData,10,SVM::getDefaultGrid(SVM::C),SVM::getDefaultGrid(SVM::GAMMA),SVM::getDefaultGrid(SVM::P),SVM::getDefaultGrid(SVM::NU),SVM::getDefaultGrid(SVM::COEF),SVM::getDefaultGrid(SVM::DEGREE),true );

svm->save("model.yml");

In other class:

HOGDescriptor hog;

Ptr<SVM> svm = StatModel::load<SVM>( "model.yml" );
Ptr<SVM> svm = StatModel::load<SVM>( "clasificador.yml" );

vector< float > hog_detector;

// get the support vectors
Mat sv = svm->getSupportVectors();
const int sv_total = sv.rows;

// get the decision function
Mat alpha, svidx;
double rho = svm->getDecisionFunction(0, alpha, svidx);

CV_Assert( alpha.total() == 1 && svidx.total() == 1 && sv_total == 1 );
CV_Assert( (alpha.type() == CV_64F && alpha.at<double>(0) == 1.) ||
           (alpha.type() == CV_32F && alpha.at<float>(0) == 1.f) );
CV_Assert( sv.type() == CV_32F );

hog_detector.clear();
hog_detector.resize(sv.cols + 1);
memcpy(&hog_detector[0], sv.ptr(), sv.cols*sizeof(hog_detector[0]));
hog_detector[sv.cols] = (float)-rho;

hog.setSVMDetector( hog_detector );

// Then, it take me about 6 s!!
hog.detectMultiScale(img, detections, thresholdDetection, winStride, padding);