【发布时间】:2017-10-10 06:55:00
【问题描述】:
我使用ubuntu 14.04 和opencv 为C++
我想运行这个项目:https://github.com/sharpe-developer/Realtime-Digit-Classifier 如果我愿意:
g++ -o l RealtimeDigitClassifier.cpp `pkg-config --cflags --libs opencv`
我明白了:
In file included from HogSvm.h:19:0,
from RealtimeDigitClassifier.cpp:16:
Svm.h:44:23: error: ‘cv::ml’ has not been declared
void SetType(cv::ml::SVM::Types type) const;
^
Svm.h:44:38: error: expected ‘,’ or ‘...’ before ‘type’
void SetType(cv::ml::SVM::Types type) const;
^
Svm.h:45:25: error: ‘cv::ml’ has not been declared
void SetKernel(cv::ml::SVM::KernelTypes kernel) const;
^
Svm.h:45:46: error: expected ‘,’ or ‘...’ before ‘kernel’
void SetKernel(cv::ml::SVM::KernelTypes kernel) const;
^
Svm.h:63:13: error: ‘ml’ is not a member of ‘cv’
cv::Ptr<cv::ml::SVM> m_svm;
^
Svm.h:63:13: error: ‘ml’ is not a member of ‘cv’
Svm.h:63:24: error: template argument 1 is invalid
cv::Ptr<cv::ml::SVM> m_svm;
^
RealtimeDigitClassifier.cpp: In function ‘void ProcessFrame(const HogSvm&, const HogSvm&, cv::Mat&, cv::Mat&)’:
RealtimeDigitClassifier.cpp:60:34: error: ‘>>’ should be ‘> >’ within a nested template argument list
std::vector<std::vector<Point>> contours;
^
RealtimeDigitClassifier.cpp:99:35: error: ‘to_string’ is not a member of ‘std’
putText(displayFrame, std::to_string(prediction), boundRect.tl() - Point(0, 5), FONT_HERSHEY_PLAIN, 1.4, Scalar(0, 0, 0));
^
RealtimeDigitClassifier.cpp: In function ‘int main(int, char**)’:
RealtimeDigitClassifier.cpp:141:57: error: ‘CAP_PROP_FRAME_WIDTH’ was not declared in this scope
Size vidSize = Size(static_cast<int>(vidCapture.get(CAP_PROP_FRAME_WIDTH)),
^
RealtimeDigitClassifier.cpp:142:57: error: ‘CAP_PROP_FRAME_HEIGHT’ was not declared in this scope
static_cast<int>(vidCapture.get(CAP_PROP_FRAME_HEIGHT)));
^
有什么问题以及如何编译这个项目?
【问题讨论】:
-
您自己构建了 OpenCV 库,还是只是下载了预编译的库?在后一种情况下,ml 模块可能尚未包含在您的库中。如果是这种情况,您需要自己构建您的 OpenCV 库。
-
究竟应该怎么做? ?我是怎么做到的?
-
在继续之前,首先检查 ml 模块是否真的不包含在您的 OpenCV 中,因为自己构建 OpenCV 可能是一项耗时的工作。尝试
#include <opencv2/ml.hpp>,如果找不到标头,那么您应该尝试按照this 指南构建您的OpenCV。 -
'c.cpp:1:26: 致命错误:opencv2/ml.hpp: 没有这样的文件或目录'
-
@devnglee thnx 获取此链接:docs.opencv.org/2.4/doc/tutorials/introduction/windows_install/… 但我有 Ubuntu