Ask Your Question
1

need help with load and display image with opencv

asked 2013-10-17 06:21:04 -0600

kimjaezie gravatar image

updated 2015-10-02 16:08:17 -0600

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 ofvoid 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!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-10-18 02:42:44 -0600

zulfiqar gravatar image

recheck your linking from the following link . It may help you as I have done linking from this link

http://linkopencvtovs.blogspot.com/2013/10/how-to-link-opencv-to-microsoft-visual.html
edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-10-17 06:21:04 -0600

Seen: 1,216 times

Last updated: Oct 18 '13