Ask Your Question
0

'ml' : is not a class or namespace name

asked 2020-06-23 13:41:15 -0500

updated 2020-06-23 20:39:37 -0500

supra56 gravatar image

Hi I am using opencv 2.4.13 and I built it in vs2008. Now I want to load a random tree model with .yml extension (saved by python) using c++. I tried the following code:

#include <opencv2/ml.hpp>
#include "opencv2/legacy/legacy.hpp"
#include <iostream>

using namespace cv;
using namespace std;

int main()
{
    Ptr<ml::RTrees> rf = ml::StatModel::load<ml::RTrees>("rf.yml");
    return 0;
}

I got the following errors :

main.cpp(10) : error C2653: 'ml' : is not a class or namespace name
1>.\main.cpp(10) : error C2065: 'RTrees' : undeclared identifier
1>.\main.cpp(10) : error C2653: 'ml' : is not a class or namespace name
1>.\main.cpp(10) : error C2065: 'load' : undeclared identifier
1>.\main.cpp(10) : error C2653: 'ml' : is not a class or namespace name
1>.\main.cpp(10) : error C2065: 'RTrees' : undeclared identifier

I am newbie in opencv. Please help me to correct the above errors.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2020-06-24 00:56:23 -0500

berak gravatar image

updated 2020-06-24 01:46:28 -0500

the code you try to use is from opencv3.x, the api has changed significantly,

you cannot use it with the opencv 2.4 api, which is discontinued and no more maintained. it's also doubtful, if you can read back your yml generated from a current (python) version back into 2.4 code

you really should update to a more recent opencv version, like 3.4.10 (master/4.x won't compile with VS2008, which is also stone-age)

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-06-23 13:41:15 -0500

Seen: 52 times

Last updated: Jun 24