user2904561
user2904561

Reputation:

OpenCV SVM tutorial? Where is the function defintion for Mat_<float>(1,2)

At the Support Vector Machines tutorial at OpenCV's website here

http://docs.opencv.org/doc/tutorials/ml/introduction_to_svm/introduction_to_svm.html#introductiontosvms

Under the Source code heading on line 35 is this

Mat sampleMat = (Mat_<float>(1,2) << j,i);

I'm new to the Mat_ class so I was wondering if someone can tell me where this part 'Mat_(1,2)' is defined in the source code. I looked all over the

'template<typename _Tp> class Mat_ : public Mat'  in 

/home/w/Documents/opencv-master/modules/core/include/opencv2/core/mat.hpp

and I found no method that looks like 'Mat_(1,2)' is a part of. I'm writing a C wrapper for it is why I need the definition and I assume its creating a matrix, a Mat object to be exact and it is a float with 1 row and 2 columns...If I'm mistaken pls correct me. If someone could direct me to what method in that class('Mat_') this function belongs to I would be most appreciative=)

Thank you

Upvotes: 2

Views: 549

Answers (1)

ccj5351
ccj5351

Reputation: 434

please see this website for details: http://docs.opencv.org/modules/core/doc/basic_structures.html?highlight=mat#Mat

Part of this explanation is:

Use a comma-separated initializer:

// create a 2x4 double-precision identity matrix Mat M = (Mat_(2,4) << 1, 0, 0, 0, 1, 0, 0, 0);

With this approach, you first call a constructor of the Mat_ class with the proper parameters, and then you just put << operator followed by comma-separated values that can be constants, variables, expressions, and so on.

The following is the result:

M = [1, 0, 0, 0, 1, 0, 0, 0]

Upvotes: 1

Related Questions