I'm trying to build this code
#include "stdafx.h"
#include <iostream>
#include <math.h>
#include "opencv2/core/core_c.h"
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui_c.h"
#include "opencv2/highgui/highgui.hpp"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int pixel;
Mat matC1_32S;
return 0;
}
and I'm getting an error:
1>c:\test1\test1\test1.cpp(21): error C2065: 'Mat' : undeclared identifier
1>c:\test1\test1\test1.cpp(21): error C2146: syntax error : missing ';' before identifier 'matC1_32S'
1>c:\test1\test1\test1.cpp(21): error C2065: 'matC1_32S' : undeclared identifier
What additional includes should I have? or somethind else?
You aren't providing a namespace for Mat. This will work if you link to the OpenCV libraries when you compile:
#include "stdafx.h"
#include <iostream>
#include <math.h>
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
using namespace std;
int _tmain(int argc, _TCHAR* argv[]) {
int pixel;
cv::Mat matC1_32S;
return 0;
}
Or you can add using namespace cv;
before _tmain
so that you don't have to preface every appearance.
Also, you're overdoing the #include statements. You don't need the *_c.h files. (Maybe you added those when you were trying to figure out why Mat wasn't declared.)
Thank you for help, but to make it work I actually had also to include the following
#ifdef _DEBUG
#pragma comment(lib, "opencv_core231d.lib")
#pragma comment(lib, "opencv_highgui231d.lib")
#pragma comment(lib, "opencv_imgproc231d")
#pragma comment(lib, "opencv_objdetect231d.lib")
#else
#pragma comment(lib, "opencv_core231.lib")
#pragma comment(lib, "opencv_highgui231.lib")
#pragma comment(lib, "opencv_imgproc231.lib")
#pragma comment(lib, "opencv_objdetect231.lib")
#endif
I understand why I need 'using namespace cv, but why do I need this stuff with pragma, despite that I provided libraries path in the project properties. ('m using VisualStudio 10
you have to go to properties >> C/C++ >> Avanced >> Compile As
and choose Compile as C++ code /TP
I did it. It works.
I'm trying to build this code
#include "stdafx.h"
#include <iostream>
#include <math.h>
#include "opencv2/core/core_c.h"
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui_c.h"
#include "opencv2/highgui/highgui.hpp"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int pixel;
Mat matC1_32S;
return 0;
}
and I'm getting an error:
1>c:\test1\test1\test1.cpp(21): error C2065: 'Mat' : undeclared identifier
1>c:\test1\test1\test1.cpp(21): error C2146: syntax error : missing ';' before identifier 'matC1_32S'
1>c:\test1\test1\test1.cpp(21): error C2065: 'matC1_32S' : undeclared identifier
What additional includes should I have? or somethind else?
You aren't providing a namespace for Mat. This will work if you link to the OpenCV libraries when you compile:
#include "stdafx.h"
#include <iostream>
#include <math.h>
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
using namespace std;
int _tmain(int argc, _TCHAR* argv[]) {
int pixel;
cv::Mat matC1_32S;
return 0;
}
Or you can add using namespace cv;
before _tmain
so that you don't have to preface every appearance.
Also, you're overdoing the #include statements. You don't need the *_c.h files. (Maybe you added those when you were trying to figure out why Mat wasn't declared.)
Thank you for help, but to make it work I actually had also to include the following
#ifdef _DEBUG
#pragma comment(lib, "opencv_core231d.lib")
#pragma comment(lib, "opencv_highgui231d.lib")
#pragma comment(lib, "opencv_imgproc231d")
#pragma comment(lib, "opencv_objdetect231d.lib")
#else
#pragma comment(lib, "opencv_core231.lib")
#pragma comment(lib, "opencv_highgui231.lib")
#pragma comment(lib, "opencv_imgproc231.lib")
#pragma comment(lib, "opencv_objdetect231.lib")
#endif
I understand why I need 'using namespace cv, but why do I need this stuff with pragma, despite that I provided libraries path in the project properties. ('m using VisualStudio 10
you have to go to properties >> C/C++ >> Avanced >> Compile As
and choose Compile as C++ code /TP
I did it. It works.
0 commentaires:
Enregistrer un commentaire