I know the way we use the function in c++ is as follows
function declaration // before main
function calling // in main
function definition // outside main
But as I used opencv in project , I also made function in it , but I didn't use function declaration in it and it works fine without any error , I use the same tool , same language same technique . Why is function declaration is not compulsory in opencv ? or is it done with other way ?
Sample code :
void generateGradient(cv::Mat& mask)
{
cv::Point firstPt = cv::Point(mask.size().width/2, mask.size().height/2);
double radius = 1.0;
double power = 0.8;
double maxImageRad = radius * getMaxDisFromCorners(mask.size(), firstPt);
mask.setTo(cv::Scalar(1));
for (int i = 0; i < mask.rows; i++)
{
for (int j = 0; j < mask.cols; j++)
{
double temp = dist(firstPt, cv::Point(j, i)) / maxImageRad;
temp = temp * power;
double temp_s = pow(cos(temp), 4);
mask.at<double>(i, j) = temp_s;
}
}
}
int main()
{
cv::Mat img = cv::imread("stack-exchange-chefs.jpg");
cv::Mat maskImg(img.size(), CV_64F);
generateGradient(maskImg);
}
Thank you