python - 如何使用 Python Opencv 检测特定区域内的移动?

标签 python python-3.x opencv opencv3.0

目前我有一个使用 Python 和 OpenCV 的算法来检测几何形状并计算其长度(不准确)。

但我需要在特定区域内进行检测,在这种情况下,它将在我使用 cv2.rect 函数绘制的矩形内进行检测,但我不知道该怎么做并且我在 Internet 上找不到有关如何执行此操作的任何信息。

我正在使用 python 3.7OpenCV 3

有人可以帮助我吗?

description of what I want to achieve

最佳答案

由于您使用的是 Python,因此您可以简单地在矩形上对图像进行切片。

x, y, w, h = cv2.selectROI(window_name, image)  # or something
img_cropped = img[y:y+h, x:x+h] 

您还可以查看 this tutorial

关于python - 如何使用 Python Opencv 检测特定区域内的移动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55383815/

相关文章:

opencv - Adaboost 中的参数选择

python - 在wxpython中保存组合框的选定值

python - 使用带括号的字符串需要帮助

python - 等效于 Python 的 OpenCV 中的 FileNotFoundError

c++ - 编译 Aruco 库?

python - OpenCV3 中的 cv2.cv 替换是什么?

python - 更新线程内的pyqtgraph BarGraphItem

python - Django 在管理页面中显示一对多关系

python - BeautifulSoup 如何选择带有空格的 <a href> 和 <td> 元素

python-3.x - 在 Debian 上的 virtualenv 中 Pip 安装 scikit-learn 失败 - Raspberry PI - 无法构建 scikit-learn