最近看別人寫的軟體,想在其中匯入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”
。。。
uj5u.com熱心網友回復:
應該需要配置一下uj5u.com熱心網友回復:
http://wiki.opencv.org.cn/index.php/Template:Install配置看這里吧
uj5u.com熱心網友回復:
opencv 2.4我一開始裝好了并且配好環境了。現在發現的問題是:在軟體中無法包含#include<iostream>,不管是頭檔案還是源檔案中加了這個都會報錯。如果只是包含了opencv的頭檔案,可以使用opencv中一些不帶有cv::,如CvMat,IplImage等,而像cv::Mat,以及一些需要cv::的函式就不能使用,此時不能加using namespace cv會報錯。
所以覺得不是opencv的問題,應該是iostream這的問題,然而找了很久一直沒有頭緒,還望各位指教!
uj5u.com熱心網友回復:
乍看起來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。
uj5u.com熱心網友回復:
在OpenCV中IplImage這些是C介面,Mat是C++介面,懷疑是C++的代碼你用了C編譯器來編譯。轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/85618.html
標籤:圖形處理/算法
下一篇:win32繪制直線問題
