OpenCV unable to set up SVM Parameters

前端 未结 2 2072
忘掉有多难
忘掉有多难 2020-11-29 09:59

I have just started my learning on SVM using C++ OpenCV and was referring to the SVM documentation here. I wanted to try out the sample source code from the link to get fami

2条回答
  •  隐瞒了意图╮
    2020-11-29 10:18

    I found the code above worked but I needed to make a small modification to convert the labels to integers. The modification is in bold:

    // Set up training data **Original**:
    
    int labels[4] = { 1, -1, -1, -1 };
    
    Mat labelsMat(4, 1, **CV_32SC1**, labels);
    
    // Set up training data **Modified**:
    
    int labels[4] = { 1, -1, -1, -1 };
    
    Mat labelsMat(4, 1, **CV_32S**, labels);
    

提交回复
热议问题