namespace cv::ml not found - xcode - C++ [closed]

asked 2015-08-13 12:03:15 -0500

chr0x gravatar image

updated 2015-08-13 12:04:36 -0500

Hi guys. I'm using XCode IDE in my project and I'm trying to create a machine learning program using the ml lib. However, I'm getting an error when I try to use the namespace cv::ml. My includes are:

#include "opencv2/core/core.hpp"
#include "opencv2/ml/ml.hpp"

#include <cstdio>
#include <vector>
#include <iostream>

using namespace std;
using namespace cv;
using namespace cv::ml; --> In this line I get the error: "expected namespace name"

I guess that this error is related to some configuration that I hasn't applied on XCode. I'm using libc++ as standard lib and I already tried to change to libstdc++ (the problem persists). I also tried to use the objects in ml namespace using the fully qualified name, i.e. cv::ml::SomeMethod for example, but I get the error: "no member named ml in the namespace cv". The include of "opencv2/ml/ml.hpp" isn't generating errors.

Question is: How can I add this namespace (ml) to my project in XCode?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by chr0x
close date 2015-08-14 06:49:50.078345


  • if you're using opencv2.4.x: - there is no namespace ml.
berak gravatar imageberak ( 2015-08-13 12:17:40 -0500 )edit

Hm. You're right. I was trying to use the command cv::ml::RTrees. The correct command for version 2.4 is the CvRTrees (I found that weird, because to me everything that begin with Cv... was part of the old API, the C API, but it seems to be not true). Thank you very much berak!

chr0x gravatar imagechr0x ( 2015-08-13 12:50:21 -0500 )edit

The ML module was about the last module that got transfered to the new C++ interface. THat only happened when going to the 3.0 interface. In 2.4.11 there was already a C++ backend partially, but the names where still C-style.

StevenPuttemans gravatar imageStevenPuttemans ( 2015-08-14 04:24:25 -0500 )edit

I think for using EM in 2.4.13 version , one gotta add #include "opencv2/legacy/legacy.hpp" before using CvEM

Hemang gravatar imageHemang ( 2017-05-05 16:38:23 -0500 )edit