

















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A Python human detection project typically involves using a combination of computer vision techniques and machine learning algorithms to identify and locate humans in images or videos. Some popular libraries for this task include OpenCV, TensorFlow, and PyTorch. The project may involve creating a custom dataset, training and evaluating the performance of a model, and integrating the detection into a larger system or application.
Typology: Papers
1 / 25
This page cannot be seen from the preview
Don't miss anything!


















KARNATAK LAW SOCIETY’S
UDYAMBAG, BELAGAVI- 590008 (An Autonomous Institution under Visveswaraya Technological University, Belagavi) (APPROVED BY AICTE, NEW DELHI) Course Activity Report on “REAL-TIME HUMAN DETECTION AND COUNTING” Submitted in the partial fulfilment for the academic requirement of 4 TH^ Semester B.E In Information Science Engineering Submitted by Adarsh Kumar 2GI20IS0 02 Danesh Naik 2GI20IS Sahil Faniband 2GI20IS Vinayak Nikam 2GI20IS Under the Guidance Of Dr.Kiran K Tangod HOD,Dept Of ISE Academic Year 2021- 2022
CERTIFICATE This is to certify that the Seminar entitled “REAL-TIME HUMAN DETECTION AND COUNTING ” is a Bonafede record of the Seminar work done by Adarsh Kumar, Danesh Naik, Sahil Faniband, Vinayak Nikam having USN 2GI20IS0 0 2,2GI20IS01 1 , 2GI20IS032, 2GI20IS050 under my supervision and guidance, in partial fulfilment of the requirements for the Outcome Based Education Paradigm in ISE from Gogte Institute of Technology for the academic year 2021-2022. Faculty In charge Head of the Department
1. Engineering Knowledge: Apply the knowledge of mathematics, science, engineering fundamentals and an engineering specialization to the solution of complex engineering problems. 2. Problem Analysis: Identify, formulate, review research literature, and analyse complex engineering problems reaching substantiated conclusions using first principles of mathematics, natural sciences and Engineering sciences. 3. Design/Development of solutions: Design solutions for complex engineering problems and design system components or processes that meet the specified needs with appropriate consideration for the public health and safety, and the cultural, societal, and environmental consideration. Conduct investigation of complex problems: Use research-based knowledge and research methods including design of experiments, analysis and interpretation of data, and synthesis of the information to provide valid conclusion. 4. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern engineering and IT tools including prediction and modelling to complex engineering activities with an understanding of the limitations. 5. The engineer and society: Apply reasoning informed by the contextual knowledge to assess societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to the professional engineering practice. 6. Environment and sustainability: Understand the impact of the professional engineering solutions in societal and environmental contexts, and demonstrate the knowledge of, and need for sustainable development. 7. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of the engineering practice. 8. Individual and team work: Function effectively as an individual and as a member or leader in diverse teams, and in multidisciplinary settings. 9. Communication: Communicate effectively on complex engineering activities with the engineering community and with society at large, such as,being able to comprehend and write effective reports and design documentation, make effective presentations, and give and receive clear instructions.
10. Project management and finance: Demonstrate knowledge and understanding of the engineering management principles and apply these to one's own work, as a member and leader in a team, to manage projects and in multidisciplinary environments 11. Life-long learning: Recognize the need for and have the preparation and ability to engage in independent and lifelong learning in the broadest context of technological change.
Real-Time human Detection and Counting i
ii
- 1.Introduction………………………………………………………….. Table of Contents: - 1.1.Problem Statement………………………………………………... - 1.2.Objectives…………………………………………………………. - 1.3.Methodology……………………………………………………… - 1.3.1.Project Details and Technology……………………….….. - 1.3.2.Python Libraries Used……………………………….....…. - 1.3.3.Human Detection…………………………………………. - 1.3.4.Accuracy…………………………………………………..Real-Time human Detection and Counting 1
1.1. Problem Statement: Real-Time Counting People OpenCV Python – The people counting camera counts the number of people who arrive, leave, or pass through a defined region 1.2. Objectives: Background subtraction technique has been widely used in foreground pixel detection where a fixed camera is usually used to observe dynamic scenes. Generating a background model from video sequences is a challenging task. (1) A background estimation procedure is performed to separate motion from background. Many standard methods exist for background modeling and seg mentation of foreground objects. In these methods, a background scene model is statistically learned using the redundancy of the pixel intensities in a training stage. The foreground objects can be detected if their Gray value differs significantly from the back-ground model. (2) Detecting humans in a video is a challenging task owing to their variable appearance and the wide range of poses that they can adopt. The first need is a robust feature set that allows the human form to be discriminated cleanly, even in cluttered backgrounds under difficult illumination. The detection of moving human bodies from live videos, especially from videos taken by a moving camera, is not a trivial task. (3) The detection normally goes through two stages they are segmentation of moving target and classification of human body. In segmentation stage, optical flow method and difference method are often used. For classification, popular methods include template match, feature characterization, cluster analysis, and machine learning approaches using various techniques such as support vector machine, adaboost, neural network, etc.
Real-Time human Detection and Counting 3 1.3.2 Python Libraries Used: OpenCV: OpenCV-Python is a library of Python bindings designed to solve computer vision problems. Python is a general purpose programming language started by Guido van Rossum that became very popular very quickly, mainly because of its simplicity and code readability. It enables the programmer to express ideas in fewer lines of code without reducing readability. Compared to languages like C/C++, Python is slower. That said, Python can be easily extended with C/C++, which allows us to write computationally intensive code in C/C++ and create Python wrappers that can be used as Python modules. This gives us two advantages: first, the code is as fast as the original C/C++ code (since it is the actual C++ code working in background) and second, it easier to code in Python than C/C++. OpenCV-Python is a Python wrapper for the original OpenCV C++ implementation. OpenCV-Python makes use of Numpy, which is a highly optimized library for numerical operations with a MATLAB-style syntax. All the OpenCV array structures are converted to and from Numpy arrays. This also makes it easier to integrate with other libraries that use Numpy such as SciPy and Matplotlib. Numpy: NumPy in Python is a library that is used to work with arrays and was created in 2005 by Travis Oliphant. NumPy library in Python has functions for working in domain of fourier transform, linear algebra, and matrices. Python NumPy is an open-source project that can be used freely. NumPy stands for Numerical Python. NumPy is often used along with packages like SciPy (Scientific Python) and Matplotlib (plotting library). This combination is widely used as a replacement for MatLab, a popular platform for technical computing. However, Python alternative to MatLab is now seen as a more modern and complete programming language. Dlib: Dlib is a general purpose cross-platform software library written in the programming language C++. Its design is heavily influenced by ideas from design by contract and component- based software engineering. Thus it is, first and foremost, a set of independent software components. It is open-source software released under a Boost Software License. Since development began in 2002, Dlib has grown to include a wide variety of tools. As of 2016, it contains software components for dealing with networking, threads, graphical user interfaces, data structures, linear algebra, machine learning, image processing, data mining, XML and text parsing, numerical optimization, Bayesian networks, and many other tasks. In recent years, much of the development has been focused on creating a broad set of statistical machine learning tools and in 2009 Dlib was published in the Journal of Machine Learning Research Since then it has been used in a wide range of domains
Real-Time human Detection and Counting 4 1.3.3 Human Detection : Human detection is the task of locating all instances of human beings present in an image, and it has been most widely accomplished by searching all locations in the image, at all possible scales, and comparing a small area at each location with known templates or patterns of people. In this we can use various predefined methods and can detect the human in any image, video and can even get various factors like accuracy, each detections counting, etc. We have implemented the project for three different cases:
This section works with real time images. Here will allow user to select any real time image from the local system and then user can detect the humans in it. And along with that it also gives the count of humans detected.
This section works with real time videos. Here will allow user to select any real time video from the local system and then user can detect the humans in it. Now in case of video, since it is running, while the detection process is going on user will be able to see the detected peoples and their count for each frames per second of the video.
This section works somehow similar to case of video. Here user will be asked to first open the webcam, and it will detect humans that will comes in that webcam during the detection process. 1.3.4 Accuracy: Now here we have discussed about the main key point of all computer vision project i.e. Accuracy. During the detection process of human, we along with process also kept track of the accuracy with each human is getting detected in image, video and camera. In our method, we have set the threshold accuracy for the detection process as 70%, so the object detected with accuracy more than the threshold accuracy, we declared it as the well detected human, and display detection indicator around that human during process. We have set this threshold in order to prevent false detection to det displayed while detection process. Now whenever term accuracy comes, there is always a general question, “What is the maximum accuracy of the detection?” and that we have discussed in the next topic.
Real-Time human Detection and Counting 6
Anuj Mohan, Constantine Papageorgiou, and Tomaso Poggio proposed a general example-based framework for detecting objects in static images by components. The technique is demonstrated by developing a system that locates people in cluttered scenes. Especially, the system detects the components of a person’s body in a picture, i.e., the head, the left and right arms, and therefore the legs, rather than the complete body by using four distinct example based detectors. The system then checks to make sure that the detected components are within the proper geometric configuration. Histograms of Oriented Gradients Approach for Human detection. Navneet Dalal and Bill Triggs proposed that the grids of Histograms of Oriented Gradient (HOG) descriptors significantly outperform existing feature sets for human detection. We study the influence of each stage of the computation on performance, concluding that fine-scale gradients, fine orientation binning, relatively coarse spatial binning, and high- quality local contrast normalization in overlapping descriptor blocks are all important for good results. The new approach gives near-perfect separation on the original MIT pedestrian database, so we introduce a more challenging dataset containing over 1800 annotated human images with a large range of pose variations and backgrounds. An Overview of our feature extraction and object detection chain is as shown in fig 1. The method is based on evaluating well-normalized local histograms of image gradient orientations in a dense grid. The basic idea is that local object appearance and shape can often be characterized rather well by the distribution of local intensity gradients or edge directions, even without precise knowledge of the corresponding gradient or edge positions. In practice this is implemented by dividing the image window into small spatial regions, for each cell accumulating a local 1-D histogram of gradient directions or edge orientations over the pixels of the cell. The combined histogram entries form the representation. For better invariance to illumination, shadowing, etc., it is also useful to contrast-normalize the local responses before using them. This can be done by accumulating a measure of local histogram “energy “over somewhat larger spatial regions and using the results to normalize all of the cells in the block. We will refer to the normalized descriptor blocks as Histogram of Oriented Gradient (HOG) descriptors. Tiling the detection window with a dense grid of HOG descriptors and using the combined feature vector in a conventional SVM based window classifier gives our human detection chain as shown in Figure 1 .3. Figure 1.3 An Overview of our feature extraction and object detection chain
Real-Time human Detection and Counting 7 Neural Network and EM based people counting and individual detection. Although there are many human detection methods, most of them are not producing high accuracy and the image resolution must be high. Ya-Li Hou and Grantham K.H. Pang is developed neural network based people counting and EM based individual detection in a low resolution image with complicated scenes that is shown in Figure 3. Figure 1.4 Block Diagram of people counting and human detection DDMCMC approach Tao Zhao and Bo Wu proposed a model based approach to interpret the image observations by multiple partially occluded human hypotheses in a Bayesian framework. This approach to segmenting and tracking multiple humans emphasizes the use of shape models. An overview diagram is given in figure.2. Figure 1. 5 Human Detect by DDMCMC Approach
Real-Time human Detection and Counting 9 if check: frame = imutils.resize(frame, width=min(800, frame.shape[1])) frame = detect(frame) if writer is not None: writer.write(frame) key = cv2.waitKey(1) #allows display a window for given milliseconds if key == ord('q'): break else: break video.release() cv2.destroyAllWindows() def detectByCamera(writer): video = cv2.VideoCapture(0) # This will return video from the first webcam on your computer. print('Detecting people...') while True: check, frame = video.read() frame = detect(frame) if writer is not None: writer.write(frame) key = cv2.waitKey(1) #allows display a window for given milliseconds if key == ord('q'): break video.release() cv2.destroyAllWindows() def detectByPathImage(path, output_path): image = cv2.imread(path) image = imutils.resize(image, width=min(800, image.shape[1])) result_image = detect(image) if output_path is not None:
Real-Time human Detection and Counting 10 cv2.imwrite(output_path, result_image) #This will save the image according to the specified format in current working directory. cv2.waitKey(0) #It takes time in milliseconds as a parameter and waits for the given time to destroy the window,
cv2.destroyAllWindows() def humanDetector(args): image_path = args["image"] video_path = args['video'] if str(args["camera"]) == 'true': camera = True else: camera = False writer = None if args['output'] is not None and image_path is None: writer = cv2.VideoWriter(args['output'], cv2.VideoWriter_fourcc(*'MJPG'), 10, (600, 600)) if camera: print('[INFO] Opening Web Cam.') detectByCamera(writer) elif video_path is not None: print('[INFO] Opening Video from path.') detectByPathVideo(video_path, writer) elif image_path is not None: print('[INFO] Opening Image from path.') detectByPathImage(image_path, args['output']) def argsParser(): arg_parse = argparse.ArgumentParser() # intialize the parser start to add custm arguments arg_parse.add_argument("-v", "--video", default=None, help="path to Video File ")# command arg_parse.add_argument("-i", "--image", default=None, help="path to Image File ")# command arg_parse.add_argument("-c", "--camera", default=False, help="Set true if you want to use the camera.")# command arg_parse.add_argument("-o", "--output", type=str, help="path to optional output video file")# command args = vars(arg_parse.parse_args()) # get an object's dict attribute return args