scieee AI-readable full text Open interactive document viewer

Violence detection inside vehicles using computer vision and deep learning

Dias, Sara João Carvalho

Abstract

The constant growth in the automotive market has been increasing the concern for driver and passenger safety. Vehicle safety has evolved throughout history, from basic measures such as rear-view mirrors and safety glass to advanced technologies, including airbags and driver assistance systems. Recently, Artificial Intelligence has been integrated to further enhance safety, with systems capable of environment recognition and driver’s attentiveness monitoring. However, current safety features are primarily oriented toward preventing crashes and do not address in-vehicle violence, a growing concern, particularly for taxi and ride-share services. This dissertation aims to develop a violence detection system using computer vision and deep learning, which can monitor and identify violent behavior in real-time with surveillance cameras inside vehicles. To obtain that, state-of-the-art deep learning algorithms for violence detection using video feeds were studied. Several algorithms using Convolutional Neural Networks and Recurrent Neural Networks, as well as techniques such as feature transferability and pose estimation were implemented and benchmarked for their effectiveness in violence detection using the provided dataset. Two distinct datasets were created from the original provided dataset. The first is an imbalanced dataset that reflects the real-life frequency of violent and nonviolent interactions. The second is a balanced dataset where all classes are represented equally for training purposes. The results from the benchmarking proved that the developed systems are capable of providing violent action detection, adding an extra layer to the security measures for drivers and passengers. For the provided dataset, the model that obtained the best performance was CNNLSTM with VGG19. On the imbalanced dataset, the Accuracy was 86% with a Matthews Correlation Coefficient (MCC) of 73%. The model performance was also evaluated on the balanced dataset, achieving an Accuracy of 92%. These results emphasize that the quality and quantity of data can influence the outcome when training deep learning models. When integrated into vehicles, this system makes ride-sharing services, public transport, and private vehicles much safer by reducing the chances of violence and increasing the amount of trust by customers toward such services. Furthermore, the development of these machine learning algorithms has potential applications in other domains such as public surveillance, smart cities, and emergency response systems.

Full text

