Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I cannot train data using knn

I am getting this error: OpenCV Error: Assertation failed <samples.type&lt;&gt;cv_32f ||="" samples.type&lt;&gt;cv_32s=""> in cv::ml::TrainDataImpl::setData

I have extracted feature and placed it in a String;

String features = "352111653512146120635735005";

Mat m;
    m.push_back(features);
    m.reshape(1, 1);

    freeman.push_back(m);
             labelMat.push_back(label);

             Ptr<ml::KNearest> knn = ml::KNearest::create();
        Ptr<ml::TrainData> td = ml::TrainData::create(feature, ml::ROW_SAMPLE, label);  <-----I am getting error here

I cannot train data using knn

I am getting this error: OpenCV Error: Assertation failed <samples.type&lt;&gt;cv_32f ||="" samples.type&lt;&gt;cv_32s=""> in cv::ml::TrainDataImpl::setData

I have extracted feature and placed it in a String;

//for loop

String features = "352111653512146120635735005";

Mat m;
    m.push_back(features);
    m.reshape(1, 1);

    freeman.push_back(m);
             labelMat.push_back(label);

             Ptr<ml::KNearest> knn = ml::KNearest::create();
        Ptr<ml::TrainData> td = ml::TrainData::create(feature, ml::ROW_SAMPLE, label);  <-----I am getting error here
click to hide/show revision 3
No.3 Revision

updated 2016-04-06 01:54:29 -0500

berak gravatar image

I cannot train data using knn

I am getting this error: error:

OpenCV Error: Assertation failed <samples.type&lt;&gt;cv_32f ||="" samples.type&lt;&gt;cv_32s=""> <samples.type<>CV_32F || samples.type<>CV_32S> in cv::ml::TrainDataImpl::setData

cv::ml::TrainDataImpl::setData

I have extracted feature and placed it in a String;

//for loop

String features = "352111653512146120635735005";

Mat m;
    m.push_back(features);
    m.reshape(1, 1);

    freeman.push_back(m);
             labelMat.push_back(label);

             Ptr<ml::KNearest> knn = ml::KNearest::create();
        Ptr<ml::TrainData> td = ml::TrainData::create(feature, ml::ROW_SAMPLE, label);  <-----I am getting error here