python - 如何使用python在检测到的对象周围绘制一个框?
问题描述
我使用了一个包含几个卷积层的顺序模型来识别图像中的拇指和食指。
经过训练的模型可以很好地识别图片中是否有拇指或食指。现在,我想添加脚本以在我想在其上应用模型的新图像中识别的手指周围绘制一个框。
在识别步骤之后,我需要该框从图像中提取手指。有人可以帮我吗?
解决方案
使用 cv2 矩形函数,
(locations, preditions) = detect_and_predict_class(test_image, model) # make predictions from your model
for (box, pred) in zip(locationss, predictions):
(startX, startY, endX, endY) = box # box coordinates returned from your model's predictions
cv2.rectangle(input_image, (startX, startY), (endX, endY), color, 2) # color is the color of the bounding box you would like & 2 is the thickness of the bounding box
参考示例示例:
推荐阅读
- ios - 是 GeoFilter 中的地址
- android - iBeacon 几乎在每台 Android 设备上都有不同的距离读数
- go - 等到 IO Buffer 用 GoLang 完全写入
- css - 字体问题 - 不考虑粗细和行高问题
- android - 检查是否在自定义应用程序类中重新创建了 Android 应用程序
- kotlin - 与将 observable 作为 lambda 表达式传递的 onExceptionResumeNext 混淆
- android - 使用 androidplot 制作实时多线图
- c# - 在数组c#中查找最远和最接近的数字
- c++ - 带有子库和包含目录的库,我如何在 CMake 中做到这一点?
- r - 在 R 函数中运行多个代码行