{
    "componentChunkName": "component---src-templates-blog-post-js",
    "path": "/python-tutorial-face-detection-using-webcam/",
    "result": {"data":{"site":{"siteMetadata":{"title":"CrewCode Solutions"}},"markdownRemark":{"id":"d3ac703f-7468-57c5-bc88-546f1f7768dd","excerpt":"In this article i will explain you how you can detect face in webcam Step 1: Install necessary python library which gonna help in reading images OpenCv: This is…","html":"<p>In this article i will explain you how you can detect face in webcam</p>\n<h4>Step 1: Install necessary python library which gonna help in reading images</h4>\n<ul>\n<li>OpenCv: This is open source image recogntion library in python</li>\n</ul>\n<pre><code class=\"language-py\">pip3 install opencv-python\n</code></pre>\n<h4>Step 2: For face detection you would need another xml file other than image</h4>\n<p>Download haarcascades file for face detection from this link\n<a href=\"https://github.com/opencv/opencv/blob/master/data/haarcascades/haarcascade_frontalface_default.xml\">https://github.com/opencv/opencv/blob/master/data/haarcascades/haarcascade_frontalface_default.xml</a></p>\n<h4>Step 2: Once the needed library installed copy paste the following code</h4>\n<pre><code class=\"language-py\">import cv2\ncap = cv2.VideoCapture(0)\nface_Cascade = cv2.CascadeClassifier(\"haarcascade_frontalface_default.xml\")\n\n#this loop continously check for the faces and detect the faces\nwhile True:\n    success, image = cap.read()\n    imgGray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)\n    faces = face_Cascade.detectMultiScale(imgGray, 1.1, 4)\n\n    for (x, y, w, h) in faces:\n      cv2.rectangle(image, (x, y), (x + w, y + h), (255, 0, 0), 2)\n\n    cv2.imshow(\"Result\", image)\n    if cv2.waitKey(1) &#x26; 0xFF == ord('q'):\n        break\n\ncap.release()\ncv2.destroyAllWindows()\n\n</code></pre>","fields":{"slug":"/python-tutorial-face-detection-using-webcam/"},"frontmatter":{"title":"Python tutorial creating voice assistant using python","date":"January 28, 2023","description":"In this article i will explain you step by step how you can create voice assistant using python","bannerimage":"https://crew-code-images.s3.us-east-1.amazonaws.com/blog_images/python.jpg"}},"previous":{"fields":{"slug":"/python-tutorial-creating-voice-assistant/"},"frontmatter":{"title":"Python tutorial creating voice assistant using python","date":"January 18, 2023","bannerimage":"https://crew-code-images.s3.us-east-1.amazonaws.com/blog_images/python.jpg"}},"next":{"fields":{"slug":"/python-tutorial-watermark-image/"},"frontmatter":{"title":"Python tutorial creating voice assistant using python","date":"February 02, 2023","bannerimage":"https://crew-code-images.s3.us-east-1.amazonaws.com/blog_images/python.jpg"}}},"pageContext":{"id":"d3ac703f-7468-57c5-bc88-546f1f7768dd","previousPostId":"3797002a-529d-5f2b-8117-13367f479914","nextPostId":"bb97d0ee-11b6-5573-bda6-f2a4fc0e4b10"}},
    "staticQueryHashes": ["3860684146"]}