[英]g++ openCV compile error on line that doesn't exist
I am trying to compile and run the following program with gcc test.cpp -o test
. 我正在尝试使用
gcc test.cpp -o test
编译并运行以下程序。 But I'm getting this error: 但我收到此错误:
In file included from test.cpp:4:
/usr/local/include/opencv/cvaux.hpp:49:10: error: 'cvaux.h' file not found with <angled>
include; use "quotes" instead
#include <cvaux.h>
^
1 error generated.
That line isn't in the program though. 但是该行不在程序中。 What can I do to rectify this?
我该怎么办才能纠正这个问题?
Program: 程序:
// Example showing how to read and write images
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv/cvaux.hpp>
int main(int argc, char** argv)
{
IplImage * pInpImg = 0;
// Load an image from file - change this based on your image name
pInpImg = cvLoadImage("my_image.jpg", CV_LOAD_IMAGE_UNCHANGED);
if(!pInpImg)
{
fprintf(stderr, "failed to load input image\n");
return -1;
}
// Write the image to a file with a different name,
// using a different image format -- .png instead of .jpg
if( !cvSaveImage("my_image_copy.png", pInpImg) )
{
fprintf(stderr, "failed to write image file\n");
}
// Remember to free image memory after using it!
cvReleaseImage(&pInpImg);
return 0;
}
"What can I do to rectify this?" “我该怎么做才能纠正这一点?”
use the c++ api instead: 改用C ++ API:
// Example showing how to read and write images
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
int main(int argc, char** argv)
{
// Load an image from file - change this based on your image name
Mat img = imread("my_image.jpg", CV_LOAD_IMAGE_UNCHANGED);
if(img.empty())
{
fprintf(stderr, "failed to load input image\n");
return -1;
}
// this is just to show, that you won't have to pre-alloc
// result-images with c++ any more..
Mat gray;
cvtColor(img,gray,CV_BGR2GRAY);
// Write the image to a file with a different name,
// using a different image format -- .png instead of .jpg
if( ! imwrite("my_image_gray.png", gray) )
{
fprintf(stderr, "failed to write image file\n");
}
// no need to release anything with c++ !
return 0;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.