检测自定义形状 OpenCV

Detect custom shape OpenCV

我想在 OpenCV 中找到自定义形状。 形状是预先定义的。我想使用网络摄像头实时检测这个形状是否等于或不等于当前形状。

我该怎么做?如何比较预定义的自定义形状和当前形状?

正如评论者所回避的那样,您可以使用模板匹配来检测自定义形状。

那么什么是模板匹配?

Template matching 是数字图像处理中的一种技术,用于查找图像中与模板图像匹配的小部分。它可以在制造中用作质量控制的一部分、移动机器人的导航方式或检测图像边缘的方式。

模板匹配 OpenCV/Python

Template Matching is a method for searching and finding the location of a template image in a larger image. OpenCV comes with a function cv2.matchTemplate() for this purpose. It simply slides the template image over the input image (as in 2D convolution) and compares the template and patch of input image under the template image.

我从 here 中获取了这篇文章,这是一篇关于如何在 OpenCV 中执行模板匹配的教程。您可以搜索您定义的任何 "custom shape"。它包括 python.

的代码示例