Ask Your Question
0

How to know the output array type of meanStdDev without looking at the source code

asked 2017-06-20 23:10:43 -0600

jacobdang gravatar image

Hi All:

The API documentation of meanStdDev (C++: void meanStdDev(InputArray src, OutputArray mean, OutputArray stddev, InputArray mask=noArray())) does not clearly indicate the OutputArray type, i.e., whether the output array is a CV_32S or CV_32F or CV_64F. Only by checking the source code (https://github.com/opencv/opencv/blob...) I find out the rules for determining the output type:

int type = _src.type(), depth = CV_MAT_DEPTH(type); ddepth = std::max(CV_32S, depth), sqddepth = std::max(CV_32F, depth), dtype = CV_MAKE_TYPE(ddepth, cn), sqdtype = CV_MAKETYPE(sqddepth, cn); // dtype and sqdtype refers to the output array type of mean and stddev

Without such important type info, I do not know how to properly access the output array (i.e. mean.at<t>(0)). I am wondering is there a easier way to look up such important info? In addition, what are the general rules regarding the input/output parameters types for OpenCV functions?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-06-21 00:42:07 -0600

berak gravatar image

if you squint hard at the docs , you'll see:

so that the results can be stored in Scalar_ 's.

// so, use a cv::Scalar for mean & stddev, and there'll be no guessing required.

Mat  image = ...
Scalar mean,dev;
meanStdDev(image, mean,dev);

double mean_of_channel_2 = mean[2];
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-06-20 23:09:48 -0600

Seen: 6,202 times

Last updated: Jun 21 '17