linux环境中如何运行第一个opencv程序,我环境配置好了,就是运行的时候提示有错。如能解决,另外加分 20
#include"cv.h"#include"highgui.h"usingnamespacecv;//下面的所有cv相关类型不用加上前缀了intmain(intargc...
#include "cv.h"
#include "highgui.h"
using namespace cv; //下面的所有cv相关类型不用加上前缀了
int main(int argc, char* argv[])
{
Mat img = imread("lena.jpg"); //声明Mat变量并调入lena小妞(老妞了现在?)的照片
if(!img.data) //判断图片调入是否成功
return -1; //调入图片失败则退出
namedWindow("loveLena", CV_WINDOW_AUTOSIZE); //创建窗口,并确定其为大小不可变类型窗口
imshow("loveLena", img); //显示图片。如果你不介意窗口大小可变,可以直接注释掉上一句。因为imshow可以直接创建窗口
waitKey(); //等待按键
return 0;
}
运行后提示的错误如下:(简单的说就是using namespace cv;这里好像有错)
Description Resource Path Location Type
‘cv’ is not a namespace-name sd.cpp /opencv1 line 4 C/C++ Problem
‘img’ was not declared in this scope sd.cpp /opencv1 line 10 C/C++ Problem
‘img’ was not declared in this scope sd.cpp /opencv1 line 15 C/C++ Problem
‘imshow’ was not declared in this scope sd.cpp /opencv1 line 15 C/C++ Problem
‘Mat’ was not declared in this scope sd.cpp /opencv1 line 8 C/C++ Problem
‘namedWindow’ was not declared in this scope sd.cpp /opencv1 line 13 C/C++ Problem
‘waitKey’ was not declared in this scope sd.cpp /opencv1 line 17 C/C++ Problem
expected ‘;’ before ‘img’ sd.cpp /opencv1 line 8 C/C++ Problem
expected namespace-name before ‘;’ token sd.cpp /opencv1 line 4 C/C++ Problem
make: *** [sd.o] 错误 1 opencv1 C/C++ Problem 展开
#include "highgui.h"
using namespace cv; //下面的所有cv相关类型不用加上前缀了
int main(int argc, char* argv[])
{
Mat img = imread("lena.jpg"); //声明Mat变量并调入lena小妞(老妞了现在?)的照片
if(!img.data) //判断图片调入是否成功
return -1; //调入图片失败则退出
namedWindow("loveLena", CV_WINDOW_AUTOSIZE); //创建窗口,并确定其为大小不可变类型窗口
imshow("loveLena", img); //显示图片。如果你不介意窗口大小可变,可以直接注释掉上一句。因为imshow可以直接创建窗口
waitKey(); //等待按键
return 0;
}
运行后提示的错误如下:(简单的说就是using namespace cv;这里好像有错)
Description Resource Path Location Type
‘cv’ is not a namespace-name sd.cpp /opencv1 line 4 C/C++ Problem
‘img’ was not declared in this scope sd.cpp /opencv1 line 10 C/C++ Problem
‘img’ was not declared in this scope sd.cpp /opencv1 line 15 C/C++ Problem
‘imshow’ was not declared in this scope sd.cpp /opencv1 line 15 C/C++ Problem
‘Mat’ was not declared in this scope sd.cpp /opencv1 line 8 C/C++ Problem
‘namedWindow’ was not declared in this scope sd.cpp /opencv1 line 13 C/C++ Problem
‘waitKey’ was not declared in this scope sd.cpp /opencv1 line 17 C/C++ Problem
expected ‘;’ before ‘img’ sd.cpp /opencv1 line 8 C/C++ Problem
expected namespace-name before ‘;’ token sd.cpp /opencv1 line 4 C/C++ Problem
make: *** [sd.o] 错误 1 opencv1 C/C++ Problem 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询