我尝试使用opencv版本2.4.6编译此源代码以加载和显示图像。我认为应该没有错误,因为我在互联网上获得了这些代码。但我仍然遇到一些错误,我不知道如何解决它。
我的代码:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main( int argc, char** argv )
{
if( argc != 2)
{
cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
return -1;
}
Mat image;
image = imread(argv[1], CV_LOAD_IMAGE_COLOR); // Read the file
if(! image.data ) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}
namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// Create a window for display.
imshow( "Display window", image ); // Show our image inside it.
waitKey(0); // Wait for a keystroke in the window
return 0;
}
错误来自其他文件。我猜它来自图书馆。我不知道我是否错误地将opencv与我的devc ++相关联。但我想我已经按照给出的所有步骤做了正确的事。
请帮帮我!我不明白错误所在的代码。
这些是错误:
Compiler: OpenCV2
Executing g++.exe...
g++.exe "C:\Users\nurulazila\Desktop\please.cpp" -o "C:\Users\nurulazila\Desktop\please.exe" -L"C:\opencv\build\x86\mingw\lib" -lcxcore2460 -lcv2460 -lcvaux2460 -lhighgui2460 -lml2460 -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"C:\opencv\build\include" -L"C:\Dev-Cpp\lib" -L"C:\opencv\build\x86\mingw\lib" -lcxcore2460 -lcv2460 -lcvaux2460 -lhighgui2460 -lml2460
In file included from C:/opencv/build/include/opencv2/core/core.hpp:4824,
from C:\Users\nurulazila\Desktop\please.cpp:1:
C:/opencv/build/include/opencv2/core/operations.hpp: In static member function `static cv::Ptr<_Tp2> cv::Algorithm::create(const std::string&)':
C:/opencv/build/include/opencv2/core/operations.hpp:3918: error: expected primary-expression before '>' token
C:/opencv/build/include/opencv2/core/operations.hpp:3918: error: expected primary-expression before ')' token
C:/opencv/build/include/opencv2/core/operations.hpp: At global scope:
C:/opencv/build/include/opencv2/core/operations.hpp:3970: 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&)'
C:/opencv/build/include/opencv2/core/operations.hpp:3970: error: but 1 required
C:/opencv/build/include/opencv2/core/operations.hpp:3979: 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&)'
C:/opencv/build/include/opencv2/core/operations.hpp:3970: 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
Execution terminated
这些错误来自opencv目录中core文件夹中的文件operations.cpp。
我确实需要帮助,因为我是带图像的代码的初学者。
感谢任何帮助!感谢