overscore icon indicating copy to clipboard operation
overscore copied to clipboard

Build error

Open Reichenbachian opened this issue 8 years ago • 1 comments

Upon building on an updated Mac with the given build string, I get the following traceback.

opencv_knn.cpp:32:15: error: expected ';' after expression
  cv::KNearest knn(trainingSet, labels);
              ^
              ;
opencv_knn.cpp:32:7: error: no member named 'KNearest' in namespace 'cv'
  cv::KNearest knn(trainingSet, labels);
  ~~~~^
opencv_knn.cpp:32:16: error: use of undeclared identifier 'knn'
  cv::KNearest knn(trainingSet, labels);
               ^
opencv_knn.cpp:50:5: error: use of undeclared identifier 'knn'
    knn.find_nearest(vec, k, label);

According to https://stackoverflow.com/questions/9155109/expected-after-expression, it seems this is a visual basic studios problem, meaning an error that's ignored in visual studios, but I don't know how to fix it. Any suggestions?

Reichenbachian avatar Feb 19 '18 17:02 Reichenbachian

This looks more like an incompatibility between the code and the version of OpenCV. This code dates from a few years ago, and the interface of OpenCV seems to have changed since then: the KNearest class is now in the cv::ml namespace (https://docs.opencv.org/trunk/dd/de1/classcv_1_1ml_1_1KNearest.html). Replacing cv::KNearest by cv::ml::KNearest might do the trick if this is the only incompatibility.

acieroid avatar Feb 21 '18 08:02 acieroid