I'm new in OpenCV
. I'm trying to save the detected object into a new image.
What should I do?
This is the code I copied from a tutorial:
import cv2
import numpy as np
tric_cascade = cv2.CascadeClassifier('cascade.xml')
img = cv2.imread('anthon18c.png')
gray= cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
tric = tric_cascade.detectMultiScale(gray,1.01,7)
for (x,y,w,h) in tric:
img = cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
cv2.imshow('img', img)
cv2.waitKey(0)
cv2.destroyAllWindows()