I'm creating a CvMat structure by calling
cvCreateMat(1,1,CV_32FC3);
This structure is filled by a subsequent OpenCV function call and fills it with three values (as far as I understand it, this is a 1x1 array with an additional depth of 3).
So how can I access these three values? A normal call to
CV_MAT_ELEM(myMat,float,0,0)
would not do the job since it expects only the arrays dimensions indices but not its depth. So how can I get these values?
Thanks!
The general way to access a cv::Mat is
type value=myMat.at<cv::VecNT>(j,i)[channel]
For your case:
Mat mymat(1,1,CV_32FC3,cvScalar(0.1,0.2,0.3));
float val=mymat.at<Vec3f>(0,0)[0];
All of the types are defined using the class cv::VecNT where T is the type and N is the number of vector elements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With