C++ OpenCV svm train crashes
<p>I have two vectors:</p>

<pre><code>vector&lt;int&gt; features;
vector&lt;int&gt; labels;
</code></pre>

<p>And in some point into my program I fill them with some values. (both vectors same size) Then, when I want to train the <code>svm</code> I copy the vectors into 2 new <code>cv::Mat</code> like this:</p>

<pre><code>Mat trainMat(features.size(), 1, CV_32FC1);
Mat labelsMat(labels.size(), 1, CV_32FC1);
for (int i = 0; i &lt; features.size(); i++) {
    trainMat.at&lt;int&gt;(i, 1) = features.at(i);
    labelsMat.at&lt;int&gt;(i, 1) = labels.at(i);
}
</code></pre>

<p>Then I create the <code>svm</code> and it's <code>params</code>:</p>

<pre><code>cv::SVMParams params;
params.svm_type = cv::SVM::C_SVC;
params.kernel_type = cv::SVM::POLY;
params.gamma = 3;
cv::SVM svm;
</code></pre>

<p>And finally I train it:</p>

<pre><code>svm.train(trainMat, labelsMat, Mat(), Mat(), params);
</code></pre>

<p>But, the program crashes and gives this error:</p>

<pre><code>Unhandled exception at 0x7484D928 in cvtest.exe: Microsoft C++ exception: cv::Exception at memory location 0x0017F04.
</code></pre>

<p>At first, I thought the problem was the size of the data(because I compile it at 32bit). So, I used only 20, even 4 samples just to test it. But, still crashing. What else could result a memory error?</p>