I am a bit confused by the documentation of connectedComponentsWithStats
in regards to the stats
parameter. According to the docs it is of type OutputArray
, so I pass cv::Mat
to it, but then I cannot access the individual values as stated in the docs as stats(label, COLUMN)
since cv::Mat
does not have an operator ()
that accepts two ints, so what I do instead is stats.at<int32_t>(label, COLUMN)
, but I am still wondering what type stats
should be in order to be able to just do stats(label, COLUMN)
You can take a look at the test code for an example of how to use the resulting stats structure
if you don’t want to consult docs or examples, you can simply ask the mat what type it holds. for such APIs, the type will always be the same. then you can write your code assuming that type.
Thanks for the suggestion, I should have worded my question a bit more specific. It was more on the line of “Can stats be something other than cv::Mat” rather than “What is the type of matrix elements when stats is a cv::mat object” (which is covered in the docs as CV_32S). But I guess the suggested stats(label, COLUMN)
acces to stats is to be understood as pseudocode and is worded like that in case matrix element access changes in some future release?