zakjma
zakjma

Reputation: 2110

‘CvLoadImage’ was not declared in this scope

I try to use OpenCV C Api in my code. I have opencv and opencv2 folder under usr/include. I can use OpenCV C++ Api. C++ code and compilation&linking commands are below :

#include <iostream>
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/opencv.hpp"

using namespace cv;

int main()
{

    Mat im = imread("Sobel.jpg");
    return 0;
}

Compile : g++ -c main.cpp

Linking : g++ -o exe main.opkg-config --libs opencv`

Now I want to use OpenCV C-Api. My code is here :

#include <iostream>
#include "opencv/cv.h"
#include "opencv/highgui.h"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/opencv.hpp"

using namespace cv;

int main()
{

    IplImage* pImg = CvLoadImage("Sobel.jpg");
    if(pImg == NULL)
         return -1;

    // ... big bloat to do the same operations with IplImage    

    CvShowImage("Image", pImg);
    cvWaitKey();
    CvReleaseImage(&pImg); // Do not forget to release memory.
    // end code here

    return 0;
}

When I compile g++ -c main.cpp, the compiler says that ‘CvLoadImage’ was not declared in this scope

Upvotes: 2

Views: 4497

Answers (1)

GPPK
GPPK

Reputation: 6666

A simple spelling mistake, the function prototype is

IplImage* cvLoadImage( const char* filename, int iscolor=CV_LOAD_IMAGE_COLOR );

Upvotes: 2

Related Questions