need help with load and display image with opencv
Hi there!
I tried the source code given by the tutorials for load and display images.
#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;
}
Once I compiled, it came out with these errors.
Compiler: OpenCV2 Executing g++.exe... g++.exe "C:\Users\nurulazila\Desktop\please.cpp" -o "C:\Users\nurulazila\Desktop\please.exe" -L"C:\OpenCV2.4.6\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:\Users\nurulazila\Desktop\opencv\include\opencv" -I"C:\Users\nurulazila\Desktop\opencv\include\opencv2" -I"C:\opencv\build\include" -L"C:\Dev-Cpp\lib" -L"C:\Users\nurulazila\Desktop\opencv\build\x86\mingw\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
I guess there are no errors in the coding. Please help me! I tried few times but still got the same errors.
Appreciate your help!