Reputation: 378
I made an Opencv app to detect faces with my phone camera as a video source, that works perfectly on receiving data and showing the video but the problem is in detection on the image, sample detected image
I did use face cascade but still, I am getting poor results this is my code
import cv2
import numpy
url = 'http://192.168.xxx.xx:8080/video'
cap = cv2.VideoCapture(url)
face = cv2.CascadeClassifier('cascade.xml')
while(True):
ret, frame = cap.read()
if frame is not None:
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
faces = face.detectMultiScale(gray, 1.1, 4)
for (x, y, w, h) in faces :
cv2.rectangle(frame,(x,y),(x+w, x+h),(255,0,0),2)
cv2.imshow('frame',frame)
q = cv2.waitKey(1)
if q == ord("q"):
break
cv2.destroyAllWindows()
my question is ..
is there any way to make the detection more accurate ??
Thanks in advance
Upvotes: 0
Views: 302
Reputation: 340
objects = cv.CascadeClassifier.detectMultiScale( image[, scaleFactor[, minNeighbors[, flags[, minSize[, maxSize]]]]]
Parameters
image Matrix of the type CV_8U containing an image where objects are detected.
objects Vector of rectangles where each rectangle contains the detected object, the rectangles may be partially outside the original image.
scaleFactor Parameter specifying how much the image size is reduced at each image scale.
minNeighbors Parameter specifying how many neighbors each candidate rectangle should have to retain it.
flags Parameter with the same meaning for an old cascade as in the function cvHaarDetectObjects. It is not used for a new cascade.
minSize Minimum possible object size. Objects smaller than that are ignored.
maxSize Maximum possible object size. Objects larger than that are ignored. If maxSize == minSize model is evaluated on single scale.
You can play around with scaleFactor and minNeighbors.
Upvotes: 1