Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

It' difficult to help without any hint, but probably you'll have to convert the image data to your training data format. Something like:

vector<vector<uchar>> training_data;
vector<int> training_labels;
vector<Mat> images;
for(int i=0;i<images.size();i++){
    vector<uchar> data;
    for(int y=0;y<images[i].rows;y++){
        uchar *p=images[i].ptr(y);
        for(int x=0;x<images[i].cols;x++){
            data.push_back(p[i]);
        }
    }
    training_data.push_back(data);
}
mynetwork.train(train_data,train_labels);

It' difficult to help without any hint, but probably you'll have to convert the image data to your training data format. Something like:

vector<vector<uchar>> training_data;
vector<int> training_labels;
vector<Mat> images;
for(int i=0;i<images.size();i++){
    vector<uchar> data;
    for(int y=0;y<images[i].rows;y++){
        uchar *p=images[i].ptr(y);
        for(int x=0;x<images[i].cols;x++){
            data.push_back(p[i]);
data.push_back(p[x]);
        }
    }
    training_data.push_back(data);
}
mynetwork.train(train_data,train_labels);

The code is for you to get an idea how to transform your images into a training set; you'll have to adapt it to the data format needed by your network.