Skip to content

Commit

Permalink
Merge pull request #49 from sharmapradyumn/master
Browse files Browse the repository at this point in the history
Face Detection
  • Loading branch information
ankanbal authored and theabhishekavi committed Jul 8, 2019
1 parent 7b9f411 commit 7783070
Show file tree
Hide file tree
Showing 7 changed files with 45,959 additions and 0 deletions.
119 changes: 119 additions & 0 deletions P16_TheFaceReader/P16Pradyumn_Sharma/Black_White_picture.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import cv2 # importing computer library "
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"cap = cv2.VideoCapture(0) # connection with camera drivers"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"camera open sucessfull\n"
]
}
],
"source": [
"# status of camera\n",
"# check connection with camera drivers\n",
"\n",
"if cap.isOpened() :\n",
" print(\"camera open sucessfull\")\n",
"else :\n",
" print(\"check yor driver\")\n",
" \n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"# its open the camera and ready to take picture but not show\n",
"# now taking image from camera using read\n",
"status,frame = cap.read()\n",
"grayimg=cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY) # take gray image picture\n"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"-1"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cv2.imshow('live1',grayimg) # showing gray image\n",
"#if cv2.waitKey(10) & 0xff==ord('q') :\n",
" # break\n",
"cv2.waitKey(0)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"cv2.destroyAllWindows()\n",
"cap.release()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
108 changes: 108 additions & 0 deletions P16_TheFaceReader/P16Pradyumn_Sharma/Crop_Picture.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"import cv2 # importing computer library "
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"cap = cv2.VideoCapture(0) # connection with camera drivers"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"camera open sucessfull\n"
]
}
],
"source": [
"# status of camera\n",
"# check connection with camera drivers\n",
"\n",
"if cap.isOpened() :\n",
" print(\"camera open sucessfull\")\n",
"else :\n",
" print(\"check yor driver\")\n",
" \n"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"-1"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# its open the camera and ready to take picture but not show\n",
"# now taking image from camera using read\n",
"status,frame = cap.read()\n",
"img1=cv2.imshow('new',frame[100:500,100:400]) # take crop picture\n",
"cv2.waitKey(0)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"cv2.destroyAllWindows()\n",
"cap.release()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
78 changes: 78 additions & 0 deletions P16_TheFaceReader/P16Pradyumn_Sharma/FACE_DETECTION.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"ename": "error",
"evalue": "OpenCV(4.1.0) C:\\projects\\opencv-python\\opencv\\modules\\objdetect\\src\\cascadedetect.cpp:1658: error: (-215:Assertion failed) !empty() in function 'cv::CascadeClassifier::detectMultiScale'\n",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31merror\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-1-6a2569bde18f>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 9\u001b[0m \u001b[0mstatus\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mframe\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mcap\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mread\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 10\u001b[0m \u001b[1;31m# now we can apply classifier in live frame\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 11\u001b[1;33m \u001b[0mface\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mcasclf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdetectMultiScale\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mframe\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m1.5\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m5\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;31m# classifier tuning parameter\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 12\u001b[0m \u001b[1;31m#print(face)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 13\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mx\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0my\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mw\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mh\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mface\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;31merror\u001b[0m: OpenCV(4.1.0) C:\\projects\\opencv-python\\opencv\\modules\\objdetect\\src\\cascadedetect.cpp:1658: error: (-215:Assertion failed) !empty() in function 'cv::CascadeClassifier::detectMultiScale'\n"
]
}
],
"source": [
"import cv2\n",
"# calling classifier \n",
"casclf=cv2.CascadeClassifier('face.xml')\n",
"casclf1=cv2.CascadeClassifier('eye.xml')\n",
"# loading face data \n",
"cap=cv2.VideoCapture(0)\n",
"\n",
"while cap.isOpened() :\n",
" status,frame=cap.read()\n",
" # now we can apply classifier in live frame \n",
" face=casclf.detectMultiScale(frame,1.5,5) # classifier tuning parameter\n",
" #print(face)\n",
" for x,y,w,h in face:\n",
" cv2.rectangle(frame,(x,y),(x+h,y+w),(0,0,255),2) \n",
" # only face\n",
" facedata=frame[y:y+h,x:x+w] \n",
" #cv2.imshow('f',facedata)\n",
" eye=casclf1.detectMultiScale(facedata)\n",
" for ex,ey,ew,eh in eye: # for eye\n",
" cv2.rectangle(facedata,(ex,ey),(ex+eh,ey+ew),(0,0,255),2)\n",
" cv2.imshow('face',frame) \n",
" if cv2.waitKey(10) & 0xff == ord('q') :\n",
" break\n",
"\n",
"cv2.destroyAllWindows()\n",
"cap.release()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
8 changes: 8 additions & 0 deletions P16_TheFaceReader/P16Pradyumn_Sharma/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# The Face Reader
# This repositary contains all the codes of face detection
### Steps
1. first i collect all the libraries required
2. than fist i write for camera starting and tiaking picture
3. after that i am able to covert it into a black-white image
4. than i take crop image using slicing
5. now its ready to detect face with some data training
Loading

0 comments on commit 7783070

Please sign in to comment.