I want to convert the c code to c++
my code in c is
// Calculate the moments to estimate the position of the ball
CvMoments *moments = (CvMoments*)mallocsizeof(CvMoments));
cvMoments(imgYellowThresh, moments, 1);
// The actual moment values
double moment10 = cvGetSpatialMoment(moments, 1, 0);
double moment01 = cvGetSpatialMoment(moments, 0, 1);
double area = cvGetCentralMoment(moments, 0, 0);
in c++
cv::Moments ourMoment;//moments variable
ourMoment=moments(imgYellowThresh); //calculat all the moment of image
double moment10=moments.m10; //extract spatial moment 10
double moment01=moments.m01; //extract spatial moment 01
double area=moments.m00; //extract central moment 00
But I am getting error at ourMoment=moments(imgYellowThresh); as identifier moments is undefined.
Please help me in this