Commit c6ef2997 authored by Michael Murtaugh's avatar Michael Murtaugh

bug fixes

parent cabbffe9
This diff is collapsed.
......@@ -82,6 +82,7 @@ def pad (img, w, h, color=(0, 0, 0)):
return cv2.copyMakeBorder(img, top, bottom, left, right, cv2.BORDER_CONSTANT, value=color)
out = None
count = 0
for i in args.input:
frame = cv2.imread(i)
......@@ -93,6 +94,7 @@ for i in args.input:
features = detectMultiScale(cascade, gray, scaleFactor=args.scaleFactor, minNeighbors=args.minNeighbors, minSize=args.minSize)
for (x,y,w,h) in features:
# print ((x, y, w, h))
count += 1
cv2.rectangle(frame, (x,y), (x+w,y+h), color, args.drawWidth)
roi_gray = gray[y:y+h, x:x+w]
roi_color = frame[y:y+h, x:x+w]
......@@ -126,7 +128,7 @@ if out:
else:
cv2.destroyAllWindows()
print ("Displayed {0} faces".format(count), file=sys.stderr)
......
......@@ -40,8 +40,6 @@ def pad (img, w, h, color=(0, 0, 0)):
right = (w - iw - left)
return cv2.copyMakeBorder(img, top, bottom, left, right, cv2.BORDER_CONSTANT, value=color)
with open (args.settings) as f:
settings = json.load(f)
......@@ -67,24 +65,31 @@ def process_features (grayimg, features):
for x in features:
roi = grayimg
ox, oy = 0, 0
for f in ensure_list(x):
#indent = ""
#if ox > 0:
# indent = " "
#print ("{0}process_feature {1}".format(indent, f['name']), file=sys.stderr)
if f['name'] not in ret:
rects = ret[f['name']] = []
if type(x) == list:
f1, f2 = x
else:
f1 = x
f2 = None
if f1['name'] not in ret:
rects = ret[f1['name']] = []
else:
rects = ret[f1['name']]
if f2:
if f2['name'] not in ret:
rects2 = ret[f2['name']] = []
else:
rects = ret[f['name']]
fcount = 0
for (x,y,w,h) in f['_cascade'].detectMultiScale(roi, **f['args']):
rects.append([int(ox+x), int(oy+y), int(w), int(h)])
fcount += 1
# narrow for (evt) next cascaded feature...
ox, oy = x, y
rects2 = ret[f2['name']]
for (x,y,w,h) in f1['_cascade'].detectMultiScale(roi, **f1['args']):
rects.append([int(x), int(y), int(w), int(h)])
# narrow for (evt) next cascaded feature...
if f2:
roi = roi[y:y+h, x:x+w]
if fcount == 0:
break # don't cascade to the next feature (ie no eyes if no faces)...
for (x2,y2,w2,h2) in f2['_cascade'].detectMultiScale(roi, **f2['args']):
rects2.append([int(x+x2), int(y+y2), int(w2), int(h2)])
return ret
output = []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment