# SimpleBlobDetector and KeyPoint.size

**URL:** <https://forum.opencv.org/t/simpleblobdetector-and-keypoint-size/5865>\
**Category:** C++\
**Created:** [October 26, 2021, 8:01pm UTC](https://forum.opencv.org/t/simpleblobdetector-and-keypoint-size/5865 "2021-10-26T20:01:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ehardin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/ehardin/32/2541_2.png) [@ehardin](https://forum.opencv.org/u/ehardin)\
**Post date:** [October 26, 2021, 8:01pm UTC](https://forum.opencv.org/t/simpleblobdetector-and-keypoint-size/5865/1 "2021-10-26T20:01:43Z")

</div>

OCV 4.5; C++, Visual Studio 2017; MFC; Windows 10

The KeyPoint.size is given as  
'diameter of the meaningful keypoint neighborhood ’

I want to make sure that I am using this ‘diameter’ correctly in order to calculate area to compare to minArea and maxArea. Can I assume that this ‘diameter’ is given in pixels?

With the code lines:

```auto
Ptr<SimpleBlobDetector> detector = SimpleBlobDetector::create(params);
detector->detect(matThresholded, keypoints);

```

say I get a keypoints.at(1).size of 2, that would be a diameter of 2 pixels. Correct?

Since I am looking for more or less circular blobs then, using the standard formula for the area of a circle I would divide by 2 to get the radius and then get Pi X r2 ie

```auto
float fRadius = keypoints.at(i).size / 2; // In this example it is a radius of 1
float fArea = 3.14 * (fRadius*fRadius); // In this example this would be an area of 3.14

```

My questions is: Is this a near correlation to what SimpleBlobDetector is using when it calculates area to compare with minArea and maxArea?

In the source file OpenCV\_453\opencv\sources\modules\features2d\src\blobdector.cpp it arrives at the area via

```auto
 Moments moms = moments(contours[contourIdx]);
double area = moms.m00;

```

So if m00 is a spatial moment, given a true circle, wouldn’t this be the same (more or less) as my area of a circle calculation above?

Is there a way, from the return in the KeyPoint object, for me to calculate a similar m00 Moment?
