mdmoin19 commited on
Commit
fe12a4b
1 Parent(s): 24ff96e
Files changed (1) hide show
  1. CNN Face Recognition.ipynb +102 -0
CNN Face Recognition.ipynb ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "id": "130f679a",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "import cv2"
11
+ ]
12
+ },
13
+ {
14
+ "cell_type": "code",
15
+ "execution_count": 5,
16
+ "id": "447799d7",
17
+ "metadata": {},
18
+ "outputs": [
19
+ {
20
+ "name": "stderr",
21
+ "output_type": "stream",
22
+ "text": [
23
+ "[ERROR:0@95.846] global persistence.cpp:531 open Can't open file: 'Downloads/haarcascade_fullbody.xml' in read mode\n"
24
+ ]
25
+ }
26
+ ],
27
+ "source": [
28
+ "model=cv2.CascadeClassifier(\"Downloads/haarcascade_fullbody.xml\")"
29
+ ]
30
+ },
31
+ {
32
+ "cell_type": "code",
33
+ "execution_count": 6,
34
+ "id": "fff2b133",
35
+ "metadata": {},
36
+ "outputs": [
37
+ {
38
+ "ename": "error",
39
+ "evalue": "OpenCV(4.10.0) /Users/xperience/GHA-Actions-OpenCV/_work/opencv-python/opencv-python/opencv/modules/objdetect/src/cascadedetect.cpp:1689: error: (-215:Assertion failed) !empty() in function 'detectMultiScale'\n",
40
+ "output_type": "error",
41
+ "traceback": [
42
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
43
+ "\u001b[0;31merror\u001b[0m Traceback (most recent call last)",
44
+ "Cell \u001b[0;32mIn[6], line 6\u001b[0m\n\u001b[1;32m 4\u001b[0m res, frame \u001b[38;5;241m=\u001b[39m cap\u001b[38;5;241m.\u001b[39mread()\n\u001b[1;32m 5\u001b[0m gray \u001b[38;5;241m=\u001b[39m cv2\u001b[38;5;241m.\u001b[39mcvtColor(frame,cv2\u001b[38;5;241m.\u001b[39mCOLOR_RGB2GRAY)\n\u001b[0;32m----> 6\u001b[0m faces \u001b[38;5;241m=\u001b[39m model\u001b[38;5;241m.\u001b[39mdetectMultiScale(gray,scaleFactor\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m1.1\u001b[39m,minNeighbors\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m8\u001b[39m)\n\u001b[1;32m 7\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m (x,y,w,h) \u001b[38;5;129;01min\u001b[39;00m faces:\n\u001b[1;32m 8\u001b[0m cv2\u001b[38;5;241m.\u001b[39mrectangle(frame,(x,y),(x\u001b[38;5;241m+\u001b[39mw,y\u001b[38;5;241m+\u001b[39mh),(\u001b[38;5;241m256\u001b[39m,\u001b[38;5;241m0\u001b[39m,\u001b[38;5;241m0\u001b[39m),\u001b[38;5;241m2\u001b[39m) \n",
45
+ "\u001b[0;31merror\u001b[0m: OpenCV(4.10.0) /Users/xperience/GHA-Actions-OpenCV/_work/opencv-python/opencv-python/opencv/modules/objdetect/src/cascadedetect.cpp:1689: error: (-215:Assertion failed) !empty() in function 'detectMultiScale'\n"
46
+ ]
47
+ }
48
+ ],
49
+ "source": [
50
+ "cap = cv2.VideoCapture(0)\n",
51
+ "\n",
52
+ "while True:\n",
53
+ " res, frame = cap.read()\n",
54
+ " gray = cv2.cvtColor(frame,cv2.COLOR_RGB2GRAY)\n",
55
+ " faces = model.detectMultiScale(gray,scaleFactor=1.1,minNeighbors=8)\n",
56
+ " for (x,y,w,h) in faces:\n",
57
+ " cv2.rectangle(frame,(x,y),(x+w,y+h),(256,0,0),2) \n",
58
+ " cv2.imshow(\"Screen\",frame)\n",
59
+ " \n",
60
+ " if cv2.waitKey(1) == ord(\"q\"):\n",
61
+ " break"
62
+ ]
63
+ },
64
+ {
65
+ "cell_type": "code",
66
+ "execution_count": null,
67
+ "id": "e563a053",
68
+ "metadata": {},
69
+ "outputs": [],
70
+ "source": []
71
+ },
72
+ {
73
+ "cell_type": "code",
74
+ "execution_count": null,
75
+ "id": "be7ab372-38ce-408b-8a45-948ecd731150",
76
+ "metadata": {},
77
+ "outputs": [],
78
+ "source": []
79
+ }
80
+ ],
81
+ "metadata": {
82
+ "kernelspec": {
83
+ "display_name": "Python 3 (ipykernel)",
84
+ "language": "python",
85
+ "name": "python3"
86
+ },
87
+ "language_info": {
88
+ "codemirror_mode": {
89
+ "name": "ipython",
90
+ "version": 3
91
+ },
92
+ "file_extension": ".py",
93
+ "mimetype": "text/x-python",
94
+ "name": "python",
95
+ "nbconvert_exporter": "python",
96
+ "pygments_lexer": "ipython3",
97
+ "version": "3.11.7"
98
+ }
99
+ },
100
+ "nbformat": 4,
101
+ "nbformat_minor": 5
102
+ }