1

I am using OpenCV 2.1 in Visual Studio 2008. I've been trying to create a matrix and I've tried the commands cvCreateMat(), Mat.M, and M.create etc... But none of these commands got compiled. There is always some error, e.g when I use this command:

M(2,2,CV_8UC3,Scalar(0,0,255));

I get the following error:

'Mat' : undeclared identifier

the other time I used this command:

CvMat* mat = cvCreateMat( 5, 5,8UC1);

And the error was:

syntax error : 'bad suffix on number'

Could anyone let me know what's the issue...

tversteeg
  • 4,717
  • 10
  • 42
  • 77
Aayman Khalid
  • 446
  • 3
  • 12
  • 24
  • I think c++ interface is not implemented in opencv2.1 – Houssam Badri Mar 12 '13 at 07:06
  • So you're saying that I have to move to another version of openCV???@houssem Bdr – Aayman Khalid Mar 12 '13 at 07:13
  • yes, i think it will be the occasion. It is easy anyway and better to work with c++ interface. Move to 2.4.4 – Houssam Badri Mar 12 '13 at 07:26
  • but there is one thing,I saw opencv 2.1 tutorial and mat commands were shown...which means that c++ commands can be implemented in opencv 2.1???@houssem Badr – Aayman Khalid Mar 12 '13 at 08:09
  • C++ interface **is** available in 2.1. Please check your headers - best start with a tutorial on how to write your first OpenCV app - most probably you did not configure your project correctly – Sam Mar 12 '13 at 09:33
  • It's working fine for other data types namely IPl* image.....I've compiled programs and they wrork fine,the issue lies with matrices...@sammy – Aayman Khalid Mar 12 '13 at 10:20

1 Answers1

3

In C++ use cv::Mat

cv::Mat A;

A.create(3,3,CV_8UC1);

or

using namespace cv;

Mat B(3,3,CV_8UC1);

Use cvMat if you are in C.

phoxis
  • 60,131
  • 14
  • 81
  • 117
Barshan Das
  • 3,677
  • 4
  • 32
  • 46
  • I tried this but I get this error:Cannot open precompiled header file: 'Debug\OpenCV_basics.pch': No such file or directory@Barshan Das – Aayman Khalid Mar 12 '13 at 09:30
  • @AaymanKhalid see this : http://stackoverflow.com/questions/1574121/precompiled-headers-with-dll-solutions-cannot-open-precompiled-header-file – Barshan Das Mar 12 '13 at 09:38