Skip to content

Commit c47f012

Browse files
committed
Open-CV-Implementations
1 parent bb45a76 commit c47f012

File tree

6 files changed

+36894
-0
lines changed

6 files changed

+36894
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ This is a repository of code files which can be used to perform some basic tasks
1818

1919
Python Code to perform Geometric Transformations like Image Translation, Rotation, Resizing, Flipping and Cropping of an image using OpenCV.
2020

21+
* [Image Arithmetic](https://github.com/altruistcoder/Open-CV-Implementations/blob/master/image_arithmetic.ipynb):
22+
23+
Python Code to perform arithmetic operations such as addition & subtraction on an image using OpenCV.
24+
2125
* [Bitwise Operations on Images](https://github.com/altruistcoder/Open-CV-Implementations/blob/master/bitwise_operations.ipynb):
2226

2327
Python Code to perform Bitwise operations like AND, OR, XOR and Not operations on an image using OpenCV.
@@ -49,3 +53,11 @@ This is a repository of code files which can be used to perform some basic tasks
4953
* [Contours](https://github.com/altruistcoder/Open-CV-Implementations/blob/master/contours.ipynb):
5054

5155
Python Code to find & draw Contours present in an image using OpenCV.
56+
57+
* [Adding Text to Videos](https://github.com/altruistcoder/Open-CV-Implementations/blob/master/text_on_video.ipynb):
58+
59+
Python Code to draw text on a video using OpenCV.
60+
61+
* [Face and Eye Detection](https://github.com/altruistcoder/Open-CV-Implementations/blob/master/face_and_eye_detection.ipynb):
62+
63+
Python Code to detect faces and eyes present in a video using OpenCV.

face_and_eye_detection.ipynb

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Face and Eye Detection"
8+
]
9+
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": 1,
13+
"metadata": {},
14+
"outputs": [],
15+
"source": [
16+
"import cv2 as cv"
17+
]
18+
},
19+
{
20+
"cell_type": "code",
21+
"execution_count": 2,
22+
"metadata": {},
23+
"outputs": [
24+
{
25+
"name": "stdout",
26+
"output_type": "stream",
27+
"text": [
28+
"<VideoCapture 0x7f7926fd18b0>\n"
29+
]
30+
}
31+
],
32+
"source": [
33+
"cap = cv.VideoCapture(0)\n",
34+
"face_cascade = cv.CascadeClassifier('haarcascade_files/haarcascade_frontalface_alt.xml')\n",
35+
"eye_cascade = cv.CascadeClassifier('haarcascade_files/haarcascade_eye.xml')\n",
36+
"print(cap)\n",
37+
"while True:\n",
38+
" ret, frame = cap.read()\n",
39+
" gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)\n",
40+
" faces = face_cascade.detectMultiScale(gray, 1.3, 3)\n",
41+
" \n",
42+
" for (x,y,w,h) in faces:\n",
43+
" frame = cv.rectangle(frame, (x,y), (x+w, y+h), (255, 0, 0), 2)\n",
44+
" roi_gray = gray[y:y+h, x:x+w]\n",
45+
" roi_color = frame[y:y+h, x:x+w]\n",
46+
" eye = eye_cascade.detectMultiScale(roi_gray)\n",
47+
" \n",
48+
" for (ex,ey,ew,eh) in eye:\n",
49+
" cv.rectangle(roi_color, (ex,ey), (ex+ew, ey+eh), (0, 255, 0), 2)\n",
50+
" \n",
51+
" cv.imshow(\"Face_Detection\", frame)\n",
52+
" if cv.waitKey(1) & 0xFF == 27: # ASCII Code for Esc Key\n",
53+
" break\n",
54+
"cap.release()\n",
55+
"cv.destroyAllWindows()"
56+
]
57+
},
58+
{
59+
"cell_type": "code",
60+
"execution_count": null,
61+
"metadata": {},
62+
"outputs": [],
63+
"source": []
64+
},
65+
{
66+
"cell_type": "code",
67+
"execution_count": null,
68+
"metadata": {},
69+
"outputs": [],
70+
"source": []
71+
}
72+
],
73+
"metadata": {
74+
"kernelspec": {
75+
"display_name": "Python 3",
76+
"language": "python",
77+
"name": "python3"
78+
},
79+
"language_info": {
80+
"codemirror_mode": {
81+
"name": "ipython",
82+
"version": 3
83+
},
84+
"file_extension": ".py",
85+
"mimetype": "text/x-python",
86+
"name": "python",
87+
"nbconvert_exporter": "python",
88+
"pygments_lexer": "ipython3",
89+
"version": "3.5.2"
90+
}
91+
},
92+
"nbformat": 4,
93+
"nbformat_minor": 2
94+
}

0 commit comments

Comments
 (0)