title: Reading SVM model generated by MATLAB in OpenCV
body: <p>I have generated SVM model using matlab. Now I want to load SVM model in OpenCV. Here is my matlab code to get the SVM model.</p>
  
  <pre><code>pos_mat = matfile('positve200.mat');             % positve samples
  neg_mat = matfile('Negative200.mat');            % negative samples 
  postest_mat = matfile('test.mat');               % positive test samples
  negtest_mat = matfile('test1.mat');              % negative test samples
  negtest_mat1= matfile('Test2.mat');              % negative test samples
  
  posRow  = pos_mat.bigmat;                        % get positve samples
  negRow  = neg_mat.bigmatneg;                     % get negative samples
  negRow(34,:) = negRow(1,:);
  
  cartestRow = postest_mat.out;             
  negtestRow = negtest_mat.negtestsamples;  
  negtestRow1 = negtest_mat1.bigmatneg;
  
  
  group = ones(68,1);
  group(35:68) = -1;
  t = 35;
  for i =1:1:34
      posRow(t,:) = (negRow(i,:));
      t = t+1;
  end
  
  xdata = posRow;
  
  SVMModel = fitcsvm(xdata,group);
  </code></pre>
  
  <p>Can someone help me to load SVM model in OpenCV and then use the values generated by the SVM model similarly to that of default people detector in <a href="https://www.dropbox.com/s/kgsacm2u88aprf4/hog.cpp?dl=0" rel="nofollow">hog.cpp</a>.  Please see the following two functions. </p>
  
  <ul>
  <li>std::vector cv::gpu::HOGDescriptor::getPeopleDetector48x96()</li>
  <li>std::vector cv::gpu::HOGDescriptor::getPeopleDetector64x128()</li>
  </ul>
  
  <p>I want to get values similar to those for my own SVM classifier.  You can find mat files <a href="https://www.dropbox.com/sh/4a5wowonhl68v8d/AACHsmfKJY815DmNnitM7Aina?dl=0" rel="nofollow">here</a></p>
  
  <p><strong>Updated:</strong>
  I used Beta values and then save it to yaml file. I used this yaml file in OpenCV to detect the object for which I trained the classifier.  Here is the code</p>
  
  <pre><code>sv    = SVMModel.IsSupportVector;
  alpha = SVMModel.Alpha;
  bias  = SVMModel.Bias;
  beta  = (SVMModel.Beta)';
  
  
  fid = fopen(sprintf('%s.yml','vecSupport'),'a');
  fprintf(fid,'%s','%YAML:1.0');
  fprintf(fid,'\n');
  fprintf(fid,'%s','vector: ');
  fprintf(fid,'%s','[ ');
  
  for i = 1:1:2772
      fprintf(fid,'%d',beta(i));
      if (i&lt;2772)
      fprintf(fid,'%s',', ');
      end
  end
  fprintf(fid,'%s',' ]');
  fclose(fid);
  </code></pre>