OpenCV - 测量“增长”一个物体的
我想请求一些有关 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 OpenCV 中,您可以:
cvSnakeImage()
,该算法将图像作为输入并计算一组点cv::minEnlookingCircle()
的输入,该函数将返回圆的直径特征检测文档: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:
cvSnakeImage()
which takes an image as an input and computes a set of pointscv::minEnclosingCircle()
, which will return the diameter of your circleFeature 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.