“CvLoadImage”未在此范围内声明



我尝试在我的代码中使用OpenCV C Api。我在usr/include下有opencvopencv2文件夹。我可以使用OpenCV C++ API。C++代码和编译和链接命令如下:

#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;
}

编译 : g++ -c main.cpp

链接 : g++ -o exe main.o pkg-config --libs opencv'

现在我想使用 OpenCV C-API。我的代码在这里:

#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;
}

当我编译g++ -c main.cpp时,编译器说‘CvLoadImage’ was not declared in this scope

一个简单的拼写错误,函数原型是

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

相关内容

  • 没有找到相关文章

最新更新