OpenCV - 测量“增长”一个物体的

发布于 2025-01-08 16:06:08 字数 776 浏览 0 评论 0原文

我想请求一些有关 OpenCV 的帮助(我目前是使用 OpenCV 的初学者)。

我打算测量两个帧之间物体的生长或运动。

例如:

                                          _  _
         =  =                          =        =
      =        =                     =            =
     =          =                   =              =
     =          =                   =              =
      =        =                     =            =
         =  =                          =        =
                                          ~  ~                

第一帧包含一个白色背景的黑色圆圈。

第二帧包含一个更大的白色背景的圆圈。

我想做的是获取圆的坐标(我不确定 OpenCV 中有哪些函数可以让我分割圆并检索它的坐标)。然后减去坐标,这样我就可以测量圆的增长。

我尝试浏览一些教程,但找不到任何有关分割对象(例如圆圈)然后将其坐标打印或写入文件的讨论。

是否可以使用 OpenCV 执行类似的操作,或者我是否需要其他软件解决方案?

谢谢大家。

I would like to ask for some assistance regarding OpenCV (I am currently a beginner in using OpenCV).

I intend to measure the growth or movement of an object between two frames.

For example:

                                          _  _
         =  =                          =        =
      =        =                     =            =
     =          =                   =              =
     =          =                   =              =
      =        =                     =            =
         =  =                          =        =
                                          ~  ~                

The first frame contains a black circle with a white background.

The second frame contains a bigger circle with a white background.

What I am thinking of doing is to get the coordinates of the circles (I am not sure what functions are available in OpenCV that allow me to segment the circle and retrieve it's coordinates). Then subtract the coordinates so that I can measure the growth of the circle.

I have tried looking through some tutorials but have not been able to find any discussing about segmenting objects (such as the circles) and then printing or writing their coordinates into a file.

Is it possible to do something like this with OpenCV, or do I require some other software solution?

Thank you all.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

温柔少女心 2025-01-15 16:06:08

在 OpenCV 中,您可以:

  1. 使用特征检测算法(如 Canny 算法)提取边缘
  2. 从该边缘图像中,您可以使用 CV 的蛇算法 cvSnakeImage(),该算法将图像作为输入并计算一组点
  3. 使用这组点作为函数 cv::minEnlookingCircle() 的输入,该函数将返回圆的直径
  4. 在下一个图像上重复并比较圆的大小

特征检测文档:http://opencv.willowgarage.com/documentation/feature_detection.html
结构/形状描述符文档: http://opencv.willowgarage.com/documentation/cpp/structural_analysis_and_shape_descriptors .html

也许你也可以使用光流(虽然我不熟悉它,所以我不确定)。

编辑(评论答案):

函数cvMinEnlookingCircle()返回“给定2D点集的最小面积的外接圆”(来自OpenCV文档)——这意味着2D 点集可以表示任何形状,而不仅仅是圆形。如果您知道正在比较同一对象的不同比例,则此测量是有意义的(因为对象的所有部分都会同时增大或缩小,从而“推动”或“收缩”外接圆)。

但其实还有更简单的方法:比较每张图像中黑色像素的数量,它们代表面积。

或者,您可能有兴趣使用另一个专用于分段的库,例如 ITK。

In OpenCV, you can:

  1. Extract the edges with a feature-detection algorithm (like the Canny algorithm)
  2. From this edges image, you can use the CV's snake algorithm cvSnakeImage() which takes an image as an input and computes a set of points
  3. Use this set of points as an input of the function cv::minEnclosingCircle(), which will return the diameter of your circle
  4. Repeat on the next image and compare size of cirlces

Feature detection doc: http://opencv.willowgarage.com/documentation/feature_detection.html
Structural/shape descriptor doc: http://opencv.willowgarage.com/documentation/cpp/structural_analysis_and_shape_descriptors.html

Maybe you can also use optical flows too (though I am not familiar with it, so I am not sure).

Edit (answer to comment):

Function cvMinEnclosingCircle() returns "the circumscribed circle of minimal area for a given 2D point set" (from the OpenCV doc) -- it means the 2D point set can represent any shape, not only circles. If you know you are comparing different scales of the same object, this measure makes sense (because all parts of your object will grow or shrink at the same time, thus "pushing" or "contracting" the circumscribed circle).

But there is actually a simpler method: compare the number of black pixels in each image, they represent the area.

Or, you might be interested in using another library dedicated to segmentation, for example ITK.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文