I am doing object recognition in opencv and python. I have done the training using 51 positive samples and 100 negative samples, and the stages of training is 7. using the command
opencv_traincascade -data samples -vec phones.vec -bg bg.txt -numPos 51 -numNeg 100 -w 40 -h 70 -featureType LBP
So the training is completed and cascade.xml is created. Now I am trying to do object recognition, Problem I am facing is, It took a long time around 12 - 13 minutes for the detection. How can I fix it.
import cv2
import sys
cascpath = ('/home/aquib/opencv/opencv-3.0.0/data/haarcascades/cascade.xml')
Cascade = cv2.CascadeClassifier(cascpath)
img = cv2.imread('c2.jpg') #saved in desktop
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) #converting it_to grey
object_detect = Cascade.detectMultiScale(
gray,
scaleFactor=1.3,
minNeighbors=5,
minSize=(15,15),
flags=cv2.CASCADE_SCALE_IMAGE
)
for (x,y,w,h) in object_detect:
img = cv2.rectangle(img,(x,y),((x+w),(y+h)),(255,0,0),2)
roi_gray = gray[y:y+h, x:x+w]
roi_color = img[y:y+h, x:x+w]
cv2.namedWindow("Object_detect", cv2.WINDOW_NORMAL)
cv2.imshow("object",img)
cv2.waitKey(0)
cv2.destroyAllWindows()