如何使用 EMGU CV 检测正方形/矩形或其他形状?
我想让应用程序使用 EMGU CV(OPENCV 包装器)检测网络摄像头中的正方形/矩形。正方形/长方形将具有纯色。
如果可能的话,我想获得正方形/矩形的宽度和高度。
在这段视频中,您可以看到我想要做什么。
http://www.youtube.com/watch?v=ytvO2dijZ7A&NR= 1
我正在使用 C#
I want to make an apps detect an square/rectangle in my webcam using EMGU CV (an OPENCV wrapper). The square/rectangle will have a solid color.
if it's posible I would like to obtain the width and heigth of the square/rectangle
In this video you can see what I would like to do.
http://www.youtube.com/watch?v=ytvO2dijZ7A&NR=1
I'm working with C#
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您已经知道所需对象的颜色,那么您可以根据该颜色分割图像。 (这可能就是为什么当那个家伙拍摄朝向和远离相机的方向时矩形消失的原因[照明差异]。一旦将对象从图像中分割出来,您就可以对图像进行区域计算。[在matlab中认为regionprops ]
一旦获得了斑点,您就可以尝试进行模型拟合以获得所表示的对象的良好近似值。
If you already know the color of the desired object then you can segment the image based on that color. (Which may be why the rectangle disapears when the guy movies the direction to and away from the camera [differences in lighting]. Once you have the object segmented out of the image you can do region calculations on the image. [In matlab think regionprops]
Once you have the blob you can attempt to do model fitting to get a good approximation of the object being represented.
在提供的视频链接中,可能正在做的是冲浪特征检测。看一下 EMGU 附带的 SURFFeture 示例。在这种情况下,不是绘制线条,而是检测四个角点并在顶部绘制形状。 EMGU.CV.Examples 文件夹中的 ShapeDetection 和 TrafficSignRecognition 等类似示例将为您提供帮助。 ShapeDetection 将教您如何对正方形进行分类,StopSignDetector.cs 类将向您展示如何应用冲浪特征检测算法的另一个示例。
这将需要一些重新配置,但如果您遇到困难,请随时提出另一个问题。
干杯
克里斯
In the video link provided what is probably being done is Surf feature detection. Take a look at the SURFFeture example that ships with EMGU. Rather than drawing lines in this case however the four corner points are detected and a shape drawn on top. Similar examples which will help you are ShapeDetection and TrafficSignRecognition both in the EMGU.CV.Examples folder. ShapeDetection will teach you how to classify the square and the StopSignDetector.cs class will show you another example of how to apply a surf feature detection algorithm.
It will require a little reconfiguration but if you get stuck feel free to ask another question.
Cheers
Chris