我正在使用Dev C ++ 4.9.9.2和OpenCV 2.4.8,我也在使用Windows 7 x86。这些都在我的编译器设置中,-L"D:\opencv\build\x86\vc12\bin" -lopencv_highgui248 -lopencv_core248 -lopencv_flann248 -lopencv_gpu248 -lopencv_imgproc248 -lopencv_legacy248 -lopencv_ml248 -lopencv_nonfree248 -lopencv_objdetect248 -lopencv_photo248 -lopencv_video248 -lopencv_ts248.
每次编译我的简单项目时,都会显示以下错误:编译器:
OpenCV
Executing g++.exe...
g++.exe "D:\VS Projects\WebCam\WebCam\loadimg.cpp" -o "D:\VS Projects\WebCam\WebCam\loadimg.exe" -g3 -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -I"D:\opencv\build\include\opencv2" -I"D:\opencv\build\include" -L"C:\Dev-Cpp\lib" -L"D:\opencv\build\x86\vc12\lib" -g3
In file included from D:/opencv/build/include/opencv2/core/core.hpp:4854,
from D:/opencv/build/include/opencv2/opencv.hpp:47,
from D:\VS Projects\WebCam\WebCam\loadimg.cpp:1:
D:/opencv/build/include/opencv2/core/operations.hpp: In static member function `static cv::Ptr<_Tp2> cv::Algorithm::create(const std::string&)':
D:/opencv/build/include/opencv2/core/operations.hpp:3972: error: expected primary-expression before '>' token
D:/opencv/build/include/opencv2/core/operations.hpp:3972: error: expected primary-expression before ')' token
D:/opencv/build/include/opencv2/core/operations.hpp: At global scope:
D:/opencv/build/include/opencv2/core/operations.hpp:4024: error: got 2 template parameters for `void cv::AlgorithmInfo::addParam(cv::Algorithm&, const char*, cv::Ptr<_Tp2>&, bool, cv::Ptr<_Tp2> (cv::Algorithm::*)(), void (cv::Algorithm::*)(const cv::Ptr<_Tp2>&), const std::string&)'
D:/opencv/build/include/opencv2/core/operations.hpp:4024: error: but 1 required
D:/opencv/build/include/opencv2/core/operations.hpp:4033: error: redefinition of `void cv::AlgorithmInfo::addParam(cv::Algorithm&, const char*, cv::Ptr<_Tp2>&, bool, cv::Ptr<_Tp2> (cv::Algorithm::*)(), void (cv::Algorithm::*)(const cv::Ptr<_Tp2>&), const std::string&)'
D:/opencv/build/include/opencv2/core/operations.hpp:4024: error: `void cv::AlgorithmInfo::addParam(cv::Algorithm&, const char*, cv::Ptr<_Tp2>&, bool, cv::Ptr<_Tp2> (cv::Algorithm::*)(), void (cv::Algorithm::*)(const cv::Ptr<_Tp2>&), const std::string&)' previously declared here
编辑: 有我的代码。
include <opencv2/opencv.hpp>
#include <iostream>
#include <io.h>
using namespace cv;
using namespace std;
int main (int, char**)
{
cv::VideoCapture camera(1);
if(!camera.isOpened())
{
std::cerr << "ERROR: Could not open camera" << std::endl;
return 1;
}
cv::namedWindow("Webcam", CV_WINDOW_AUTOSIZE);
while(1)
{
cv::Mat frame;
camera >> frame;
cv::imshow("Webcam", frame);
if (cv::waitKey(30) >= 0)
{
imwrite("test.jpg", frame);
break;
}
}
return 0;
}
执行终止
你能帮我解决这个问题吗?请。 感谢。