Reputation: 1
I've used a sequential model including several convolutional layers to recognize thumb finger from index finger in images.
The trained model works pretty well to recognize if the picture has the thumb or index finger inside. Now, I want to add script to draw a box around the recognized finger in the new image which I want to apply the model on it.
I need the box to extract the finger from the image after recognition step. could someone help me please?
Upvotes: 0
Views: 1713
Reputation: 768
Using cv2 rectangle function,
(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
Reference to sample example:
Geeks for geeks sample on how to use
Upvotes: 1