Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
mauzumshamil authored Apr 21, 2024
1 parent 3012b2f commit e696250
Showing 1 changed file with 166 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 7,
"id": "2e4261c0",
"metadata": {},
"outputs": [],
"source": [
"import cv2\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "bc8b5e14",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"< cv2.VideoCapture 0000014A9D92E010>"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"vid = cv2.VideoCapture(0)\n",
"vid"
]
},
{
"cell_type": "markdown",
"id": "be4c1cf5",
"metadata": {},
"source": [
" Live Capturing"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "fbd53b2b",
"metadata": {},
"outputs": [],
"source": [
"import cv2\n",
"\n",
"vid = cv2.VideoCapture(0)\n",
"\n",
"while True:\n",
" success, frame = vid.read()\n",
" if not success:\n",
" # If unable to read frame, break the loop\n",
" break\n",
" \n",
" cv2.imshow(\"Video\", frame)\n",
" if cv2.waitKey(1) & 0xFF == 27:\n",
" break\n",
"\n",
"vid.release()\n",
"cv2.destroyAllWindows()\n"
]
},
{
"cell_type": "markdown",
"id": "a3bf1372",
"metadata": {},
"source": [
"Live capturing with face detections"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "f58e6f0d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"< cv2.VideoCapture 0000014A9D92E290>"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"vid = cv2.VideoCapture(0)\n",
"vid"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "d660da44",
"metadata": {},
"outputs": [],
"source": [
"face_cascade =cv2.CascadeClassifier('haarcascade_frontalface_default .xml')"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "a8131c25",
"metadata": {},
"outputs": [],
"source": [
"\n",
"vid = cv2.VideoCapture(0)\n",
"\n",
"while True:\n",
" success, frame = vid.read()\n",
" \n",
" if frame is not None and frame.shape[0] > 0 and frame.shape[1] > 0:\n",
" faces = face_cascade.detectMultiScale(frame)\n",
" for (x,y,w,h) in faces:\n",
" cv2.rectangle(frame,(x,y),(x+w,y+h),color=(255,0,255),thickness=3)\n",
" \n",
" cv2.imshow(\"Video\", frame)\n",
"\n",
" if cv2.waitKey(1) & 0xFF == 27:\n",
" break\n",
"\n",
"vid.release()\n",
"cv2.destroyAllWindows()\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4427271d",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.11.4"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

0 comments on commit e696250

Please sign in to comment.