University of Minho School of Engineering Sara João Carvalho Dias Violence detection inside vehicles using computer vision and deep learning July 2024 University of Minho School of Engineering Sara João Carvalho Dias Violence detection inside vehicles using computer vision and deep learning Master’s dissertation Masters in Informatics Engineering Dissertation supervised by João Miguel Lobo Fernandes André Leite Ferreira July 2024 Copyright and Terms of Use for Third Party Work This dissertation reports on academic work that can be used by third parties as long as the internationally accepted standards and good practices are respected concerning copyright and related rights. This work can thereafter be used under the terms established in the license below. Readers needing authorization conditions not provided for in the indicated licensing should contact the author through the RepositóriUM of the University of Minho. License granted to users of this work: CC BY https://creativecommons.org/licenses/by/4.0/ v vi Statement of Integrity I hereby declare having conducted this academic work with integrity. I confirm that I have not used plagiarism or any form of undue use of information or falsification of results along the process leading to its elaboration. I further declare that I have fully acknowledged the Code of Ethical Conduct of the University of Minho. University of Minho, Braga, 2024 Sara João Carvalho Dias vii viii Acknowledgments Everyone who was alongside me during this journey knows how challenging it was. This marks the end of a long ride that has provided me with a lot of knowledge, wisdom, experiences, and memories. To Professor João M. Fernandes, for being rigorous but supportive. To Professor André L. Ferreira, for the patience during the early stages of this dissertation. To Bosch, for providing me with this opportunity for professional growth. To my mentors Bruno, Tomé and Edgar, for the compassion and patience throughout my learning process. Thank you all for your guidance, knowledge, understanding and availability. To my mom. Without you, without your unconditional support, I would not have been able to finish this stage. Thank you for letting me be who I am and for (almost) always letting me fly, always respecting my time and space. You are a true example of strength and determination, and one of my greatest pillars. To you I owe the beautiful life I have. Thank you for everything. To you, "mana", for all the support and understanding. Thank you for being my big sister and giving me the reality checks I sometimes need. You are, and always will be, a shoulder I can turn to, no matter how difficult the days may seem. To Aurorinha, such a tiny but beautiful being who has brightened my days from the moment she was born. I will forever be your proud "titi". Thank you for her as well, sis. I love you so much. To my family, for always being there for me. To Inês and Bia, for always believing in me, for being patient with me, for encouraging and motivating me. Thank you for always making me laugh and helping me see the light at the end of my darkest tunnels. I wouldn’t be able to be who I am without your unconditional love. Thank you for joining me in study sessions, for believing in me when I couldn’t believe in myself, and for offering tough love when I needed it. I am so grateful for both of you and for all the memories we’ve created together. Thank you for being part of my life. To Né, for being exactly who I needed you to be. Thank you for the late study nights, for all the memories, and for our inside jokes. This journey wouldn’t have been the same without you. I will always be grateful for "CG1", for the beginning of us. Thank you for making my life brighter. To António. I owe the completion of this dissertation to you. I can never thank you enough for never complaining, even when I asked for too much of your help. You give everything you have to everyone around you, and I am grateful for being one of those people. Thank you for being who you are, for the immense support you gave me during this journey, and for all the moments you were there for me. Thank you for cheering me up, for being my favorite company for procrastinating, for believing in my potential when I couldn’t see it, for many things that words cannot express that make you such a special person to me. To all of you who made this possible. And to myself for surviving. ix 3.6.1 Undersampling ................................ 33 3.6.2 Weightdistribution.............................. 35 3.7 Stratifieddatasplit.................................. 35 4 Implementation of state-of-the-art techniques 37 4.1 Datashape ...................................... 37 4.2 Datagenerator .................................... 37 4.3 Classandsampleweights............................... 38 4.4 Poseestimation.................................... 38 4.4.1 OpenPose ................................... 39 4.4.2 MoveNet.................................... 39 4.4.3 PoseNet .................................... 42 4.5 Benchmarking deep learning models . . . . . . . . . . . . . . . . . . . . . . . . . 43 4.5.1 CNN-LSTM with VGG19 . . . . . . . . . . . . . . . . . . . . . . . . . . 44 4.5.2 CNN-LSTM with ResNet50 . . . . . . . . . . . . . . . . . . . . . . . . . 46 4.5.3 StreamConvLSTM.............................. 46 4.5.4 C10R1D2 ................................... 47 4.5.5 3DCNN .................................... 48 4.5.6 BiLSTM.................................... 49 4.5.7 MoveNet with Dense layers . . . . . . . . . . . . . . . . . . . . . . . . . 50 4.5.8 MoveNetwithLSTM............................. 52 4.5.9 Results..................................... 54 4.5.10 Training with the balanced dataset . . . . . . . . . . . . . . . . . . . . . 55 5 Conclusion and future work 57 5.1 Conclusion....................................... 57 5.2 Limitations and future work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 References 61 A Model architectures 65 xvi List of Acronyms Acc Accuracy BiLSTM Bidirectional LSTM CNN Convolutional Neural Network FPS Frames Per Second LSTM Long Short-Term Memory MCC Matthews Correlation Coefficient RNN Recurrent Neural Network SVM Support Vector Machine xvii xviii List of Figures 2.1 Researchmethodology................................. 5 2.2 Typical approach to violence detection. . . . . . . . . . . . . . . . . . . . . . . . 9 2.3 Standard confusion matrix. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 3.1 Camera perspectives in a vehicle. . . . . . . . . . . . . . . . . . . . . . . . . . . 24 3.2 Examples showcasing the dataset classes. . . . . . . . . . . . . . . . . . . . . . . 24 3.3 Violencecategories................................... 26 3.4 Nonviolencecategories................................. 27 3.5 Number of videos per category, without Talk_left and Talk_right......... 29 3.6 Number of frames of each category, without Talk_left and Talk_right....... 29 3.7 Frequency of video duration, in seconds. . . . . . . . . . . . . . . . . . . . . . . 30 3.8 Count of categories in the imbalanced dataset. . . . . . . . . . . . . . . . . . . . 32 3.9 Balance of classes in the imbalanced dataset. . . . . . . . . . . . . . . . . . . . . 32 3.10 Count of categories in clipped 1-second videos dataset. . . . . . . . . . . . . . . 33 3.11 Balance of classes in clipped 1-second videos dataset. . . . . . . . . . . . . . . . 34 3.12 Count of categories in the balanced dataset. . . . . . . . . . . . . . . . . . . . . 34 3.13 Balance of classes in the balanced dataset. . . . . . . . . . . . . . . . . . . . . . 35 4.1 First implementation of MoveNet. . . . . . . . . . . . . . . . . . . . . . . . . . . 39 4.2 Implementation of MoveNet with colored keypoints and connections. . . . . . . . 40 4.3 Implementation of MoveNet with adjusted contrast and brightness. . . . . . . . 40 4.4 Implementation of MoveNet on a frame with occlusion. . . . . . . . . . . . . . . 41 4.5 Implementation of MoveNet without visible legs or heads. . . . . . . . . . . . . . 41 4.6 Implementation of MoveNet seen from different perspectives. . . . . . . . . . . . 41 4.7 Implementation of MoveNet with visibility and body member overlap. . . . . . . 42 4.8 Implementation of PoseNet on a frame. . . . . . . . . . . . . . . . . . . . . . . . 42 4.9 Evolution of Accuracy and loss during the training of CNN-LSTM with VGG19. 45 4.10 Misclassification frequency graph by category for CNN-LSTM with VGG19. . . 45 4.11 Misclassification frequency graph by category for CNN-LSTM with ResNet50. . 46 4.12 Misclassification frequency graph by category for stream ConvLSTM. . . . . . . 47 4.13 Misclassification frequency graph by category for C10R1D2. . . . . . . . . . . . 48 4.14 Evolution of Accuracy and loss during the training of 3DCNN. . . . . . . . . . . 48 4.15 Misclassification frequency graph by category for 3DCNN. . . . . . . . . . . . . 49 4.16 Evolution of Accuracy and loss during the training of BiLSTM. . . . . . . . . . 49 4.17 Misclassification frequency graph by category for BiLSTM. . . . . . . . . . . . . 50 4.18 Evolution of Accuracy and loss during the training of MoveNet with Dense layers. 51 4.19 Misclassification frequency graph by category for MoveNet with Dense layers. . . 51 4.20 Evolution of Accuracy and loss during the training of MoveNet with LSTM. . . 52 4.21 Misclassification frequency graph by category for MoveNet with LSTM. . . . . . 53 4.22 Evolution of Accuracy and loss during the training of CNN-LSTM with VGG19 onthebalanceddataset. ............................... 55 xix 4.23 Misclassification frequency graph by category for CNN-LSTM with VGG19 on thebalanceddataset ................................. 56 A.1 CNN-LSTM with VGG19 architecture. . . . . . . . . . . . . . . . . . . . . . . . 65 A.2 CNN-LSTM with ResNet50 architecture. . . . . . . . . . . . . . . . . . . . . . . 66 A.3 Stream ConvLSTM architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . 67 A.4 C10R1D2architecture................................. 68 A.5 3DCNNarchitecture.................................. 69 A.6 BiLSTMarchitecture. ................................ 70 A.7 MoveNet with Dense layers architecture. . . . . . . . . . . . . . . . . . . . . . . 71 A.8 MoveNet with LSTM architecture. . . . . . . . . . . . . . . . . . . . . . . . . . 72 xx List of Tables 2.1 Researchsources. ................................... 6 3.1 Logfile.......................................... 25 3.2 Statistics of the Violent videos. . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 3.3 Statistics of the Nonviolent videos. . . . . . . . . . . . . . . . . . . . . . . . . . 28 3.4 Comparison between the number of clips and the number of seconds/frames of Violentvideos. .................................... 28 3.5 Comparison between the number of clips and the number of seconds/frames of Nonviolentvideos. .................................. 28 3.6 Number of training, test, and validation examples after splitting, for the imbalanceddataset...................................... 36 3.7 Number of training, test, and validation examples after splitting, for the balanced dataset. ........................................ 36 4.1 Benchmarking results for different models on the imbalanced dataset. . . . . . . 54 4.2 Best-performance model results on the balanced dataset. . . . . . . . . . . . . . 56 xxi xxii 1 Introduction 1.1 Context and motivation The automotive market has been in constant growth for many years now, with more people owning and driving a car each day. More so, with the increase in the number of vehicles circulating the streets every day, the safety of the driver and passengers has been a growing concern to the public in general. However, the concern for automotive safety began way before this date, back when cars were still news. In fact, from the early days of the automotive industry, safety became of the highest priority. The first elementary safety measures were in the early 20th century, with the implementation of rear-view mirrors and safety glass (Quitugua, 2022). These marked the beginning of what would become a long journey on vehicle safety, that persists nowadays, aiming to reduce injuries and fatalities on the road. Despite elementary, these safety measures are still standard to this day and have seen increasingly progressive technologies over the decades, with continuous improvements in the protection of drivers and passengers. In the 1950s, some of the most important safety features still in use in today’s vehicles were introduced. Airbags and seat belts made their appearance in this decade and came to stay (Quitugua, 2022). It was in the 50s that the World Forum for Harmonization of Vehicle Regulations was established by the United Nations, with the purpose of harmonizing regulations on vehicles, and promoting standard safety features globally (UNECE, 2022). During the mid-20th century, more safety measures occurred that showed the seriousness and importance of this matter. Crash tests were introduced to assess the impacts of car collisions, becoming mandatory at the end of the 20th century (Quitugua, 2022). The 1990s introduced the use of electronic systems in vehicles, such as Brake Assist Systems (BAS) and Electronic Stability Control (ESC) systems (Quitugua, 2022). This marked the beginning of an era where technology rules the advancements for vehicle safety features. The 21st century came accompanied by driver-assistance systems that transformed the landscape of automobile safety. The introduction of motion sensors, cameras, autonomous emergency braking systems, and others have made huge contributions to lessening the risk of accidents and mitigating their effects (Quitugua, 2022). All this evolution would not be possible without Bosch playing its part. Bosch has been present almost from day one, regarding safety features on vehicles. It started on windshield wipers, made its way through the innovation of airbags, ABS (Anti-Lock Brake System), and ESC (Electronic Stability Control) systems, and is now contributing vastly to driver assistance and automated driving systems (Bosch, 2024c,d), always being on the cutting edge of automotive technology. The most recent approach to vehicle safety is the integration of Artificial Intelligence (AI) into automobile systems. Bosch has developed assistance systems with the help of AI, such as a multi-purpose camera, that makes automated driving safer and more reliable: it helps with environment recognition (Bosch, 2024a), enabling vehicles to reliably detect objects and people at all times (Bosch, 2024b). 1 There have been huge advancements in vehicle safety, with the primary objective of protecting drivers and passengers. For instance, systems designed to monitor the attentiveness of the driver to prevent accidents have been implemented (MulticoreWare, 2021). These systems can detect signs of fatigue or other distractions, and alert the driver to avert potential issues. Keeping the driver and passengers safe has been a priority in the automotive industry. However, the focus lies on preventing car crashes and road accidents. It is important to consider that the safety of the people inside the vehicle may be at risk with other variants, such as in-vehicle violence. In this context, the detection of violence inside vehicles becomes a natural extension of the protection of the occupants of vehicles. The history of vehicle safety developments is crucial to understand the evolution necessary to reach what is known and taken for granted today. There is a lot of potential in the technology available today to enhance vehicle safety, including the capability to detect and address violence within vehicles. Violence is an issue that has been present forever and has unfortunately never gone away, being infiltrated in almost every aspect of our daily lives. Violence was declared a “major public health issue” back in 1996, by the World Health Assembly (Krug et al., 2002). The automotive sector is just one of the daily life environments where in-vehicle violence has increased recently. Violence inside vehicles poses a great risk to the drivers and passengers’ safety. When discussing robberies or domestic violence, we often overlook the fact that these incidents can occur inside our cars. It is relevant to notice that "taxi drivers have the highest or among the highest risk of job-related homicide and assault", as stated by Menendez and Morgantown (2019). Along with car crashes, violence is often a leading cause of taxi driver deaths. The safety of cab drivers is, therefore, a significant concern, and it is crucial that these workers feel protected while doing their jobs. Furthermore, ride-sharing services have reported numerous cases of assault and violence, affecting both drivers and passengers (Almoqbel and Wohn, 2019). This highlights the importance of ensuring safety measures for all individuals involved in these services. People do anything and everything inside their cars — we can even say that a car is like a home now. It’s in growing demand that people feel comfortable inside their vehicles, with the increase in the daily time they spend driving a car or being a passenger in one. With the consumers’ growing desire for car improvements, many machine learning applications are being used to improve consumers’ experiences regarding the automotive industry. “Autonomous driving”, “conversational user interfaces” that allow a “hands-free interaction with the vehicle” (Luckow et al., 2016), or driver assistance systems that help in the prevention of accidents, are currently evolving to be the default pattern concerning the experience of driving a car. These machine learning approaches answer the question of how to bring the best features to car users, not only regarding their comfort but also their safety. New issues also emerge with the new paradigms of autonomous driving that are being taken into place. When a vehicle drives itself, the need for a driver disappears, but the need for new methods to ensure security appear. It becomes necessary to find a way to replace these people’s responsibilities in maintaining order inside vehicles. To address these challenges of guaranteeing safety inside vehicles, innovative solutions that use advanced technologies are required. Computer vision and deep learning are promising approaches that can help overcome these limitations by making real-time surveillance and anomaly detection in the vehicle a possibility. These technologies can alert the authorities on any violent occurrence, reassuring the driver or passengers in an unfortunate situation. This research impacts more than just improvement in safety inside vehicles. Implementing 2 a robust violence detection system within vehicles could transform public safety completely. With the detection of violent behavior in real-time, passengers of ride-hailing services, public transport, and private vehicles will feel safer. Enhancing the sense of safety of the passengers can lead to a higher usage and trust in these services, while also somehow preventing these situations from happening. Such as passengers, drivers will also have an added level of protection against assaults, especially those in high-risk professions, such as taxi and ride-share drivers. This reduces risks related to the job, improving job satisfaction. The implementation of violence detection inside vehicles will make available real-time data on these occurrences. This may help law enforcement in developing more effective policies and responses to in-vehicle violence. Furthermore, the development of machine learning algorithms to detect violent behavior can contribute to extending applications in other domains, including public surveillance, smart cities, and emergency response systems. 1.2 The problem and its challenges The proposed problem in this research can be described as finding an architecture or pipeline of models for the detection of violence inside the vehicle. Therefore, it is required to research investigations that scientists have made on activity and violence detection, and with that, choose the models that show a better performance on identifying and labeling actions based on video, addressing the pros and cons of each one. How the combinations of algorithms are chosen depends on the metrics that are used to evaluate said algorithms. It is important to understand metrics and whether they are suitable for the problem at hand, and make a final selection on the best metrics to use regarding this topic. This way, it is possible to comprehend the results that are being achieved and interpret the answer. This shows a better understanding of the problem, which leads to the better implementation of the models, and a better analysis of possible improvements that can be made in future work. To detect human activity and take this problem into hands, it is mandatory to understand the data presented to the algorithms. The dataset used is composed of labeled videos. A video can be described as a sequence of images or frames. To process these images, a possible approach is to use feature extraction with the help of computer vision technology, and then feed these features into a sequence model that takes into account that the video frames have an inherent order between them. The model proceeds to detect if there is any strange activity present in the frames, being able to tell if there is a case of violence or not. The biggest challenge of this problem is the data. Since the performance of neural networks depends on the data that it is fed with, the dataset used must be adequate for the problem. This means that the data needs to be sufficient for the model to be trained with the most varied examples possible; this leads to the need for the dataset to be generalized enough, so the model is vastly trained and able to properly classify and adapt to new data, avoiding overfitting on the training data. 1.3 Main objectives The main purpose of this study is to research and evaluate various approaches and algorithms for detecting video-based human activity inside a vehicle. Using state-of-the-art computer vision and deep learning models, the goal is to identify the best-performing algorithms for violence detection in video sequences and test their performance on the provided dataset. Therefore, this dissertation has the following objectives: 1. Research and analyze state-of-the-art literature in machine learning techniques on activity 3 videos, is less representative of scene-focused datasets due to the static images (Zhou, 2022). Different from scene-focused datasets, background scenes in non-scene-focused datasets do not provide much contribution to the final result. 2.4.2 Data challenges When dealing with datasets, many challenges occur, due to the variance that exists between the data. In this particular case, each video, or even each frame, can have different characteristics from the others. It becomes important to recognize these possible issues and, preferably, address them, so they are not a problem for the task at hand. Quantity When training a machine learning model, one of the biggest challenges is the data. For the algorithm to perform well in real-life applications, it needs a large quantity of information. Particularly with deep learning models, their performance improves the larger the volume of the data. For video action recognition, large-scale datasets are needed for the construction of effective models (Zhu et al., 2020). Angles A video can be shot from different angles, which results in different apparent motions, depending on where the camera is located. Occlusion During an action, the relevant subject may be temporarily hidden behind another object (Kaur and Singh, 2022). There can also be overlapping of objects or humans, which might make the task of recognizing the activity more challenging. Multiple actions Multiple subjects in a video could be performing different relevant actions that the model should detect. This adds to the complexity of detection since the model might confuse the features of different interactions and have a hard time identifying each interaction correctly. Change in relative size A subject can appear to be changing sizes if its relative position to the camera changes, this may lead to higher complexity in recognition. Lighting In the research performed by Shahinfar et al. (2020), there was a particular dataset in which the performance of the model was not as satisfactory as with other datasets. They concluded that this was due to the majority of the data in that dataset being captured during the night, where the target object was too small and hard to identify, even by the human eye. This shows that one of the challenges of computer vision is the visibility of the images and the amount of light available. Kaur and Singh (2022) reinforce that sudden changes in lighting might make two sequential frames look completely different, making it harder to detect relevant actions. 10 Discerning violence from other actions There may be subtle changes between a violent action and a nonviolent one, which makes it necessary for the model to be precise in its detection. As a result, this increases the need for quality labeled data (Kaur and Singh, 2022). Complex behaviors Human behavior is a complex subject. Noise and variation in a subject’s activity can make interactions unclear and difficult to identify (Kaur and Singh, 2022). Variations on perspective When a person is performing some action, it is important to have in mind that that action can be perceived as something else from another point of view. Zhu et al. (2020) supports that certain actions have similar motion patterns that can be challenging to distinguish. There is no catch-all solution for all these challenges. It is necessary to address each problem individually by using specific techniques to tackle each one. It is wise to develop methods that handle as many issues as they can efficiently and effectively. 2.4.3 Data augmentation Deep learning algorithms require a lot of data to train properly, and there are times when the available datasets do not provide enough information for them to train adequately. In these cases, the content of those datasets may be augmented to surpass this problem. Data augmentation is the act of introducing small changes in the training data and including them in the original training set. This makes the model more robust to variance in data and leads to an increase in the model’s performance (Shahinfar et al., 2020). This is a technique that has been used for years, and video action recognition models still adopt primitive methods of augmenting the data, such as random resizing, random cropping, and random horizontal flipping. State-of-the-art models also use rotation, zooming in, symmetric wrapping, and changing global information of images, such as their saturation or brightness. Zhu et al. (2020) shows that color jittering and random rotation have a great impact on helping representation learning. 2.4.4 Data normalization Data normalization when the dataset is composed of videos means ensuring consistency between the videos and identical data distribution for each pixel, as well as decreasing the complexity of the training of the models. Each frame of each video is composed of pixels, and these pixels have values that range from 0 to 255, representing a color code. The computation of high numeric values can become complex for deep learning networks, so the solution is normalizing these values to range from 0 to 1. Normalized data speeds up model convergence during training. Islam et al. (2021) concluded that normalization improved the model’s performance after fifty epochs, which in turn made it more efficient than if the training data had not been normalized at all. 11 2.5 Feature extraction Feature extraction is the process of converting raw data into numerical features that can be processed by machine learning models while retaining the information from the original dataset. This approach typically achieves better results compared to applying the models directly to raw data. 2.5.1 Feature extraction techniques The techniques mentioned in Figure 2.2 are included in feature extraction approaches. Histogram of Oriented Gradients (HOG), Histogram of Oriented Flow (HOF), optical flow, spatiotemporal, among others, are techniques that are able to extract features from raw video data. Each one of these techniques has different purposes for the analysis of features in video frames and sequences. Traditional methods to detect violence are mostly based on feature extraction algorithms since they can effectively capture violent motion in the video. However, these techniques need large preprocessing. Over the years, there have been many proposals for end-to-end deep learning models, which this study focuses on. Deep learning algorithms need little to no preprocessing, therefore resulting in a less resource-hungry program (Zhou, 2022). On the other side, these models need a large quantity of data to learn useful features effectively. 2.5.2 Feature transferability Deep learning models need large quantities of data to properly extract meaningful features. However, there are often situations where there is not sufficient data available. In such cases, feature transferability becomes a valuable solution. When training data is scarce, using features from distant tasks to initialize the network may be more advantageous than using random weights (Shahinfar et al., 2020). Pre-trained models have been trained on large datasets and can be used for feature extraction or fine-tuned for a specific problem. These features can be effectively reused for different but related tasks or datasets. Initializing a network with transferred features can improve the model’s ability to generalize (Yosinski et al., 2014). This approach is useful for limited datasets and computing resources while achieving good accuracy, as demonstrated in violence detection datasets by Abdali and Al-Tuma (2019) and Zhu et al. (2020). Fine-tuning involves retraining the top layers of the pre-trained model so that it learns features specific to the problem and adjusts its weights accordingly. Feature extraction involves the freezing of all the layers of the pre-trained model to extract features based on the data on which it was originally trained, and feeds these extracted features to a classification algorithm to return the final result. VGG16 Visual Geometry Group 16 (VGG16) is a Convolutional Neural Network (CNN) architecture with 16 layers. This number of layers enables the model to capture the fine details in an image and understand complex relationships between features (Simonyan and Zisserman, 2015). VGG16 achieves high accuracy and is widely used due to its balance in performance and computational efficiency. VGG16 achieved good performance on the ImageNet Large-Scale Visual Recognition Challenge, taking the first and second positions for object detection and classification tasks (Simonyan and Zisserman, 2015). This success proves the ability of VGG16 to handle complex 12 problems of image recognition. VGG16 is pre-trained on the ImageNet dataset (Deng et al., 2009). VGG19 VGG19 is an improved version of VGG16. This Convolutional Neural Network (CNN) architecture is known for its simplicity and high results in image recognition tasks. VGG19 is three layers deeper than VGG16, with 19 convolutional layers instead of 16 (Boesch, 2021). This increased depth allows this architecture to potentially extract more complex features from images, However, this increased depth also requires higher computational resources compared to VGG16. VGG19 is pre-trained on the ImageNet dataset (Deng et al., 2009), and its extensive training achieves robust performance in various image classification scenarios. ResNet50 ResNet50 is a deep Residual Network, which is a type of Convolutional Neural Network 50 layers deep (Boesch, 2021). It is known for its ability to address the vanishing gradient problem with a technique called residual learning (Huang et al., 2017). This helps the network train effectively by allowing it to bypass certain layers, with information flowing directly from earlier layers to later layers in the network, making it easier to handle deep architectures and learn complex features (Boesch, 2023). ResNet50 has been applied to several image recognition tasks, with a good balance between performance and computational efficiency. ResNet50 is pre-trained on the ImageNet dataset (Deng et al., 2009). 2.5.3 Pose estimation Pose estimation is a computer vision technique used in a variety of proposed approaches (Shah et al., 2021; Kwan-Loo et al., 2022), widely used for machine learning problems that include the detection or recognition of human figures. As the name says, this method calculates the pose of a human, where the location of specific joints is extracted from a particular frame. Most algorithms for pose estimation can locate the human’s head, arms, legs, knees, elbows, wrists, and ankles (Kwan-Loo et al., 2022). One of the challenges with pose estimation is the order of the objects between two frames. If there are two or more people in two consecutive frames, there is no guarantee that the first bounding box in each array will correspond to the same person. Another challenge in pose estimation is the overlapping of objects on a particular frame. It becomes a hard task to detect the joints of two humans that are overlapping each other (Kwan-Loo et al., 2022). There is a large variety of pose estimation models out there. An analysis and study of the state-of-the-art models was necessary to select the most adequate one for this problem. In the pose estimation world, some models can detect solely one person, and there are muti-person models, that can detect many people. For the problem at hand, considering the interactions happen between two people, the pose estimation model must be able to detect at least two people in the videos. This cuts down a large amount of the existing pose estimation models. Multi-person pose estimation is more challenging since it requires analyzing an environment where the number and location of people to detect is unknown. There are two approaches to this problem: top-down and bottom-up. The top-down approach first detects people and only then tries to associate a pose with them. The bottom-up approach works the other way around. It first detects body parts and then associates those parts in a way that composes a person. 13 To be able to choose a pose estimation algorithm, it is important to consider whether their licenses authorize commercial use, since this work is being developed with Bosch. PoseNet PoseNet is a top-down approach to pose estimation, released in 2017. There are two versions of this model: single and multi-person. Single pose estimation is faster and simpler but is limited to images/videos with only one person. In PoseNet, an input RGB image is fed through a Convolutional Neural Network (CNN). The model is available with two architecture variants: MobileNetV1 and ResNet50. The MobileNetV1 model is smaller and faster but with low accuracy, while the ResNet50 model is larger and slower, although more accurate. Both architectures support single and multi-pose estimation. The model outputs the coordinates of 17 keypoints along with a confidence score for each detected person (Bhavika Panara, 2021). OpenPose OpenPose was the first pose estimation algorithm that was able to detect human body joints on multi-person and real-time images. With a total of 135 keypoints, this algorithm can detect joints along the body, hands, face, and feet (Cao et al., 2021). OpenPose is a bottom-up pose estimation algorithm with very good performance. It analyzes the input image with a Convolutional Neural Network (CNN) to produce "feature maps", which highlight varied aspects of the image, such as edges, textures, and shapes. The feature maps are then fed into a highly specialized, multi-stage CNN pipeline, which outputs two things: the Part Confidence Maps and the Part Affinity Fields. The Part Confidence Maps represent each body part—for instance, the elbows, the knees, the face—being in a specific position, while the Part Affinity Fields depict the orientation and connection between the different body parts, therefore allowing the system to understand their connectivity and interaction. Finally, OpenPose uses an algorithm that makes the best locally optimal choices at each step, to identify individual poses in images containing multiple people. MoveNet MoveNet is a bottom-up approach released in 2021 by Tensorflow (2022). They offer three different versions of the model: two single-pose algorithms and one multi-pose. The multi-pose detector is only available in Lightning version, which is intended for latency-critical applications and does not perform with such accuracy as Thunder, which is only available for single-pose estimation. The multi-pose version of MoveNet is a Convolutional Neural Network (CNN) model for running on RGB images that detects human joint locations for multiple people in an image frame. Unlike its predecessor, the single-pose version, which detects only one person, the multipose model will detect up to six people at the same time while maintaining real-time speed. The "Lightning" variant of the model detects up to six people at once and delivers good performance. 2.6 Algorithms for action recognition Many machine learning algorithms can be used for computer vision tasks. When choosing the best algorithm to use, it is wise to study each one considering the use case, as this can impact the performance of an algorithm. 14 As explained before, a machine learning model performance is influenced by factors such as its complexity, the characteristics of the training data (such as quantity and quality), and the task or problem it is being used for. With that said, the next step is identifying and evaluating the existing models, namely for video action recognition. To avoid complexity and promote simplicity, this study tackles a binary classification problem, with the purpose of defining an action in a video as violent or nonviolent. Therefore, the two classes that are relevant here are Violent and Nonviolent. With this approach, it is possible to conclude which models are the best to solve these kinds of problems, while keeping low complexity. There are three main categories in which these models fit: Machine Learning, Support Vector Machine (SVM), and Deep Learning. The usage of different classifiers is determined by what is the best approach to a certain problem, and it depends on the context and the type of data being used. No algorithm works perfectly for everything, it all depends on the problem at hand since different algorithms have different strengths and weaknesses. In the end, the intention was to find the algorithm that works best for the topic of violence detection inside a vehicle, by evaluating the work that has been performed through the years, on different or similar problems. Ramzan et al. (2019) evaluated many Machine Learning models against SVMs and Deep Learning approaches, on the topic of violence detection. Each pipeline may have distinct techniques for feature extraction and object detection, which is important to consider since all the conditions in which the algorithms are trained interfere with the performance and adequacy of the specific problem. Another important consideration to have is the data that is used, mainly the video features that are considered, and the different datasets used for training the algorithms since they all present distinct characteristics. 2.6.1 Machine Learning Many approaches use Machine Learning classifiers. However, since Deep Learning approaches emerged on the topic, they have been having better results than the previously studied Machine Learning ones: “Machine Learning algorithms focus on motion, whilst in neural networks, the process is done automatically, and we only need to provide this determined set of parameters” (Bermejo Nievas et al., 2011). 2.6.2 Support Vector Machine Besides machine learning, Support Vector Machines (SVMs) are also used as classifiers. This technique is effective for classification problems, particularly binary classification. However, SVMs are now considered an outdated solution for violence detection, especially given the need for real-time classification (Ramzan et al., 2019). 2.6.3 Deep Learning Deep Learning models have made a huge advance in the past years regarding Artificial Intelligence problems. This new method relies on neural networks to do the job. Neural networks mimic how the human brain works, which makes them more reliable when dealing with more complex data, such as videos. Their performance can also be improved when trained with large amounts of data. Accordingly, Huang et al. (2017) and Ramzan et al. (2019) observed that approaches based on Deep Learning presented better results for violence detection than 15 traditional Machine Learning algorithms and SVMs. There are many types of neural networks, including Recurrent Neural Networks (RNN), Convolutional Neural Networks (CNN), Transformers, and others. Deep learning networks are distinguished from each other by their architectures in the form of the number of layers and neurons, the type of connection between layers, activation functions, and optimization algorithms (Shahinfar et al., 2020). CNNs and RNNs are networks that conveniently manage sequential data - such as videos - and can be used to detect patterns and features on them that are not easily visible to the human eye. Convolutional Neural Networks A Convolutional Neural Network (CNN) is a type of neural network designed to process data that has a grid-like structure — such as pixels in an image — by applying filters to the input data to extract features and then perform classification tasks. CNNs are mainly used for processing images and videos, since the network can be trained to recognize specific objects in them. They perform feature extraction automatically, using backpropagation to improve the parameters (Zhu et al., 2020). With the development of Deep Learning in recent years, methods based on Convolutional Neural Networks become the mainstream in video action recognition (Zhou, 2022). There are several types of CNNs, but the most common to deal with action recognition are 2D CNNs (Zhu et al., 2020; Ding et al., 2014) and 3D CNNs (Zhu et al., 2020; Kwan-Loo et al., 2022; Kaur and Singh, 2022; Islam et al., 2021; Shah et al., 2021; Abdali and Al-Tuma, 2019). 2D CNNs This type of Convolutional Neural Network is designed to process, as the name states, 2- dimensional data, i.e., images. They focus solely on extracting spatial information and being efficient in training and inference (Zhu et al., 2020). They lack, however, the ability to process the temporal information on sequences of images, i.e., videos. For violence detection, it is essential to consider the motion and optical flow of the frames (Ding et al., 2014; Zhu et al., 2020). 3D CNNs 3D CNNs are a solution for the spatial-temporal issue. They apply convolution on spatial and temporal sequences (Ding et al., 2014), extracting the motion from the input (Zhu et al., 2020), contrarily to 2D CNNs. 3D models generally perform better than 2D models (Zhou, 2022). This indicates that the spatio-temporal information is critical for long-term complex action understanding. Considering the sequential nature of videos, the temporal aspect must not be ignored, to improve the dependency on the whole system (Shah et al., 2021). Models with 3D CNNs typically use a set of complete frames to learn about changes in images and the environment, which can be advantageous for actions that are performed in similar surroundings (Kwan-Loo et al., 2022). However, this approach may be limited to actions that are independent of the environment, leading to overfitting or learning irrelevant information (Zhu et al., 2020). 3D CNNs also have the characteristic of requiring longer input. This can be seen as a disadvantage due to the training complexity of the network, but it can also be an advantage since it helps with the recognition, considering some actions might require long-term features to be recognizable (Zhu et al., 2020). ResNet In 2020, ResNet (Residual Network) was one of the most efficient and accurate Deep Learning architectures, achieving first-place results in both the Imagenet Large Scale Visual Recogni- 16 tion Challenge 2015 and Common Objects in Context 2015 competitions (Huang et al., 2017). However, since the development of other solutions, this type of Convolutional Neural Network has become outdated. It is, however, widely used for the pre-trained models based on ResNet, such as ResNet50. DenseNet The DenseNet (Densely Connected Convolutional Network) architecture has been found to provide similar accuracy levels to ResNet and slightly better performance, but with higher model complexity. This can be a limitation when the data collection is made through cameras, but can also come with a greater capacity for the model to learn since it considers a larger number of classes or environments (Huang et al., 2017). However, as it brings unnecessary complexity to the task, and has not been proved as one of the best state-of-the-art approaches, it isn’t widely used for violence detection problems. Recurrent Neural Networks Recurrent Neural Networks were originally designed to process sequential data. These networks are characterized by having the notion of time. They can maintain a hidden state that is passed from one timestep to the next. This hidden state allows the network to “remember” information from previous timesteps and use it to inform its current output. RNNs are useful for tasks when the context of the action is important, i.e., when something that happened before may influence what is happening next. This type of neural network comes with the vanishing gradient problem, which limits the ability of the network to retain information from previous steps when propagating back through it. To overcome this problem, some architectures were developed to control the flow of information and help avoid the vanishing gradient problem, such as Long Short-Term Memory (LSTM) and GRU (Gated Recurrent Units). The latter is a simplified version of LSTM networks, using fewer parameters, and thus being less computationally expensive. LSTM Traditional Recurrent Neural Networks struggle to learn long-term dependencies, due to the single hidden state passed through time. Long Short-Term Memory (LSTM) networks meet the challenge by adding a memory cell that stores information for a long time. They are mainly used for extracting temporal context from sequential input. These networks can be combined with other architectures of neural networks, such as CNNs, in the analysis of images and videos. LSTMs require fixed-length input, which means that shorter instances need to be padded to match the length of the longest sequence. In the context of this dissertation, the input consists of videos, so achieving a fixed sequence length involves padding the shorter videos with empty frames. Padding these videos means adding frames that contain only black pixels, devoid of any content, until they match the desired Frames Per Second (FPS) rate. When padding is necessary, it is best practice to apply a Masking layer (Chollet et al., b) before training an LSTM. This layer prevents the padding values from influencing the learning process by instructing the LSTM layer to disregard those values. BiLSTM Bidirectional LSTM is a Recurrent Neural Network that uses two LSTM networks that go through the network in opposite directions to make use of both past and future context of the input, being able to improve the performance of the model on certain tasks where the context is important. Using this technique along with a pre-trained model for feature extraction proved to be more salient than a single LSTM model, showing results with high accuracy on real-time violence 17 detection (Gupta and Ali, 2022; Kwan-Loo et al., 2022). ConvLSTM Several papers factorize 3D convolution filters into 2D spatial filters and 1D temporal filters to ease the training (Zhu et al., 2020). Combining the CNN with an LSTM that brings the temporal information to the spatial information extraction (Kaur and Singh, 2022) promotes the achievement of generality, accuracy, and fast response time. ConvLSTM can effectively capture and process spatiotemporal features in sequential data. This algorithm was developed by Shi et al. (2015). In Kwan-Loo et al. (2022), Islam et al. (2021) and Mugunga et al. (2021) this method achieved great accuracy, especially when using pre-trained models for feature extraction. 2.6.4 Selected architectures Based on a thorough literature review, the best-performing deep learning models were selected for benchmarking. The state-of-the-art models chosen due to their superior performance include ConvLSTM using VGG19 (Abdali and Al-Tuma, 2019), stream ConvLSTM (Mugunga et al., 2021), C10R1D2 (Islam et al., 2021), 3DCNN (Ding et al., 2014), BiLSTM (Gupta and Ali, 2022) and MoveNet with Dense layers (Kwan-Loo et al., 2022). These architectures combine the potential of feature transferability, pose estimation, CNNs, and RNNs. CNN-LSTM with VGG19 The architecture developed by Abdali and Al-Tuma (2019) combines Convolutional Neural Networks and Long Short-Term Memory (LSTM) networks. CNNs are used to extract spatial features from the video frames, while the LSTM network has the task of capturing the temporal relationships between the frames. This architecture uses the pre-trained VGG19 model for the extraction of spatial features, after which an LSTM layer is applied to process sequential data, which helps achieve high accuracy and fast processing on the Hockey Fight Dataset (Shrief, 2021), Movies Dataset (Bermejo Nievas et al., 2011) and Violent-Flows Dataset (Hassner et al., 2012). A detailed diagram of the implemented architecture can be seen in Section A.1 of the Appendix. Stream ConvLSTM The architecture proposed by Mugunga et al. (2021) implements a stream ConvLSTM network for violence detection from surveillance cameras. This architecture combines strengths from Convolutional Neural Networks and Long Short-Term Memory (LSTM) networks in a way to capture spatial and temporal information in video sequences effectively. Each frame from the data is processed through a pre-trained VGG16 model for feature extraction. The sequences are then handled by three ConvLSTM layers. The outputs from the ConvLSTM layers are concatenated and subsequently passed through a series of fully connected layers (Dense layers) for the final classification of violence. The stream ConvLSTM network aims to enhance the accuracy of violence detection in surveillance videos by taking advantage of spatial and temporal features. A detailed diagram of the implemented architecture can be seen in Section A.3 of the Appendix. 18 C10R1D2 Islam et al. (2021) employed a new architecture, which features a combination of 10 CNN layers, 1 RNN layer, and 2 Dense layers. C10R1D2 is an architecture for violence detection in surveillance videos. The CNN layers extract spatial features from the videos, while the LSTM layer extracts temporal features. A detailed diagram of the implemented architecture can be seen in Section A.4 of the Appendix. 3DCNN The architecture employed by Ding et al. (2014) is a 3D Convolutional Neural Network (CNN) designed for violence detection in video clips. 2D CNNs can easily extract spatial information. By adding a dimension to create a 3D CNN, the convolution can be applied to temporal sequences, allowing for the extraction of motion information from the input videos. The study demonstrated that this architecture outperforms traditional methods by directly operating on raw video data and automatically learning relevant features for violence detection. A detailed diagram of the implemented architecture can be seen in Section A.5 of the Appendix. BiLSTM Gupta and Ali (2022) developed a BiLSTM model for violence detection in videos. It uses a pre-trained VGG16 model to extract features from each frame. These features are then fed into a BiLSTM model, which considers both past and future information to classify the video as violent or nonviolent. The study tested the model on the following datasets: Hockey Fights (Shrief, 2021), Crowd and Violent Flow (Hassner et al., 2012). The study’s results showed that the BiLSTM model achieved higher accuracy compared to a standard LSTM model, especially for the Crowd and Violent Flow dataset. A detailed diagram of the implemented architecture can be seen in Section A.6 of the Appendix. MoveNet with Dense layers The model developed by Kwan-Loo et al. (2022) focuses on detecting violent behavior in videos using a combination of pedestrian detection, tracking, pose estimation, and neural networks. The model first uses YOLOv3, developed by Redmon and Farhadi (2018), to detect pedestrians in each frame of the video. Then, it tracks these pedestrians across frames using the Intersection over Union (IoU) method. This is followed by the implementation of OpenPose to extract the locations of 25 key joints from each pedestrian’s body in each frame. These joint locations are converted into angles to be used as features in the neural network. The model was evaluated on the Kranok-NV dataset, proposed in this paper. The results showed that the model can achieve good accuracy, precision, recall, and F1-score for violence classification. A detailed diagram of the implemented architecture can be seen in Section A.7 of the Appendix. 19 •Arguing •Elbowing •Fighting •Grabbing •Kicking •Punching •Pushing •Slapping •Handshaking •Hugging •Other positive •Talk_left •Talk_right •Talking •Touching The violence categories included within the dataset are designed to be clear and easy to understand. To provide a more comprehensive understanding and a visual reference, example video frames from each category are presented below. (a) Arguing (b) Elbowing (c) Fighting (d) Grabbing (e) Kicking (f) Punching (g) Pushing (h) Slapping Figure 3.3: Violence categories. While the violence categories within the dataset are readily apparent, some nonviolent categories, such as Other positive, might require further clarification. To ensure a comprehensive understanding of the dataset, example video frames representing each category are presented below. 26 (a) Handshaking (b) Hugging (c) Other positive (d) Touching (e) Talk_left (f) Talk_right (g) Talking Figure 3.4: Nonviolence categories. Once the clips were separated between categories, it was time to analyze the data, such as the duration of the clips, the number of clips in each category, and the total duration of each category, among others. The number of frames in a video can be calculated as showed in Equation (3.1). n_frames = 25 ×duration (s)(3.1) The statistics are summarized in Tables 3.2 and 3.3. It is important to note that every interaction is recorded by three different cameras from three different perspectives. For this project, it was decided to treat each view independently, as if they were different scenarios. Therefore, no association was made between videos of the same interaction. Table 3.2: Statistics of the Violent videos. Count Mean Std1Min 25th Pctl2Median 75th Pctl2Max Arguing 60 31.08 36.61 2.16 7.57 11.28 54.77 151.96 Elbowing 12 0.86 0.20 0.60 0.75 0.86 0.97 1.12 Fighting 938 17.15 29.65 0.28 4.76 9.32 16.8 297.20 Grabbing 1 501 8.05 13.37 0.40 1.80 4.04 8.64 160.32 Kicking 583 2.96 5.45 0.32 0.80 1.20 2.68 43.76 Punching 798 3.42 8.33 0.28 0.68 0.92 2.43 67.88 Pushing 2 060 1.98 2.29 0.32 0.80 1.16 2.32 30.40 Slapping 2 161 1.45 4.04 0.16 0.60 0.80 1.32 79.28 1Standard Deviation 2Pctl represents Percentile 27 Table 3.3: Statistics of the Nonviolent videos. Count Mean Std3Min 25th Pctl4Median 75th Pctl4Max Handshaking 33 1.71 0.73 0.84 1.24 1.40 2.08 3.52 Hugging 1 011 5.95 7.48 0.72 2.80 3.96 6.36 79.60 Other positive 3 2.28 0 2.28 2.28 2.28 2.28 2.28 Talk_left 99 2.73 2.82 0.32 0.84 1.64 3.96 13.48 Talk_right 276 11.89 22.05 0.56 1.52 3.84 8.97 109.68 Talking 1 527 36.12 81.50 0.60 7.08 14.44 31.36 1 010.92 Touching 378 8.69 11.61 0.48 1.84 5.40 10.36 76.68 From the data in Tables 3.2 and 3.3, it is evident that the dataset is highly imbalanced between violent and nonviolent videos, as well as between categories. However, knowing the number of clips of each category does not provide sufficient information for making decisions about balancing the dataset. The duration of each clip varies a lot, with interactions ranging from short to long, within the same category or between different categories. Therefore, beyond the number of clips, it is important to consider the duration of each category or the number of frames that comprise it. This provides a more accurate measure of the amount of information each category contains. Tables 3.4 and 3.5 illustrate the discrepancies between the number of clips and the total duration (in seconds) for each category. Table 3.4: Comparison between the number of clips and the number of seconds/frames of Violent videos. No. of clips No. of seconds No. of frames Arguing 60 1 864.92 46 623 Elbowing 12 10.32 258 Fighting 938 16 087.72 402 193 Grabbing 1 501 12 079.68 301 992 Kicking 583 1 721.20 43 180 Punching 798 2 731.76 68 294 Pushing 2 060 4 088.08 102 202 Slapping 2 161 3 130.12 78 253 Table 3.5: Comparison between the number of clips and the number of seconds/frames of Nonviolent videos. No. of clips No. of seconds No. of frames Handshaking 33 56.52 1 413 Hugging 1 011 6 019.80 150 495 Other positive 3 6.84 171 Talk_left 99 270 6 750 Talk_right 276 3 282.96 82 074 Talking 1 527 55 148.72 1 378 719 Touching 378 3 282.97 82 074 3Standard Deviation 4Pctl represents Percentile 28 This comparison provides a new perspective on the actual quantity of data in each category. For example, the category Grabbing (see Table 3.2) has almost the same amount of clips as the category Talking (see Table 3.3). But looking at the total duration of the clips, it is possible to see that Grabbing has approximately 12,000 seconds of data (see Table 3.4), whilst Talking has over 58,000 seconds (see Table 3.5). This means that the average clip length of the category Talking is much higher than that of the category Grabbing, as shown in Tables 3.2 and 3.3. This example shows the importance of looking at the categories’ duration over the number of clips. In the process of cutting the videos, some categories stood out due to their similarities. Categories such as Talk_left and Talk_right were merged into the category Talking to simplify the data, as their content fit well within that category. This change increased the size of the category Talking. The resulting data is summarized in Figures 3.5 and 3.6. Figure 3.5: Number of videos per category, without Talk_left and Talk_right. Figure 3.6: Number of frames of each category, without Talk_left and Talk_right. 29 The discrepancy of the dataset is now clearer, particularly with the category Talking, which has an excessive number of videos comparatively. Additionally, categories such as Elbowing and Other positive have very few videos to represent these actions. 3.4 Data normalization After extracting the clips from the original videos, an inconsistency in the duration and size of the videos was observed. Some clips were as long as 5 minutes, while others didn’t last a whole second. This discrepancy between data can lead to some issues during model training. When this happens, it is necessary to normalize the data to ensure all clips have the same duration. This normalization brings some consistency to the deep learning models and the dataset sizes. Figure 3.7 illustrates the range of video lengths in the dataset. As observable, many clips are no longer than 1 second, and the largest sample of the data has a maximum of 5 seconds of content. Some videos are incredibly long, reaching up to 1,000 seconds, which is equivalent to more than 15 minutes long. This goes to show the inconsistency in the duration of the clips. Figure 3.7: Frequency of video duration, in seconds. To address this inconsistency, the videos were clipped to have the same number of frames. To make this process possible, the MP4 files were converted into NumPy arrays. A .npy file stores a multidimensional array of numerical values. These values represent each pixel of a frame in the video. This technique, supported by Bosch’s Deep Learning Team, transforms the videos into a simplified format. This primitive state allows for easier manipulation, such as reshaping and clipping the video data. Detecting violence using video has the advantage of providing context for the actions, which is not possible with images. Therefore, while clipping the videos, it is important to keep in mind that they need a minimum of information for temporal context. The videos in the dataset were recorded at 25 Frames Per Second (FPS), which is equivalent to having 25 images per second where it is possible to extract information from. Initially, it was considered to keep only some frames from each second of video. However, since many videos were less than one second long - some of them had merely 12 frames -, reducing the number of frames would remove a significant amount of context. In the end, it 30 was decided not to interleave the frames on each video, keeping the 25 FPS characteristic. Considering some of the models that would be tested included LSTMs, it was necessary to choose a common length for all the videos of the dataset. Figure 3.7 illustrates that a significant quantity of the videos is no more than 1 second long. Considering each second of video has 25 frames, choosing a longer clip duration than 1 second could introduce a lot of padding – empty and unnecessary frames – for the shorter videos. For instance, if a 2-second threshold were employed, a video containing 17 frames would need 33 empty frames more, resulting in double the number of empty frames compared to relevant frames. While 1-second long videos might seem short, it’s important to remember that each second contains 25 valuable examples of interaction and context for training purposes. This duration provides sufficient context for understanding most actions within the videos, while also minimizing the need for padding and empty frames, consequently reducing the memory required for processing the information. To ensure dataset homogeneity and facilitate efficient processing and analysis, a decision was made to create a dataset comprised entirely of 1-second video clips. Importantly, all clipped videos retained the labels assigned to their original, unclipped counterpart. Another normalization strategy involves ensuring consistency among the videos and an identical data distribution for each pixel. To achieve this, an operation was performed on all clips to normalize their pixel values. This normalization process adjusts the pixel values to range from 0 to 1 instead of 0 to 255, decreasing the complexity of training the algorithms. 3.5 Building an imbalanced dataset Balanced data is generally preferred when training artificial intelligence algorithms because it reduces the risk of the model becoming biased towards more represented targets in the dataset. It ensures that all classes are trained equally, which leads to a more robust model. However, in some cases, it is not desired to train all classes equally. Sometimes, certain classes may be more important or relevant than others, and in such cases, it may be beneficial to have more samples representing the more important classes. This deliberately creates a bias, which ensures that these classes are trained and learned with more specificity. For the particular problem at hand, imbalanced datasets might be useful. The dataset contains both violent and nonviolent scenarios, each represented by multiple categories. The primary objective of this work is to detect violent scenarios inside vehicles. Therefore, it can be said that, in this case, violent videos are more critical than nonviolent videos. However, nonviolent videos are still necessary so that the model can learn to differentiate between violence and nonviolence, even when the actions appear similar. Within both classes, there is a variety of categories. Some of the categories are situations that occur more often than others. For example, in the class Violence, Elbowing might happen with less frequency than Grabbing. In the Nonviolence class, Touching might happen with less frequency than Talking. The dataset was created with these real-life frequencies in mind. Actions with fewer clips are less likely to happen in real-life situations. Actions with a larger quantity of videos are more likely to happen in real-life scenarios. Therefore, it is pertinent to test the artificial intelligence algorithms with this strategy, allowing them to better learn situations that have a higher probability of happening. By not recurring to data augmentation techniques to balance the dataset, it is possible to save memory and avoid increasing the number of underrepresented classes. This also avoids decreasing the well-represented classes, giving the model more data to learn from the frequent scenarios. Considering this, the quantity of data in the dataset was still too large, especially in the 31 class Talking, and needed to be reduced, all while keeping the same level of imbalance as the original dataset. It was decided to retain only 10% of the videos from each category, cutting all categories equally. This resulted in a more manageable dataset size, as shown in Figure 3.8. Figure 3.9 illustrates the balance of the resulting dataset. Nonviolence is the class with the most videos, reflecting the more frequent occurrence of these events compared to violent ones. Figure 3.8: Count of categories in the imbalanced dataset. Figure 3.9: Balance of classes in the imbalanced dataset. 3.6 Building a balanced dataset Despite an imbalanced dataset being relevant for the task at hand, it is still pertinent to experiment with a balanced dataset to compare results and maximize the probability of an efficient classification model. There is an uneven distribution of clips across both classes (violent and nonviolent) and their corresponding categories. To address this, the dataset was balanced to achieve a near 50/50 ratio between violent and nonviolent clips. 32 This strategy ensures that violence and nonviolence classes are equally represented in the dataset, giving both classes the same attention from the models. However, this technique alone does not account for the different categories within each class. Some categories might be only represented in the test data, for example, preventing the model from training on them. This issue can be solved with stratified data splitting, which is mentioned in Section 3.7. 3.6.1 Undersampling As observed before, there is a significant imbalance in the provided data, with the class Talking being undoubtedly predominant. To address this, Talking was undersampled to match the duration of the next category with the highest duration — Fighting. This resulted in a decrease of approximately 73% in the class Talking. Even after undersampling Talking, there remained a considerable amount of videos for efficient training of the models. The dataset was very complete, however for benchmarking deep learning models, presenting them with such a large amount of data could compromise the project’s time efficiency. With this in mind, it was necessary to cut the dataset even further, including almost all categories of Violence and Nonviolence. Training deep learning algorithms typically requires large quantities of data. The precise amount of what can be considered sufficient is not agreed upon and remains a topic of debate within the field since it depends on data characteristics and the specific architecture being trained. For this study, the Deep Learning Team at Bosch did not impose any restrictions on computational resource utilization. Consequently, a decision was made to limit the number of videos within each category to 4,000 (as illustrated in Figure 3.10). This threshold is a fair middle ground, ensuring adequate representation for categories with both high and low video counts, decreasing the discrepancy between them. Figure 3.10: Count of categories in clipped 1-second videos dataset. After completing this process, the balance of the dataset was analyzed. It was observed that a certain imbalance remained, primarily because almost all categories had the same quantity of videos, but Violence has more categories than Nonviolence. 33 Figure 3.11: Balance of classes in clipped 1-second videos dataset. For this dataset, there were twice as many videos of Violence compared to Nonviolence (Figure 3.11). To achieve a balanced dataset, both classes need to be equally represented, which means an ideal percentage of 50% each. By analyzing the categories of Violence with the most occurrences, it was decided to remove some of their instances. Categories such as Fighting, Grabbing,Pushing, and Slapping were each reduced by 2,500 videos. Additionally, 1,500 videos of Punching were also removed, and when combined, summed up to the approximate amount of videos that needed to be taken out for an equal distribution of the dataset. This removal balanced the dataset, and its results are depicted in Figures 3.12 and 3.13. Figure 3.12: Count of categories in the balanced dataset. 34 Figure 3.13: Balance of classes in the balanced dataset. 3.6.2 Weight distribution One other way of balancing datasets involves assigning weights to the data during the model’s training, without the need to modify the content of the dataset. These weights influence the model’s behavior: they can make the model pay more attention to some data and less to other data. Usually, this is achieved by assigning heavier weight to less represented data and lighter weight to more prevalent data, balancing the dataset during the training process of the algorithm. Weights can be assigned using class weights and/or sample weights. Class weights Class weights are a method for balancing data used in deep learning, where the same weight is applied to data from the same class. In the context of this problem, if class Violence is five times more represented than Nonviolence, a weight of 5 can be assigned to the minority class Nonviolence, and a weight of 1 to the majority class Violence. This approach tells the model that the minority class is more important, making it pay more attention to that class’s data, resulting in a more specified training of the minority class. Sample weights Sample weights follow the same logic as class weights. However, instead of assigning weights to the classes as a whole, they assign a different weight to each sample of the training dataset. This allows for a more fine-grained weighting at the level of individual samples instead of classes. This can be useful for this project since both classes are divided into categories. With sample weights, it is possible to assign a different weight to each category. 3.7 Stratified data split To minimize the probability of data-driven low performance when training deep learning algorithms, a strategy was used to split the data into training, test, and validation datasets while taking into account the different categories within both classes — Violence and Nonviolence. Stratified data splitting ensures that the target variables, which in this case are the categories, have the same final distribution in each of the sets. This guarantees that each category is equally represented in the sets (Igareta, 2021). 35 the final test (Figure 4.7). This frame has the particularity of having both people’s entire bodies visible, but their hands intertwined. What can be observed is that the skeletons of both people were accurately determined, however, the model struggles to recognize their arms and hands when they are touching. Figure 4.7: Implementation of MoveNet with visibility and body member overlap. 4.4.3 PoseNet PoseNet is a top-down approach to pose estimation. This model was tested after analyzing the MoveNet algorithm. It was observed that the detection of keypoints wasn’t as accurate as seen with the MoveNet model. PoseNet detected more keypoints than necessary for the people involved and failed to connect them to form a coherent person. Considering it’s a top-down approach, not connecting the joints may indicate that the algorithm doesn’t successfully detect individuals. Figure 4.8 exemplifies the pose estimation model applied to a certain frame of a video from the given dataset. Figure 4.8: Implementation of PoseNet on a frame. 42 Increasing the brightness and contrast of the frames did not affect the detection of the pose, indicating that lighting isn’t a relevant factor for the misdetection of people by this algorithm. Due to testing PoseNet following MoveNet, the first was quickly discarded given MoveNet’s superior performance. The examples of misdetection of keypoints and their connections aren’t sufficient to conclude that pose estimation may not be useful for violence detection, especially for this dataset. Given the uncertainty surrounding how neural networks process keypoints, it’s still early to dismiss the pose estimation for this violence detection problem based solely on a few examples. Further testing with deep learning architectures is needed to draw more definitive conclusions. However, after evaluating and analyzing the performances of MoveNet and PoseNet, it was decided to proceed to the training phase of the models using MoveNet. The pose estimation model was initially applied to the imbalanced dataset, with the intention of also applying it to the balanced dataset. However, due to time constraints, it was not possible to obtain the keypoints from the videos in the balanced dataset. The shape of the dataset after the implementation of the pose estimation model MoveNet is (25 x 6 x 17 x 3). The tensor captures pose information for a maximum of 6 people in each frame of a video clip with 25 frames, with 17 keypoints describing their body postures. The 3 RGB channels maintain the color information from the original video. 4.5 Benchmarking deep learning models Based on a thorough literature review, the best-performing deep learning models were selected for benchmarking with the provided dataset. The state-of-the-art models chosen due to their superior performance include ConvLSTM using VGG19 (Abdali and Al-Tuma, 2019), stream ConvLSTM (Mugunga et al., 2021), C10R1D2 (Islam et al., 2021), 3DCNN (Ding et al., 2014), BiLSTM (Gupta and Ali, 2022) and MoveNet with Dense layers (Kwan-Loo et al., 2022). Additionally, variations of these architectures were studied in an attempt to improve some models performances. In total, eight models were benchmarked for this problem with this project dataset. Their architectures are succinctly explained in Section 2.6.4. An adaptation made to the architectures from state-of-the-art papers involved returning the model’s output with a Sigmoid function. This function ensures the output is a value between 0 and 1, where 0 indicates Nonviolent and 1 indicates Violent, in this project. Essentially, it represents the probability of the interaction being violent. An important part of the training process of deep learning models is the loss function, as it measures how well the model’s predicted probabilities match the true labels. Monitoring this metric helps evaluate the performance of the model along the training process and understand if there is improvement or decline. The loss function used for this binary classification problem was binary cross-entropy. This loss function penalizes incorrect predictions, especially those that are confident and wrong, and is essential for optimizing model parameters during training so that it generalizes well on unseen data. A loss of 0 represents perfect classifications (Fortuner et al., 2017). The training phase of some models was monitored using a graph illustrating the evolution of Accuracy and loss over the epochs. A decreasing loss indicates progress toward the goal. Increasing accuracy indicates that the values are being classified more correctly. Validation accuracy and validation loss are also used as metrics. These metrics are important for monitoring potential overfitting to the training data. If the training accuracy and loss are comparable to the validation accuracy and loss, the model is not overfitting. However, if the validation accuracy is significantly lower or the validation loss is significantly higher than the training accuracy and loss, it indicates that the model is overfitting to the training data. Ideally, the results 43 should show increasing accuracy and decreasing loss, with validation accuracy and validation loss improving correspondingly. The training of each model was set for 100 epochs, meaning the neural network iterates over the entire training dataset 100 times. This extensive training allows the model to learn and capture complex patterns and relationships in the data, helping it reach convergence, indicating that the model parameters have settled into their optimal values. However, training for too many epochs can lead to overfitting, where the model becomes too adjusted to the training data and performs poorly on unseen data. To prevent overfitting, the Early Stopping technique by Chollet et al. (a) was applied. Early Stopping not only helps avoid overfitting but also reduces computational resources and training time. It works by interrupting the training process when a monitored metric stops improving. For the imbalanced dataset, the monitored metric was the Matthews Correlation Coefficient (MCC). If MCC did not improve by at least 1% over 5 consecutive epochs, the training would stop, as further improvement was unlikely. For the balanced dataset, the monitored metric was the validation loss. If the loss did not decrease by 1% over 5 consecutive epochs, the training would stop. When Early Stopping was triggered, the best weights achieved up to that point were restored. The final results for each model were calculated using the test dataset, rather than the training or validation sets. This approach aims to demonstrate the models’ ability to generalize and perform effectively on unseen data. The initial experiments were conducted using the imbalanced dataset. This approach ensured that all models were trained to reflect the real-life frequency of actions occurring in the real world. Once that initial phase was complete, the model with the best performance on the imbalanced dataset was selected for further training with the balanced dataset. This step aimed to evaluate whether balancing the dataset would lead to any performance improvements, as suspected. The ultimate goal was to train all models on the balanced dataset to ensure a comprehensive evaluation. However, this could not be done within the time available due to the time consumption of training deep learning models. Therefore, only the best-performing model from the initial phase was subjected to additional training with the balanced dataset. This allowed for a focused assessment of the potential benefits of dataset balancing within the limited time available. The library used to train and modify the deep learning architectures was Tensorflow along with the Keras framework, due to their higher-level approach, advice from Bosch’s Deep Learning Team, and documentation available. The project was developed using the Python programming language. 4.5.1 CNN-LSTM with VGG19 The initial attempt to train the CNN-LSTM with VGG19 model was using the imbalanced dataset. The training evolution of the model is illustrated in Figure 4.9, which shows the accuracy improvement and the loss reduction over the epochs. The increasing accuracy aligns with the progression of the loss: higher accuracy means that the values are being classified more correctly. The caption inside the graph explains the following: "acc" represents the accuracy with the train data, "val_acc" represents the accuracy with the validation data, "loss" represents the loss with the train data, and "val_loss" represents the loss with the validation data. The x-axis represents the number of epochs reached until the EarlyStopping triggered. The y-axis represents the decimal equivalent of the percentage for the accuracy. For the loss, it represents its actual value. The same applies to the following graphs of the same type. 44 Figure 4.9: Evolution of Accuracy and loss during the training of CNN-LSTM with VGG19. Figure 4.10 illustrates the frequency of misclassified actions by category. It is possible to observe that Other positive was 100% misclassified, which means that all its videos were classified as Violent despite being Nonviolent. This might have happened due to the small amount of videos that represent that category. More than half of Handshaking, Hugging, and Arguing videos were misclassified. However, the rest of the categories presented a low frequency of misclassification, mainly those with more representation in the dataset. The caption inside the graph explains the following: false positives refer to the Nonviolent videos that were classified as Violent; false negatives refer to the Violent videos that were classified as Nonviolent. The same applies to the following graphs of the same type. Figure 4.10: Misclassification frequency graph by category for CNN-LSTM with VGG19. The performance of the CNN-LSTM with VGG19 model on the imbalanced dataset gave encouraging results in its handling of complex spatiotemporal data. MCC recorded a performance of 72.76%, which can be considerable for imbalanced class distributions. At the same time, the model obtained an Accuracy of 86.35%, Recall of 84.45%, and Precision of 87.79%, which means it could identify enough positive instances while trying to keep the false positive rate low. Besides, the F1-score, at 86.09%, highlighted the balanced performance of the model. 45 4.5.2 CNN-LSTM with ResNet50 To accompany the state-of-the-art models, which state pre-trained models as a feature that enhances the performance of architectures, additional pre-trained models were evaluated. This architecture follows the same structure as CNN-LSTM with VGG19 developed by Abdali and Al-Tuma (2019), with the variation of using deeper ResNet50 instead of VGG19. ResNet50 has a good reputation for feature transferability, so it is pertinent to evaluate the differences in performance. This architecture first uses transfer learning with the pre-trained ResNet50 model for spatial feature extraction, followed by an LSTM layer for sequential data processing. A detailed diagram of the implemented architecture can be seen in Section A.2 of the Appendix. Analysis of Figure 4.11 reveals a high level of misclassifications across several categories. Arguing has a misclassification rate of over 80%. It is also evident that the most frequent categories in the dataset were classified more accurately. According to Figure 3.8, Talking, Fighting, and Grabbing are the categories with the most training examples. These categories have a misclassification rate of at most 20%, as shown in Figure 4.11. Overall, the misclassification frequency was considerably higher than CNN-LSTM with VGG19 model. A possible reason for this could be the overcomplexity of ResNet50 relative to the characteristics of the available data, as well as the specific nature and context of the task. Figure 4.11: Misclassification frequency graph by category for CNN-LSTM with ResNet50. The performance metrics of this model can be found in Table 4.1 alongside those of other models. The results obtained for this architecture are as follows: Accuracy: of 81.74%, Recall of 80.52%, Precision of 82.53%, F1-Score of 81.51%, and MCC of 63.5%. When dealing with imbalanced datasets, the most reliable performance metric is the Matthews Correlation Coefficient (MCC). Its value indicates a strong positive correlation between the model’s classifications and the actual values. 4.5.3 Stream ConvLSTM The structure of this architecture and the number of layers led to a complex training process. This model was built for detecting violence in surveillance cameras, which meets the problem at hand. When analyzing the misclassification of actions by this model, illustrated in Figure 4.12, a notable observation is the high frequency of misclassifications, particularly among Nonviolent actions. These categories share a common trait: they are underrepresented in the dataset. 46 Interestingly, Violent actions, despite having a comparable number of videos, experienced significantly fewer misclassifications. Handshaking,Hugging, and Other positive interactions share a characteristic of physical touch, which occurs naturally in these scenarios. One conclusion that can be drawn is that the model tends to classify interactions involving physical touch as being violent. On the other hand, Arguing does not naturally involve physical contact and is frequently misclassified as Nonviolent. This suggests that the model tends to classify interactions without physical contact as Nonviolent. Figure 4.12: Misclassification frequency graph by category for stream ConvLSTM. Despite these observable misclassifications, the model achieved an Accuracy of 83.24%, MCC of 66.48%, a Recall of 83.43%, a Precision of 83.11%, and an F1-score of 83.27% (these results are also in Table 4.1). Considering Nonviolence is the most prevalent category in the imbalanced dataset, the model’s evaluation indicates a lack of bias toward Violence, contrary to what might be inferred from the misclassification frequency graph in Figure 4.12. 4.5.4 C10R1D2 The number of convolutional layers in this architecture posed a challenge during the training process. Unlike previous architectures that utilized pre-trained models for feature extraction, this model relied on its convolutional layers for spatial feature extraction, followed by an LSTM layer for temporal feature extraction. The misclassification frequency graph in Figure 4.13 reveals a pattern similar to the previous stream ConvLSTM model. Once again, actions such as Handshaking,Hugging,Other positive, and Arguing exhibited numerous misclassifications, with some instances reaching 100%, while other categories remained below the 30% misclassification rate. This suggests a tendency for the model to classify interactions involving physical contact as violent, and vice-versa. 47 Figure 4.13: Misclassification frequency graph by category for C10R1D2. Overall, the performance of this model was not as impressive as previously achieved. It achieved an Accuracy of 79.65%, MCC of 59.31%, Recall of 79.79%, Precision of 79.57%, and F1-score of 79.68%. 4.5.5 3DCNN Figure 4.14 represents the evolution of the Accuracy and loss during the training process of the 3DCNN model. Initially, the loss was significantly high, but it quickly decreased as the model processed the training data. The validation loss turned out to be slightly higher than the training loss, indicating that generalization is not being fully achieved. However, the difference is minimal, and considering the validation accuracy, it does not suggest overfitting. Figure 4.14: Evolution of Accuracy and loss during the training of 3DCNN. The misclassification frequency graph in Figure 4.15 illustrates improved classification in certain categories compared to previous models. Despite Other positive being 100% misclassified, the problematic categories (Handshaking,Hugging, and Arguing) are misclassified by no more than 60%. While this still indicates significant misclassifications, it is an improvement from earlier models. 48 Figure 4.15: Misclassification frequency graph by category for 3DCNN. The results achieved are as follows: Accuracy of 86.1%, MCC of 72.22%, Recall of 84.88%, Precision of 86.99%, and an F1-score of 85.93%. The recall and precision rates indicate an accurate identification of violent instances. The MCC score emphasizes the reliability of the model in handling the imbalanced dataset effectively. These results suggest that although there is room for improvement in the overall accuracy, the model exhibits strong performance. 4.5.6 BiLSTM Figure 4.16 illustrates the evolution of the Accuracy and loss during the training process of the BiLSTM model. The training metrics remained stable throughout, showing a slight increase in accuracy and a slight decrease in loss. The validation metrics followed a similar pattern. Figure 4.16: Evolution of Accuracy and loss during the training of BiLSTM. The misclassification frequency graph in Figure 4.17 once again highlights Handshaking, Hugging,Other positive, and Arguing as problematic categories, similar to previous models. Other positive is 100% misclassified and the others range around 80%. 49 Figure 4.17: Misclassification frequency graph by category for BiLSTM. The performance of the BiLSTM model was as follows: Accuracy of 82.76%, MCC of 65.53%, Precision of 82.52%, Recall of 83.14%, and F1-score of 82.83%. These metrics values reflect the model’s performance in classifying violence with an imbalanced dataset. There is moderate agreement between the classified and true classes, and the accuracy shows the model’s capability to classify videos belonging to different classes. 4.5.7 MoveNet with Dense layers The model proposed by Kwan-Loo et al. (2022) utilized a combination of pedestrian detection, pose estimation, and neural networks. However, during the implementation of the model, due to the project deadline constraints, the object detection algorithm was not applied. Consequently, the neural network was solely fed with pose estimation keypoints. Besides that, the proposed architecture used OpenPose as the pose estimation algorithm, which was not possible in this project. Figure 4.18 represents the evolution of the Accuracy and loss during the training process of the MoveNet with Dense layers model. The metric curves exhibited fluctuations during training but ultimately converged as expected. Accuracy steadily improved across epochs, while loss decreased, reflecting favorable progress. Matthews Correlation Coefficient (MCC) was used as a training metric in this model. Towards the final epoch, there was a slight deviation in MCC between training and validation sets. 50 Figure 4.18: Evolution of Accuracy and loss during the training of MoveNet with Dense layers. Similar to the results observed in previous models, the misclassification frequency graph of the MoveNet with Dense layers model highlights Handshaking,Hugging,Other positive, and Arguing as problematic categories, with misclassification rates exceeding 80%. Additionally, the category Touching has shown an increased misclassification frequency compared to other models. While it never exceeded a 30% rate previously, with this model it reaches 40% of misclassifications. The increase in misclassification frequency for categories involving physical touch suggests that the model is incorrectly classifying nonviolent actions as violent. Similarly, interactions that do not involve physical touch but are violent tend to be misclassified as nonviolent. This could potentially be amplified by inadequacies in the pose estimation algorithm, which may fail to detect poses adequately. It also indicates that the model might not capture sufficient movement and changes in position between frames, necessary to distinguish between violent and nonviolent interactions. Figure 4.19: Misclassification frequency graph by category for MoveNet with Dense layers. With all of this, the performance achieved by this model with the imbalanced dataset was as follows: Accuracy of 78.11%, MCC of 56.54%, Precision of 75.41%, Recall of 83.43%, and an F1-score of 79.22%. These metrics indicate a moderate to substantial agreement between classified and actual values. 51 The initial impression of the dataset involved separating the videos into smaller chunks based on the labeling. The labeling process was not double-checked in this dissertation and was assumed to have been done professionally. However, it is good practice to verify the data, including the video labels. Ensuring accurate labeling became even more critical when separating the videos into 1 second long clips. However costly due to the dataset’s size, this limitation can be addressed in the future. Regarding data preparation, many data augmentation techniques were studied, but there was not enough scope to explore these factors fully. Future work can improve the dataset by including more samples of underrepresented categories using data augmentation strategies, ensuring a better balance between categories of the same class. Although the underrepresentation of some categories did not significantly impact the final classification outcomes—since the models classify actions as Violent or Nonviolent—balancing the dataset remains important considering the achieved results. Some data challenges were primarily observed in the provided dataset, mainly lighting and occlusion. One way of dealing with the lighting is adjusting the brightness and contrast of video frames to achieve clearer images of the interactions. This method was used for the pose estimation algorithm, but it could also be applied to the raw data for training the models in future work. The occlusion is a challenge that does not have a perfect solution. As referred before, each interaction was recorded using three cameras from different perspectives inside the vehicle. One approach to manage occlusion could be to inform the model that the three videos belong to the same interaction; if one camera view has some occlusion, another might capture the interaction. However, in this study, the three perspectives were treated as different interactions. Future work could apply image filters for lighting and integrate the three camera perspectives as one for occlusion. The size of the dataset was incredibly large, with videos at a resolution of 1936x1216 pixels in color. The dataset size was significantly reduced when the resolution changed to 224x224 pixels. However, the pixels remained in color, with three RGB channels. Further size reduction could be achieved by converting the videos to black and white, reducing each pixel by one channel and possibly improve contrast. When constructing the different datasets, balanced and imbalanced, insufficient attention was given to comparing them in terms of the number of examples allocated for training, testing, and validation. When the balanced dataset was split, it resulted in a training set with over 16 thousand instances, whereas the imbalanced dataset only contained just over 8 thousand examples for training, approximately half the size in comparison. This discrepancy also applied to the test and validation sets. This oversight likely influenced the performance results of the models when trained with the imbalanced dataset. Lighting and occlusion were what probably influenced the most the performance of the pose estimation algorithm, along with the angle, as legs were not always visible. It is possible that the misdetection of people could be mitigated with the use of an object detection algorithm, by applying bounding boxes around each person, reducing the image size for pose estimation. Although only one pose estimation algorithm was benchmarked in this study due to time constraints, future work could include other algorithms, such as PoseNet or OpenPose, addressing the issues of the installation. The only state-of-the-art architecture for violence detection analyzed that used pose estimation also incorporated an object detection algorithm to aid in identifying people in the frames, thereby facilitating the pose estimation process. Due to time constraints, object detection was not implemented in this dissertation. However, for future work, implementing an object detection model could enhance the accuracy of pose estimation, especially given the poor performance observed with the provided dataset. 58 Model training was well-conceived for the imbalanced dataset. However, the balanced dataset lacks attention and should have been used with all architectures as well as it showed promising results. The prospect of having a naturally imbalanced dataset to help the model be prepared for real-world scenarios overshadowed the use of a balanced dataset. This can be addressed in future work by training the models with the balanced dataset for a more accurate benchmarking on the balanced data. Unfortunately, this process was not feasible without Bosch’s computational resources. When selecting the model that performed best on the imbalanced dataset, the criteria used were the metric scores: the model with the highest set of metrics was considered the bestperforming model. However, the misclassification frequency graph of the models’ classifications was not regarded in this decision. Upon comparing the metrics and the misclassification graph of CNN-LSTM with VGG19 to those of 3DCNN, it is evident that the performance is very similar between the two models, with 3DCNN’s misclassification graph showing better results overall. Considering the similarity of the metrics, 3DCNN was also a strong contender. When evaluating the best-performing model on the balanced dataset, the metrics used were not entirely consistent with those used for the imbalanced dataset. While the Matthews Correlation Coefficient (MCC) is particularly useful for assessing classification balance in imbalanced datasets, it remains relevant for the balanced dataset, especially when comparing performance between the two. Future work could explore the calculation of this metric during model training with the balanced dataset to gain a comprehensive understanding of performance balance. The training of the state-of-the-art models mainly involved applying the provided dataset to various architectures. Minimal attention was given to hyperparameter tuning such as learning rate and batch size, as this was not the focus of the dissertation. For future work, it would be interesting to tune hyperparameters to achieve optimal results for the models. However, within the scope of this dissertation, detailed hyperparameter tuning was not essential, as it was unlikely to significantly alter the outcome and comparison of the models. After model training, an analysis of the results was conducted. For the imbalanced dataset, a possible approach to improve results would be to increase the sample size for each category in both classes, particularly in Nonviolence, which had many false positives. This issue may be due to the natural physical interactions present in some nonviolent categories. Regarding the balanced dataset, improvements can include augmenting the more misclassified actions. Lastly, additional models could enhance the benchmarking process. Transformers are gaining significance in the deep learning community. Although more commonly applied to textual data, they can be effective with computer vision and video-based datasets. Recent studies indicate that transformer-based models look promising for video-based tasks. 59 60 References Abdali, A.-M. R. and Al-Tuma, R. F. (2019). Robust Real-Time Violence Detection in Video Using CNN And LSTM. In 2019 2nd Scientific Conference of Computer Sciences (SCCS), pages 104–108. DOI 10.1109/SCCS.2019.8852616. Almoqbel, M. Y. and Wohn, D. Y. (2019). Individual and Collaborative Behaviors of Rideshare Drivers in Protecting their Safety. Proc. ACM Hum.-Comput. Interact., 3(CSCW). DOI 10.1145/3359319. Amidi, A. and Amidi, S. (2021). A detailed example of how to use data generators with Keras. URL https://stanford.edu/~shervine/blog/keras-how-to-generate-data- on-the-fly. Accessed 2024-07-31. Bermejo Nievas, E., Deniz Suarez, O., Bueno García, G., and Sukthankar, R. (2011). Violence Detection in Video Using Computer Vision Techniques. In Real, P., Diaz-Pernil, D., Molina-Abril, H., Berciano, A., and Kropatsch, W., editors, Computer Analysis of Images and Patterns, pages 332–339. Springer Berlin Heidelberg. DOI 10.1007/978-3-642-23678-5_39. Bhavika Panara, I. I. (2021). Comparing MoveNet to PoseNet for Person Fall Detection. URL https://blog.ambianic.ai/2021/09/02/movenet-vs-posenet-person-fall- detection.html. Accessed 2024-07-31. Boesch, G. (2021). Very Deep Convolutional Networks (VGG) Essential Guide. URL https: //viso.ai/deep-learning/vgg-very-deep-convolutional-networks/. Accessed 2024- 07-31. Boesch, G. (2023). Deep Residual Networks (ResNet, ResNet-50) – 2024 Guide. URL https: //viso.ai/deep-learning/resnet-residual-neural-network/. Accessed 2024-07-31. Bosch (2024a). Artificial intelligence meets domain knowledge. URL https://www.bosch. com/research/research-fields/artificial-intelligence/. Accessed 2024-07-31. Bosch (2024b). Multi purpose camera. URL https://www.bosch-mobility.com/en/ solutions/camera/multi-purpose-camera/. Accessed 2024-07-31. Bosch (2024c). Our Legacy in Automotive. URL https://www.boschautoservice.com/ about-us/bosch-history.html. Accessed 2024-07-31. Bosch (2024d). Safety for all road users. URL https://www.bosch-mobility.com/en/ mobility-topics/safety-for-all-road-users/. Accessed 2024-07-31. Cambridge Dictionary (2024). Definition of violence from the Cambridge Advanced Learner’s Dictionary & Thesaurus. URL https://dictionary.cambridge.org/dictionary/ english/violence. Accessed 2024-07-31. 61 Cao, Z., Hidalgo, G., Simon, T., Wei, S.-E., and Sheikh, Y. (2021). OpenPose: Realtime Multi-Person 2D Pose Estimation Using Part Affinity Fields. IEEE Transactions on Pattern Analysis and Machine Intelligence, 43(1):172–186. DOI 10.1109/TPAMI.2019.2929257. Chicco, D. and Jurman, G. (2020). The advantages of the Matthews correlation coefficient (MCC) over F1 score and accuracy in binary classification evaluation. BMC Genomics, 21(1):6. DOI 10.1186/s12864-019-6413-7. Chollet, F. et al. Keras EarlyStopping Callback. URL https://keras.io/api/callbacks/ early_stopping/. Accessed 2024-07-31. Chollet, F. et al. Keras Masking Layer. URL https://keras.io/api/layers/core_layers/ masking/. Accessed 2024-07-31. Deng, J., Dong, W., Socher, R., Li, L.-J., Li, K., and Fei-Fei, L. (2009). Imagenet: A largescale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pages 248–255. Ieee. DOI 10.1109/CVPR.2009.5206848. Ding, C., Fan, S., Zhu, M., Weiguo, F., and Jia, B. (2014). Violence Detection in Video by Using 3D Convolutional Neural Networks. volume 8888, pages 551–558. DOI 10.1007/978- 3-319-14364-4_53. Fortuner, B. et al. (2017). Loss Functions — ML Glossary documentation. URL https://mlcheatsheet.readthedocs.io/en/latest/loss_functions.html. Accessed 2024-07-25. Government of Newfoundland and Labrador (2014). Nine Types of Violence and Abuse. URL https://www.gov.nl.ca/vpi/files/nine_types_of_violence.pdf. Accessed 2024-07-31. Government of Québec (2022). Forms of violence. URL https://www.quebec.ca/en/family- and-support-for-individuals/violence/forms-violence. Accessed 2024-07-31. Gupta, H. and Ali, S. T. (2022). Violence Detection using Deep Learning Techniques. In 2022 International Conference on Emerging Techniques in Computational Intelligence (ICETCI), pages 121–124. DOI 10.1109/ICETCI55171.2022.9921388. Hassner, T., Itcher, Y., and Kliper-Gross, O. (2012). Violent flows: Real-time detection of violent crowd behavior. In 2012 IEEE Computer Society Conference on Computer Vision and Pattern Recognition Workshops, pages 1–6. DOI 10.1109/CVPRW.2012.6239348. Huang, G., Liu, Z., van der Maaten, L., and Weinberger, K. (2017). Densely Connected Convolutional Networks. DOI 10.1109/CVPR.2017.243. Igareta, A. (2021). Stratified Sampling: You May Have Been Splitting Your Dataset All Wrong. URL https://towardsdatascience.com/stratified-sampling-you-may-have- been-splitting-your-dataset-all-wrong-8cfdd0d32502. Accessed 2024-07-31. Islam, M. S., Hasan, M. M., Abdullah, S., Akbar, J. U. M., Arafat, N. H. M., and Murad, S. A. (2021). A deep Spatio-temporal network for vision-based sexual harassment detection. In 2021 Emerging Technology in Computing, Communication and Electronics (ETCCE), pages 1–6. DOI 10.1109/ETCCE54784.2021.9689891. Kaur, G. and Singh, S. (2022). Violence Detection in Videos Using Deep Learning: A Survey. In Goar, V., Kuri, M., Kumar, R., and Senjyu, T., editors, Advances in Information Communication Technology and Computing, pages 165–173. Springer Nature Singapore. DOI 10.1007/978-981-19-0619-0_15. 62 Krug, E. G., Mercy, J. A., Dahlberg, L. L., and Zwi, A. B. (2002). The world report on violence and health. The Lancet, 360(9339):1083–1088. DOI 10.1016/S0140-6736(02)11133-0. Kwan-Loo, K. B., Ortíz-Bayliss, J. C., Conant-Pablos, S. E., Terashima-Marín, H., and Rad, P. (2022). Detection of Behavior Using Neural Networks and Pose Estimation. IEEE Access, 10:86339–86352. DOI 10.1109/ACCESS.2022.3198985. Luckow, A., Cook, M., Ashcraft, N., Weill, E., Djerekarov, E., and Vorster, B. (2016). Deep learning in the automotive industry: Applications and tools. In 2016 IEEE International Conference on Big Data (Big Data), pages 3759–3768. DOI 10.1109/BigData.2016.7841045. Menendez, C. C. and Morgantown, D. E. (2019). NIOSH Fast Facts Taxi Drivers How to Prevent Robbery and Violence. DOI 10.26616/NIOSHPUB2020100. Mugunga, I., Dong, J., Rigall, E., Guo, S., Madessa, A. H., and Nawaz, H. S. (2021). A Frame- Based Feature Model for Violence Detection from Surveillance Cameras Using ConvLSTM Network. In 2021 6th International Conference on Image, Vision and Computing (ICIVC), pages 55–60. DOI 10.1109/ICIVC52351.2021.9526948. MulticoreWare (2021). What is driver monitoring system? URL https://multicorewareinc. com/what-is-driver-monitoring-system/. Accessed 2024-07-31. Quitugua, C. (2022). The Evolution of Vehicle Safety. URL https://www.clarkfountain. com/blog/the-evolution-of-vehicle-safety/. Accessed 2024-07-31. Ramzan, M., Abid, A., Khan, H. U., Awan, S. M., Ismail, A., Ahmed, M., Ilyas, M., and Mahmood, A. (2019). A Review on State-of-the-Art Violence Detection Techniques. IEEE Access, 7:107560–107575. DOI 10.1109/ACCESS.2019.2932114. Redmon, J. and Farhadi, A. (2018). YOLOv3: An Incremental Improvement. arXiv. DOI 10.48550/arXiv.1804.02767. Rutherford, A., Zwi, A. B., Grove, N. J., , and Butchart, A. (2007). Violence: a glossary. Journal of Epidemiology and Community Health, 61(8):676–680. DOI 10.1136/jech.2005.043711. SaferSpaces (2016). What is violence? URL https://www.saferspaces.org.za/understand/ entry/what-is-violence. Accessed 2024-07-31. Shah, D. S., Govindraj, S., and Omkar, S. (2021). Real-time Violence Activity Detection Using Deep Neural Networks in a CCTV camera. In 2021 IEEE International Conference on Electronics, Computing and Communication Technologies (CONECCT), pages 1–6. DOI 10.1109/CONECCT52877.2021.9622739. Shahinfar, S., Meek, P., and Falzon, G. (2020). “How many images do I need?” Understanding how sample size per class affects deep learning model performance metrics for balanced designs in autonomous wildlife monitoring. Ecological Informatics, 57:101085. DOI 10.1016/j.ecoinf.2020.101085. Shi, X., Chen, Z., Wang, H., Yeung, D.-Y., kin Wong, W., and chun Woo, W. (2015). Convolutional LSTM Network: A Machine Learning Approach for Precipitation Nowcasting. DOI 10.48550/arXiv.1506.04214. Shrief, Y. (2021). Hockey Fight Vidoes. URL https://www.kaggle.com/datasets/ yassershrief/hockey-fight-vidoes. Accessed 2024-07-31. 63 Simonyan, K. and Zisserman, A. (2015). Very Deep Convolutional Networks for Large-Scale Image Recognition. DOI 10.48550/arXiv.1409.1556. Tensorflow (2022). MoveNet. URL https://github.com/tensorflow/tfjs-models/tree/ master/pose-detection/src/movenet. Accessed 2024-07-31. UNECE (2022). World Forum for Harmonization of Vehicle Regulations (WP.29). URL https://unece.org/transport/vehicle-regulations/world-forum-harmonization- vehicle-regulations-wp29. Accessed 2024-07-31. World Health Organization (1996). Violence: A Public Health Priority. World Health Organization. Yosinski, J., Clune, J., Bengio, Y., and Lipson, H. (2014). How transferable are features in deep neural networks? DOI 10.48550/ARXIV.1411.1792. Zhou, L. (2022). End-to-End Video Violence Detection with Transformer. In 2022 5th International Conference on Pattern Recognition and Artificial Intelligence (PRAI), pages 880–884. DOI 10.1109/PRAI55851.2022.9904115. Zhu, Y., Li, X., Liu, C., Zolfaghari, M., Xiong, Y., Wu, C., Zhang, Z., Tighe, J., Manmatha, R., and Li, M. (2020). A Comprehensive Study of Deep Video Action Recognition. DOI 10.48550/arXiv.2012.06567. 64 A Model architectures A.1 CNN-LSTM with VGG19 Figure A.1: CNN-LSTM with VGG19 architecture. 65 A.2 CNN-LSTM with ResNet50 Figure A.2: CNN-LSTM with ResNet50 architecture. 66 A.3 Stream ConvLSTM Figure A.3: Stream ConvLSTM architecture. 67