如何使用python在检测到的对象周围绘制一个框?

如何使用python在检测到的对象周围绘制一个框?,python,image-processing,object-detection,bounding-box,cnn,Python,Image Processing,Object Detection,Bounding Box,Cnn,我使用了一个包含几个卷积层的序列模型来识别图像中的拇指和食指。 经过训练的模型可以很好地识别图片中是否有拇指或食指。现在,我想添加脚本,在新图像中识别的手指周围画一个框,我想在其上应用模型。 我需要在识别步骤后从图像中提取手指的框。有人能帮我吗?使用cv2矩形函数 (locations, preditions) = detect_and_predict_class(test_image, model) # make predictions from your model for (box, p

我使用了一个包含几个卷积层的序列模型来识别图像中的拇指和食指。
经过训练的模型可以很好地识别图片中是否有拇指或食指。现在,我想添加脚本,在新图像中识别的手指周围画一个框,我想在其上应用模型。

我需要在识别步骤后从图像中提取手指的框。有人能帮我吗?

使用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
参考示例:


您可以在CV2中使用矩形函数您训练过的模型的输出是什么?