mirror of
https://github.com/hastagAB/Awesome-Python-Scripts.git
synced 2024-11-27 14:01:09 +00:00
e428f6a3fd
* Added face recognition script * Updated README Co-authored-by: Ayush Bhardwaj <classicayush@gmail.com>
57 lines
1.3 KiB
Plaintext
57 lines
1.3 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import cv2\n",
|
|
"\n",
|
|
"face_cascade = cv2.CascadeClassifier(\"haarcascade_frontalface_default.xml\")\n",
|
|
"\n",
|
|
"img = cv2.imread(\"morgan.jpg\",1)\n",
|
|
"\n",
|
|
"gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)\n",
|
|
"\n",
|
|
"faces = face_cascade.detectMultiScale(gray_img, scaleFactor=1.05, minNeighbors=5)\n",
|
|
"\n",
|
|
"print(type(faces))\n",
|
|
"print(faces)\n",
|
|
"\n",
|
|
"for x,y,w,h in faces:\n",
|
|
" img = cv2.rectangle(img, (x,y), (x+w,y+h), (0,255,0),3)\n",
|
|
" \n",
|
|
"resize_img = cv2.resize(img, (int(img.shape[1]/2), int(img.shape[0]/2)))\n",
|
|
"\n",
|
|
"cv2.imshow(\"Gray\",resize_img)\n",
|
|
"\n",
|
|
"cv2.waitKey(0)\n",
|
|
"\n",
|
|
"cv2.destroyAllWindow(Gray)"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.7.3"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|