Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Capture.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 74 additions & 0 deletions Face_Detect.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import numpy as np\n",
"import cv2\n",
"\n",
"\n",
"cap = cv2.VideoCapture('Jason.mp4')\n",
"\n",
"face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_alt.xml')\n",
"kernel = np.ones((21,21),'uint8')\n",
"\n",
"while(True):\n",
"\n",
" ret, frame = cap.read()\n",
" faces = face_cascade.detectMultiScale(frame, scaleFactor=1.2, minSize=(20,20))\n",
" for (x,y,w,h) in faces:\n",
" frame[y:y+h, x:x+w,:] = cv2.dilate(frame[y:y+h,x:x+w,:], kernel)\n",
"\n",
" for (x,y,w,h) in faces:\n",
" cv2.circle(frame, (x + int(w/2),y + int(h/2)), int(w/2), (0,255,255), thickness=-1)\n",
" cv2.circle(frame, (x + int(w/4),y + int(h/4)), 10, (0,0,0), thickness=-1)\n",
"\n",
" cv2.circle(frame, (x + w - int(w/4),y + int(h/4)), 10, (0,0,0), thickness=-1)\n",
" cv2.ellipse(frame, (x + int(w/2), y + h - int(h/4)), (int(w/4), int(h/5)), 180, 180, 360, (0,0,0))\n",
"\n",
" cv2.imshow('frame',frame)\n",
" if cv2.waitKey(1) & 0xFF == ord('q'):\n",
" break\n",
"\n",
"\n",
"cap.release()\n",
"cv2.destroyAllWindows()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
Binary file added Jason.mp4
Binary file not shown.