在此范围内未声明“CvLoadImage”

时间:2015-06-16 14:27:54

标签: c++ c opencv compiler-errors

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

usr/include

编译:{{1​​}}

链接:#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; } pkg-config --libs opencv`

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

g++ -c main.cpp

当我编译g++ -o exe main.o时,编译器会说#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; }

1 个答案:

答案 0 :(得分:2)

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

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