Ask Your Question
0

'CvRTParams' : undeclared identifier (RandomForest, OpenCV, C++)

asked 2017-07-06 00:42:23 -0600

BhgSr gravatar image

updated 2017-07-06 01:33:03 -0600

I am trying to implement Random Forest Classifier using OpenCV C++. But "CvRTParams", "CvRTrees", these keywords are not being recognized by my program and showing as "identifier undeclared". I have included the header "ml.h" and other related headers. Also, the library path is correct.

Relevant Lines, CvRTrees *rtree = new CvRTrees; CvRTParams params = CvRTParams("all the parameters");

And I am using OpenCV 3 and Visual Studio 2012.

edit retag flag offensive close merge delete

Comments

opencv version ? api has changed a lot from opencv1.0 (ml.h). you just seem to use outdated code

berak gravatar imageberak ( 2017-07-06 00:47:52 -0600 )edit

also, please add the relevant lines of code to your question

berak gravatar imageberak ( 2017-07-06 00:51:34 -0600 )edit

These are the lines, CvRTrees *rtree = new CvRTrees; CvRTParams params = CvRTParams("all the parameters");

And I am using OpenCV 3.

BhgSr gravatar imageBhgSr ( 2017-07-06 01:29:54 -0600 )edit

Can you please tell me how to create this train and test file. What should be the format ? I am confused.

BhgSr gravatar imageBhgSr ( 2017-07-07 01:28:48 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-07-06 02:27:52 -0600

berak gravatar image

again, api has changed significantly with opencv3. please use:

#include <opencv2/ml.hpp> // NOT the C-api (!!) ml.h
Ptr<RTrees> rtrees = RTrees::create(); // you HAVE TO use cv::Ptr.
rtrees->setMaxDepth(10);    // no more Params struct, setters/getters instead.
rtrees->setMinSampleCount(2);
...

have a look here for a complete example

edit flag offensive delete link more

Comments

Thank you friend. This info is very helpful to me.

Can you please advise how can I read .csv data into Ptr<traindata> format ? What do these parameters mean in the loadFromCSV() function ?

TrainData::loadFromCSV(filename, 0, response_idx, response_idx+1, typespec);

BhgSr gravatar imageBhgSr ( 2017-07-06 08:07:14 -0600 )edit

Can you please tell me how to create this train and test file. What should be the format ? I am confused.

BhgSr gravatar imageBhgSr ( 2017-07-07 01:28:41 -0600 )edit

this is a totally unrelated question, now. please use the search box and eventually ask a new question

berak gravatar imageberak ( 2017-07-07 01:35:15 -0600 )edit

Ok friend.

BhgSr gravatar imageBhgSr ( 2017-07-07 08:43:50 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-07-06 00:42:23 -0600

Seen: 492 times

Last updated: Jul 06 '17