C语言下opencv的配置

qq_38374736 2017-09-27 06:50:54
最近看别人写的软件,想在其中导入Opencv的库,其中部分头文件如下所示
#ifndef _LPRTYPE_H_
#define _LPRTYPE_H_

#include <time.h>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

在其中加入:
#include<iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
后就出现了如下一大堆错误。
然而调用opencv的函数包括Mat类型等均需要cv::

追踪错误点在:
using _CSTD abs; using _CSTD acos; using _CSTD asin;
using _CSTD atan; using _CSTD atan2; using _CSTD ceil;
using _CSTD cos; using _CSTD cosh; using _CSTD exp;
using _CSTD fabs; using _CSTD floor; using _CSTD fmod;
using _CSTD frexp; using _CSTD ldexp; using _CSTD log;
using _CSTD log10; using _CSTD modf; using _CSTD pow;
using _CSTD sin; using _CSTD sinh; using _CSTD sqrt;
using _CSTD tan; using _CSTD tanh;

刚开始接触不久,不知道该如何解决这个问题。

望各位大神指点,谢谢!

错误:
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\cmath(23): error C2061: 语法错误: 标识符“abs”
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\cmath(23): error C2059: 语法错误:“;”
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\cmath(23): error C2061: 语法错误: 标识符“acos”
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\cmath(23): error C2061: 语法错误: 标识符“asin”
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\cmath(24): error C2061: 语法错误: 标识符“atan”
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\cmath(24): error C2059: 语法错误:“;”
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\cmath(24): error C2061: 语法错误: 标识符“atan2”
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\cmath(24): error C2061: 语法错误: 标识符“ceil”
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\cmath(25): error C2061: 语法错误: 标识符“cos”
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\cmath(25): error C2059: 语法错误:“;”
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\cmath(25): error C2061: 语法错误: 标识符“cosh”
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\cmath(25): error C2061: 语法错误: 标识符“exp”
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\cmath(26): error C2061: 语法错误: 标识符“fabs”
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\cmath(26): error C2059: 语法错误:“;”
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\cmath(26): error C2061: 语法错误: 标识符“floor”
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\cmath(26): error C2061: 语法错误: 标识符“fmod”
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\cmath(27): error C2061: 语法错误: 标识符“frexp”
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\cmath(27): error C2059: 语法错误:“;”
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\cmath(27): error C2061: 语法错误: 标识符“ldexp”
。。。

...全文
1410 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
liups 2017-09-28
  • 打赏
  • 举报
回复
qq_38374736 2017-09-28
  • 打赏
  • 举报
回复
opencv 2.4我一开始装好了并且配好环境了。 现在发现的问题是:在软件中无法包含#include<iostream>,不管是头文件还是源文件中加了这个都会报错。如果只是包含了opencv的头文件,可以使用opencv中一些不带有cv::,如CvMat,IplImage等,而像cv::Mat,以及一些需要cv::的函数就不能使用,此时不能加using namespace cv会报错。 所以觉得不是opencv的问题,应该是iostream这的问题,然而找了很久一直没有头绪,还望各位指教!
老之 2017-09-28
  • 打赏
  • 举报
回复
在OpenCV中IplImage这些是C接口,Mat是C++接口,怀疑是C++的代码你用了C编译器来编译。
赵4老师 2017-09-28
  • 打赏
  • 举报
回复
乍看起来c++的cin、cout、ifstream、ofstream、istringstream、ostringstream在输入、输出上比c的scanf、printf、fscanf、fprintf、fread、fwrite、sscanf、sprintf简单,不用格式控制符! 但是不用格式控制符,输入输出恰好是你期望的格式的时候好说;等到输入输出不是你期望的格式的时候,你就会觉得还是用格式控制符更方便、更靠谱。 摒弃cin、cout、ifstream、ofstream、istringstream、ostringstream! 使用scanf、printf、fscanf、fprintf、fread、fwrite、sscanf、sprintf。
shiter 2017-09-27
  • 打赏
  • 举报
回复
应该需要配置一下

19,468

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