Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object detector codes added-hacktober #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
102 changes: 102 additions & 0 deletions Advance/ObjectDetector/00_Introduction-Main-Goals-of-the-Project.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Tasks"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"- Face Detection\n",
"- Eyes Detection\n",
"- Face & Eyes Detection\n",
"- Pedestrians Detection\n",
"- Cars Detection\n",
"- Car Plate Detection"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can Run the cell by:\n",
"- clicking on the Run button\n",
"- Shift + Enter (<b>Windows</b>).\n",
"- Control + Enter (<b>Mac</b>)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"When we have finished with our Jupyter Notebook we go to:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<b>File</b> -> <b>Save and Checkpoint</b> and then"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<b>File</b> -> <b>Close and Halt</b>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### How to Tune Cascade Classifier"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"(https://docs.opencv.org/2.4/modules/objdetect/doc/cascade_classification.html#cascadeclassifier-detectmultiscale)\n",
"\n",
"<b>detectMultiscale</b>(input image, <b>Scale Factor</b>, <b>Min Neighbors</b>)\n",
"- <b>Scale Factor</b> Parameter specifying how much yhe image size is reduced at each image scale.\n",
"\n",
"\n",
"- <b>Min Neighbors</b> Parameter specifying how many neighbors each candidate rectangle should have to retain it."
]
},
{
"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.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
201 changes: 201 additions & 0 deletions Advance/ObjectDetector/01_Face_Detection.ipynb

Large diffs are not rendered by default.

241 changes: 241 additions & 0 deletions Advance/ObjectDetector/02_Eyes_Detection.ipynb

Large diffs are not rendered by default.

200 changes: 200 additions & 0 deletions Advance/ObjectDetector/03_Face_and_Eyes_Detection.ipynb

Large diffs are not rendered by default.

132 changes: 132 additions & 0 deletions Advance/ObjectDetector/04_Pedestrians_Detection.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Import Libraries"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import cv2\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create Classifier"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"body_classifier = cv2.CascadeClassifier('Haarcascades/haarcascade_fullbody.xml')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Capture Video"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"cap = cv2.VideoCapture('Video/People_Walking.mp4')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### It's a Kind of Magic"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"# While Loop\n",
"while cap.isOpened():\n",
"\n",
"\n",
" # Read the capture\n",
" ret, frame = cap.read()\n",
" \n",
" # Pass the Frame to the Classifier\n",
" bodies = body_classifier.detectMultiScale(frame, 1.3 ,5)\n",
" \n",
" # if Statement\n",
" if ret == True:\n",
" \n",
" # Bound Boxes to Identified Bodies\n",
" for (x, y, w, h) in bodies:\n",
" cv2.rectangle(frame,\n",
" (x,y),\n",
" (x+w,y+h),\n",
" (255, 125,0),\n",
" 5)\n",
" cv2.imshow('Pedestraints', frame)\n",
" \n",
" # Exit with Esc button\n",
" if cv2.waitKey(1)==27:\n",
" break\n",
" \n",
" # else Statement\n",
" else:\n",
" break\n",
" \n",
"# Release the Capture & Destroy All Windows\n",
"\n",
"cap.release()\n",
"cv2.destroyAllWindows()\n",
"\n"
]
},
{
"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.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
128 changes: 128 additions & 0 deletions Advance/ObjectDetector/05_Car_Detection.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Import Libraries"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import cv2"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create Classifier"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"car_detector = cv2.CascadeClassifier('Haarcascades/haarcascade_car.xml')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Capture Video"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"cap = cv2.VideoCapture('Video/Vehicles.mp4')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### It's a Kind of Magic"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"# while Loop\n",
"while cap.isOpened():\n",
"\n",
"\n",
" # Read the capture\n",
" ret, frame = cap.read()\n",
" \n",
" # Pass the Frame to the Classifier\n",
" cars = car_detector.detectMultiScale(frame, 1.3 , 5)\n",
" \n",
" # for Loop\n",
" for (x,y,w,h) in cars:\n",
" \n",
" # Bound Boxes to Identified Bodies\n",
" cv2.rectangle(frame,\n",
" (x,y),\n",
" (x+w,y+h),\n",
" (0,255,255),\n",
" 2)\n",
" cv2.imshow('Cars', frame)\n",
" \n",
" \n",
" # Exit with Esc button\n",
" if cv2.waitKey(1) & 0xFF == 27:\n",
" break\n",
" \n",
" \n",
"# Release the Capture & Destroy All Windows\n",
"cap.release()\n",
"cv2.destroyAllWindows()\n",
"\n",
"\n"
]
},
{
"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.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading