Ask Your Question
0

How to run neural network code using opencv in C++

asked 2017-03-10 05:48:15 -0600

Su gravatar image

Hello I am new to OpenCV. I have a neural network code which is in c++. I am not able to run it. How do i run it please reply ASAP. Well am using ubuntu 14.04 and OpenCV 2.4.9

edit retag flag offensive close merge delete

Comments

we cannot help you, unless you get more specific. show us your code, tell us, where the exact problem is, please.

berak gravatar imageberak ( 2017-03-10 06:45:29 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-03-10 09:33:29 -0600

kbarni gravatar image

updated 2017-03-10 09:35:35 -0600

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[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.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-03-10 05:48:15 -0600

Seen: 130 times

Last updated: Mar 10 '17