

{"id":79766,"date":"2020-07-24T22:19:19","date_gmt":"2020-07-24T16:49:19","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=79766"},"modified":"2026-06-01T11:47:10","modified_gmt":"2026-06-01T06:17:10","slug":"python-project-real-time-human-detection-counting","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/python-project-real-time-human-detection-counting\/","title":{"rendered":"Python Project &#8211; Real-time Human Detection &amp; Counting"},"content":{"rendered":"<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:2493,&quot;href&quot;:&quot;https:\\\/\\\/drive.google.com\\\/file\\\/d\\\/1Foj8YmCNatVyg5Lg3Kak7Hk6SYMkh_WH\\\/view?usp=drive_link&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20260601061857\\\/https:\\\/\\\/drive.google.com\\\/file\\\/d\\\/1Foj8YmCNatVyg5Lg3Kak7Hk6SYMkh_WH\\\/view?usp=drive_link&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-06-01 07:04:24&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-04 12:20:22&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-07 13:36:55&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-07 13:36:55&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:1037,&quot;href&quot;:&quot;https:\\\/\\\/docs.opencv.org\\\/2.4\\\/modules\\\/gpu\\\/doc\\\/object_detection.html&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20250820204909\\\/https:\\\/\\\/docs.opencv.org\\\/2.4\\\/modules\\\/gpu\\\/doc\\\/object_detection.html&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2025-12-08 22:28:45&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-12 12:32:25&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-15 12:35:52&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-18 13:19:29&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-21 14:50:57&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-24 19:18:52&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-28 11:36:44&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-31 12:12:44&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-04 05:40:07&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-07 16:48:33&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-11 03:10:34&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-14 09:51:00&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-17 14:07:04&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-20 15:38:51&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-23 20:50:08&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-27 03:20:13&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-30 05:46:38&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-02 07:57:08&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-05 09:21:12&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-08 10:03:29&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-11 14:00:27&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-14 14:49:42&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-17 15:08:40&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-21 16:45:45&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-02-24 18:48:19&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-28 02:16:00&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-03 07:35:58&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-06 17:05:29&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-09 18:22:40&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-12 19:06:44&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-15 19:42:17&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-19 00:17:25&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-22 00:49:41&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-25 07:11:14&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-28 08:12:21&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-31 08:17:01&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-03 10:00:22&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-06 14:33:39&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-10 06:26:42&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-13 15:24:52&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-16 18:42:31&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-20 09:27:01&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-23 09:37:31&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-26 20:22:25&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-30 01:24:48&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-03 10:37:02&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-06 14:31:24&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-09 21:02:31&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-13 04:59:53&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-16 10:50:12&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-19 16:33:17&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-23 11:40:55&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-26 14:39:08&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-29 21:08:58&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-02 06:21:15&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-05 16:34:38&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-08 19:22:11&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-08 19:22:11&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;}]'><\/div>\n<p>In this python project, we are going to build the Human Detection and Counting System through Webcam or you can give your own video or images. This is an intermediate level deep learning project on computer vision, which will help you to master the concepts and make you an expert in the field of Data Science. Let\u2019s build an exciting project.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/human-detection-project-output.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-79777\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/human-detection-project-output.gif\" alt=\"human detection project output\" width=\"800\" height=\"456\" \/><\/a><\/p>\n<h2>Human Detection with Computer Vision<\/h2>\n<h3>Project Prerequisites<\/h3>\n<p>The project in Python requires you to have basic knowledge of python programming and the OpenCV library. We will be needing following libraries:<\/p>\n<ul>\n<li><strong>OpenCV:<\/strong>\u00a0A strong library used for machine learning<\/li>\n<li><strong>Imutils:<\/strong> To Image Processing<\/li>\n<li><strong>Numpy:<\/strong>\u00a0Used for Scientific Computing. Image is stored in a numpy array.<\/li>\n<li><strong>Argparse:<\/strong>\u00a0Used to give input in command line.<\/li>\n<\/ul>\n<p>To install the required library, run the following code in your terminal.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">pip install opencv-python\r\npip install imutils\r\npip install numpy\r\n<\/pre>\n<h3>Download Project Code<\/h3>\n<p>Before proceeding ahead, please download the source of real-time human detection project: <a href=\"https:\/\/drive.google.com\/file\/d\/1Foj8YmCNatVyg5Lg3Kak7Hk6SYMkh_WH\/view?usp=drive_link\"><strong>Human Detection &amp; Counting Project<\/strong><\/a><\/p>\n<h3>Histogram of Oriented Gradient Descriptor<\/h3>\n<p>HOG is a feature descriptor used in computer vision and image processing for the purpose of object detection. This is one of the most popular techniques for object detection, to our fortune, OpenCV has already been implemented in an efficient way to combine the <a href=\"https:\/\/docs.opencv.org\/2.4\/modules\/gpu\/doc\/object_detection.html\">HOG Descriptor algorithm<\/a> with Support Vector Machine or SVM.<\/p>\n<h3>Steps To Build Human Detection Project<\/h3>\n<p><strong>1. Import the libraries:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">import cv2\r\nimport imutils\r\nimport numpy as np\r\nimport argparse\r\n<\/pre>\n<p><strong>2. Create a model which will detect Humans:<\/strong><\/p>\n<p>As discussed earlier, We will use HOGDescriptor with SVM already implemented in OpenCV.\u00a0 Below code will do this work:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">HOGCV = cv2.HOGDescriptor()\r\nHOGCV.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())\r\n<\/pre>\n<p><strong>cv2.HOGDescriptor_getDefaultPeopleDetector()<\/strong> calls the pre-trained model for Human detection of OpenCV and then we will feed our support vector machine with it.<\/p>\n<p><strong>3. Detect() method:<\/strong><\/p>\n<p>Here, the actual magic will happen.<\/p>\n<p><strong>Video:<\/strong> A video combines a sequence of images to form a moving picture. We call these images as Frame. So in general we will detect the person in the frame. And show it one after another that it looks like a video.<\/p>\n<p>That is exactly what our Detect() method will do.\u00a0 It will take a frame to detect a person in it. Make a box around a person and show the frame..and return the frame with person bounded by a green box.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">def detect(frame):\r\n    bounding_box_cordinates, weights =  HOGCV.detectMultiScale(frame, winStride = (4, 4), padding = (8, 8), scale = 1.03)\r\n    \r\n    person = 1\r\n    for x,y,w,h in bounding_box_cordinates:\r\n        cv2.rectangle(frame, (x,y), (x+w,y+h), (0,255,0), 2)\r\n        cv2.putText(frame, f'person {person}', (x,y), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0,0,255), 1)\r\n        person += 1\r\n    \r\n    cv2.putText(frame, 'Status : Detecting ', (40,40), cv2.FONT_HERSHEY_DUPLEX, 0.8, (255,0,0), 2)\r\n    cv2.putText(frame, f'Total Persons : {person-1}', (40,70), cv2.FONT_HERSHEY_DUPLEX, 0.8, (255,0,0), 2)\r\n    cv2.imshow('output', frame)\r\n\r\n    return frame\r\n<\/pre>\n<p>Everything will be done by detectMultiScale(). It returns 2-tuple.<\/p>\n<ol>\n<li>List containing Coordinates of bounding Box of person.<br \/>\nCoordinates are in form X, Y, W, H.<br \/>\nWhere x,y are starting coordinates of box and w, h are width and height of box respectively.<\/li>\n<li>Confidence Value that it is a person.<\/li>\n<\/ol>\n<p>Now, We have our detect method. Let\u2019s Create a Detector.<\/p>\n<p><strong>4. HumanDetector() method<\/strong><\/p>\n<p>There are two ways of getting Video.<\/p>\n<ol>\n<li>Web Camera<\/li>\n<li>Path of file stored<\/li>\n<\/ol>\n<p>In this deep learning project, we can take images also. So our method will check if a path is given then search for the video or image in the given path and operate. Otherwise, it will open the webCam.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">def humanDetector(args):\r\n    image_path = args[\"image\"]\r\n    video_path = args['video']\r\n    if str(args[\"camera\"]) == 'true' : camera = True \r\n    else : camera = False\r\n\r\n    writer = None\r\n    if args['output'] is not None and image_path is None:\r\n        writer = cv2.VideoWriter(args['output'],cv2.VideoWriter_fourcc(*'MJPG'), 10, (600,600))\r\n\r\n    if camera:\r\n        print('[INFO] Opening Web Cam.')\r\n        detectByCamera(ouput_path,writer)\r\n    elif video_path is not None:\r\n        print('[INFO] Opening Video from path.')\r\n        detectByPathVideo(video_path, writer)\r\n    elif image_path is not None:\r\n        print('[INFO] Opening Image from path.')\r\n        detectByPathImage(image_path, args['output'])\r\n<\/pre>\n<p><strong>5. DetectByCamera() method<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">def detectByCamera(writer):   \r\n    video = cv2.VideoCapture(0)\r\n    print('Detecting people...')\r\n\r\n    while True:\r\n        check, frame = video.read()\r\n\r\n        frame = detect(frame)\r\n        if writer is not None:\r\n            writer.write(frame)\r\n\r\n        key = cv2.waitKey(1)\r\n        if key == ord('q'):\r\n            break\r\n\r\n    video.release()\r\n    cv2.destroyAllWindows()\r\n<\/pre>\n<p><strong>cv2.VideoCapture(0)<\/strong> passing 0 in this function means we want to record from a webcam. <strong>video.read()<\/strong> read frame by frame. It returns a check which is True if this was able to read a frame otherwise False.<\/p>\n<p>Now, For each Frame, we will call detect() method. Then we write the frame in our output file.<\/p>\n<p><strong>6. DetectByPathVideo() method<\/strong><\/p>\n<p>This method is very similar to the previous method except we will give a path to the Video. First, we check if the video on the provided path is found or not.<\/p>\n<p><em>Note &#8211; A full path must be given.<\/em><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">def detectByPathVideo(path, writer):\r\n\r\n    video = cv2.VideoCapture(path)\r\n    check, frame = video.read()\r\n    if check == False:\r\n        print('Video Not Found. Please Enter a Valid Path (Full path of Video Should be Provided).')\r\n        return\r\n\r\n    print('Detecting people...')\r\n    while video.isOpened():\r\n        #check is True if reading was successful \r\n        check, frame =  video.read()\r\n\r\n        if check:\r\n            frame = imutils.resize(frame , width=min(800,frame.shape[1]))\r\n            frame = detect(frame)\r\n            \r\n            if writer is not None:\r\n                writer.write(frame)\r\n            \r\n            key = cv2.waitKey(1)\r\n            if key== ord('q'):\r\n                break\r\n        else:\r\n            break\r\n    video.release()\r\n    cv2.destroyAllWindows()\r\n\r\ndef detectByCamera(writer):   \r\n    video = cv2.VideoCapture(0)\r\n    print('Detecting people...')\r\n\r\n    while True:\r\n        check, frame = video.read()\r\n\r\n        frame = detect(frame)\r\n        if writer is not None:\r\n            writer.write(frame)\r\n\r\n        key = cv2.waitKey(1)\r\n        if key == ord('q'):\r\n                break\r\n\r\n    video.release()\r\n    cv2.destroyAllWindows()\r\n<\/pre>\n<p>The implementation is similar to the previous function except for each frame we will check that it successfully reads the frame or not. At the end when the frame is not read we will end the loop.<\/p>\n<p><strong> 7. DetectByPathimage() method<\/strong><\/p>\n<p>This method is used if a person needs to be detected from an image.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">def detectByPathImage(path, output_path):\r\n    image = cv2.imread(path)\r\n\r\n    image = imutils.resize(image, width = min(800, image.shape[1])) \r\n\r\n    result_image = detect(image)\r\n\r\n    if output_path is not None:\r\n        cv2.imwrite(output_path, result_image)\r\n\r\n    cv2.waitKey(0)\r\n    cv2.destroyAllWindows()\r\n<\/pre>\n<p><strong>8. Argparse() method<\/strong><\/p>\n<p>The function argparse() simply parses and returns as a dictionary the arguments passed through your terminal to our script. There will be Three arguments within the Parser:<\/p>\n<ol>\n<li><strong>Image:<\/strong> The path to the image file inside your system<\/li>\n<li><strong>Video:<\/strong> The path to the Video file inside your system<\/li>\n<li><strong>Camera:<\/strong> A variable that if set to \u2018true\u2019 will call the cameraDetect() method.<\/li>\n<\/ol>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">def argsParser():\r\n    arg_parse = argparse.ArgumentParser()\r\n    arg_parse.add_argument(\"-v\", \"--video\", default=None, help=\"path to Video File \")\r\n    arg_parse.add_argument(\"-i\", \"--image\", default=None, help=\"path to Image File \")\r\n    arg_parse.add_argument(\"-c\", \"--camera\", default=False, help=\"Set true if you want to use the camera.\")\r\n    arg_parse.add_argument(\"-o\", \"--output\", type=str, help=\"path to optional output video file\")\r\n    args = vars(arg_parse.parse_args())\r\n\r\n    return args\r\n<\/pre>\n<p><strong> 9. Main function<\/strong><\/p>\n<p>We have reached the end of our project.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">if __name__ == \"__main__\":\r\n    HOGCV = cv2.HOGDescriptor()\r\n    HOGCV.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())\r\n\r\n    args = argsParser()\r\n    humanDetector(args)\r\n<\/pre>\n<p>Instead of declaring our model above, we can declare it in our main function.<\/p>\n<h3>Run the Human Detection Project<\/h3>\n<p>To run the human detection deep learning project, please run below-mentioned commands as per requirements<\/p>\n<p>1. To give video file as input:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">python main.py -v \u2018Path_to_video\u2019\r\n<\/pre>\n<p>2. To give image file as input:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">python main.py -i \u2018Path_to-image\u2019\r\n<\/pre>\n<p>3. To use the camera:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">python main.py -c True\r\n<\/pre>\n<p>4. To save the output:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">Python main.py -c True -o \u2018file_name\u2019\r\n<\/pre>\n<h3>Project Output<\/h3>\n<p>Now, after running the human detection python project with multiple images and video, we will get:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/human-counting-output.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-79778\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/human-counting-output.jpg\" alt=\"human counting output\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/human-counting-output.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/human-counting-output-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/human-counting-output-1024x536.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/human-counting-output-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/human-counting-output-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/human-counting-output-520x272.jpg 520w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/human-counting-output-2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-79779\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/human-counting-output-2.jpg\" alt=\"human counting project output 2\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/human-counting-output-2.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/human-counting-output-2-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/human-counting-output-2-1024x536.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/human-counting-output-2-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/human-counting-output-2-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/human-counting-output-2-520x272.jpg 520w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/human-detection-project-output.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-79777\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/human-detection-project-output.gif\" alt=\"human detection project output\" width=\"800\" height=\"456\" \/><\/a><\/p>\n<h2>Summary<\/h2>\n<p>In this deep learning project, we have learned how to create a people counter using HOG and OpenCV to generate an efficient people counter. We developed the project where you can supply the input as: video, image, or even live camera. This is an intermediate level project, which will surely help you in mastering python and deep learning libraries.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this python project, we are going to build the Human Detection and Counting System through Webcam or you can give your own video or images. This is an intermediate level deep learning project&#46;&#46;&#46;<\/p>\n","protected":false},"author":10,"featured_media":79780,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[22271,21686,22746,22744,22745,20697,21082],"class_list":["post-79766","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-computer-vision-project","tag-deep-learning-project","tag-human-counting","tag-human-detection","tag-human-detection-project","tag-machine-learning-project","tag-python-project"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python Project - Real-time Human Detection &amp; Counting - DataFlair<\/title>\n<meta name=\"description\" content=\"Human detection &amp; counting in Python - develop an exciting deep learning project. In this project we used HOG and OpenCV to detect and count no of humans in image, video or real-time\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/python-project-real-time-human-detection-counting\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Project - Real-time Human Detection &amp; Counting - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Human detection &amp; counting in Python - develop an exciting deep learning project. In this project we used HOG and OpenCV to detect and count no of humans in image, video or real-time\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/python-project-real-time-human-detection-counting\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-07-24T16:49:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-01T06:17:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/real-time-human-detection-counting-python.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python Project - Real-time Human Detection &amp; Counting - DataFlair","description":"Human detection & counting in Python - develop an exciting deep learning project. In this project we used HOG and OpenCV to detect and count no of humans in image, video or real-time","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/python-project-real-time-human-detection-counting\/","og_locale":"en_US","og_type":"article","og_title":"Python Project - Real-time Human Detection &amp; Counting - DataFlair","og_description":"Human detection & counting in Python - develop an exciting deep learning project. In this project we used HOG and OpenCV to detect and count no of humans in image, video or real-time","og_url":"https:\/\/data-flair.training\/blogs\/python-project-real-time-human-detection-counting\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2020-07-24T16:49:19+00:00","article_modified_time":"2026-06-01T06:17:10+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/real-time-human-detection-counting-python.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/python-project-real-time-human-detection-counting\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/python-project-real-time-human-detection-counting\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/a90b082e16aa38d207212d22b0581f33"},"headline":"Python Project &#8211; Real-time Human Detection &amp; Counting","datePublished":"2020-07-24T16:49:19+00:00","dateModified":"2026-06-01T06:17:10+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-project-real-time-human-detection-counting\/"},"wordCount":842,"commentCount":58,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-project-real-time-human-detection-counting\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/real-time-human-detection-counting-python.jpg","keywords":["computer vision project","deep learning project","human counting","human detection","human detection project","machine learning project","Python project"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/python-project-real-time-human-detection-counting\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/python-project-real-time-human-detection-counting\/","url":"https:\/\/data-flair.training\/blogs\/python-project-real-time-human-detection-counting\/","name":"Python Project - Real-time Human Detection &amp; Counting - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-project-real-time-human-detection-counting\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-project-real-time-human-detection-counting\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/real-time-human-detection-counting-python.jpg","datePublished":"2020-07-24T16:49:19+00:00","dateModified":"2026-06-01T06:17:10+00:00","description":"Human detection & counting in Python - develop an exciting deep learning project. In this project we used HOG and OpenCV to detect and count no of humans in image, video or real-time","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/python-project-real-time-human-detection-counting\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/python-project-real-time-human-detection-counting\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/python-project-real-time-human-detection-counting\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/real-time-human-detection-counting-python.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/real-time-human-detection-counting-python.jpg","width":1200,"height":628},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/python-project-real-time-human-detection-counting\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Python Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/python\/"},{"@type":"ListItem","position":3,"name":"Python Project &#8211; Real-time Human Detection &amp; Counting"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/a90b082e16aa38d207212d22b0581f33","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/dd6de0d647a0185cd6faf264e4ba860b0d85d08d7070766f9cd41bea5bb0b227?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/dd6de0d647a0185cd6faf264e4ba860b0d85d08d7070766f9cd41bea5bb0b227?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/dd6de0d647a0185cd6faf264e4ba860b0d85d08d7070766f9cd41bea5bb0b227?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"The DataFlair Team is passionate about delivering top-notch tutorials and resources on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. With expertise in the tech industry, we simplify complex topics to help learners excel. Stay updated with our latest insights.","url":"https:\/\/data-flair.training\/blogs\/author\/dfadteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/79766","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=79766"}],"version-history":[{"count":5,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/79766\/revisions"}],"predecessor-version":[{"id":148561,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/79766\/revisions\/148561"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/79780"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=79766"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=79766"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=79766"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}