1. Trang chủ
  2. » Luận Văn - Báo Cáo

(Đồ án hcmute) application of image processing in the identification of people falling

73 1 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Application image processing in the identification of people falling
Tác giả Pham Duc Thien, Tran Dai Loc
Người hướng dẫn PhD. Vu Van Phong
Trường học Ho Chi Minh City University of Technology and Education
Chuyên ngành Automation and Control Engineering
Thể loại Đồ án
Năm xuất bản 2023
Thành phố Ho Chi Minh City
Định dạng
Số trang 73
Dung lượng 3,6 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Cấu trúc

  • Chapter 1: INTRODUCTION (14)
    • 1.1. Problem Statement (14)
    • 1.2. Objective (0)
    • 1.3. Constraints (0)
    • 1.4. Jobs to do (0)
    • 1.5. Plan (0)
    • 1.6. Estimated Expense (0)
  • Chapter 2: LITERATURE REVIEW (18)
    • 2.1 Introduction (18)
    • 2.2 System review (19)
    • 2.3 GAUSSIAN FILTER (19)
      • 2.3.1 PROCESS TO APPLY A GAUSS FILTER (19)
      • 2.3.2 Fourier Spectrum- Quick Refresh (20)
      • 2.3.3 Filtering (20)
      • 2.3.4 Gaussian Filter (21)
      • 2.3.5 Gaussian Filter and low pass filtering (21)
    • 2.4 Gaussian blurring (21)
      • 2.4.1 When to use Gaussian blur (21)
      • 2.4.2 The aspects of a Gaussian blur filter (22)
      • 2.4.3 How Gaussian blur works in image filtering (22)
    • 2.5 SOFTWARE (22)
      • 2.5.1 RASPBERRY PI (22)
      • 2.5.2 PYTHON (24)
  • Chapter 3: HARDWARE DESIGN (27)
    • 3.1 System Requirement (27)
    • 3.2 System Design (27)
    • 3.3 Device Selection (27)
      • 3.3.1 Raspberry Pi 4 (27)
      • 3.3.2 C920s PRO HD WEBCAM (30)
    • 3.4 Algorithm Flowchart (32)
  • Chapter 4: METHODOLOGY (34)
    • 4.1 System Overview (34)
    • 4.2 OpenCV (34)
    • 4.3 Method (35)
    • 4.4 Function in code (37)
    • 4.5 Image Progessing- Smoothing (40)
    • 4.6 Gaussianblur (41)
    • 4.7 Threshold (43)
    • 4.8 Morphological Processing (45)
      • 4.8.1 Morphology Introduction (45)
      • 4.8.2 Morphological Transformation (45)
    • 4.9 Contours (49)
    • 4.10 Application System (51)
    • 4.11 Python HTTP Server (53)
  • Chapter 5: EXPERIMENT RESULTS/ FINDINGS AND ANALYSIS (56)
    • 5.1 Hardware Result (56)
    • 5.2 Testing Result (57)
  • Chapter 6: CONCLUSION AND RECOMMENDATIONS (64)
    • 6.1 Conclusion (64)
    • 6.2 Future works (64)
  • References 52 (65)

Nội dung

INTRODUCTION

Problem Statement

Frequent or accidental falls can lead to serious injuries or fatalities, especially among the elderly population The table below illustrates the percentage of older adults who are hospitalized following a fall.

Figure 1.1.1Among geriatric and adult patients hospitalized for the treatment of trauma injuries, the etiology of trauma [1]

Recent studies on fall prevention are gaining significant attention, leveraging image processing technology to monitor individuals in specific areas These advanced systems can detect behaviors indicative of a potential fall, allowing for early alerts to tracking devices like smartphones This timely notification enables loved ones to respond quickly, reducing the risk of injury and enhancing safety for individuals at risk of falling.

Design a system to monitor sudden falls in the elderly continuously

Design a tracking application to be installed on a family member's smartphone so that they can receive direct and earliest notifications when an incident occurs

The system design can monitor in a variety of environmental conditions to ensure over 80% accuracy in fall diagnosis

This study is limited to utilizing a single camera for monitoring the elderly, focusing solely on a fixed area Additionally, tracking effectiveness is compromised in poorly lit environments.

The algorithm faces limitations, particularly its inability to compare frames against each other instead of just the initial frame, resulting in significant noise when assessing similar frames Enhancing the outcomes could be achieved by implementing additional noise-reduction strategies Furthermore, the algorithm necessitates a full view of the human body, making it ineffective in occluded scenarios To overcome this challenge, installing an additional camera in obstructed areas may be required.

It compares the subsequent frames to the initial frame, which is another drawback

The algorithm's performance relies on the initial frame being empty to accurately display all contours Although it has not been tested in environments with multiple individuals, our research indicates that no warnings would be required.

Fix bugs and perfect the pro

No Jobs to do People W1 W2 W3 W4 W5 W6 W7 W8 W9 W10 W11 W12 W13 W14 W15

2 Simulate system in laptop Lộc

6 Fix bugs and perfect the product Lộc,

No List of things Cost

Parts for raspberry 700.000 vnd 3.Tools Courses for program 400.000 vnd

LITERATURE REVIEW

Introduction

Falls are a prevalent issue among children and the elderly, often resulting from body imbalances or organ function decline In older adults, these falls can lead to serious injuries, particularly due to age-related conditions like calcium deficiency, which can cause sudden fractures, posing greater risks than heart or brain issues Numerous studies have explored the epidemiology of falls in older populations, highlighting the complications arising from aging diseases Current methods for detecting falls include technologies such as Children Location Monitoring Systems (CLMS), Vehicle Tracking Devices (VTD), and student tracking systems This paper introduces a novel approach for human fall detection utilizing pose estimation tools to monitor sudden positional changes within brief timeframes.

Fall detection studies utilize single sensor and sensor fusion techniques, which can be categorized into four main types: individual wearable sensors, individual ocular sensors, individual ambient sensors, and data fusion through sensor networks Although some research merges visual and environmental sensors, this survey treats them as separate categories due to the increasing prevalence of visual sensors, particularly with the advent of depth cameras (RGBD) like the Kinect.

Falls can trigger significant physiological changes in the human body, which can serve as criteria for detecting such incidents Various sensors, including accelerometers, gyroscopes, glucometers, pressure sensors, ECG, EEG, and EOG, are effective tools for measuring different bodily functions.

Traditional health monitoring for the elderly often relies on wearable tracking devices, which require battery charging and additional human assistance However, recent advancements in camera technology and image processing now enable monitoring of abnormal fall behavior using just a smartphone With strategically placed cameras in the home, elderly individuals can be continuously monitored, and relatives will receive immediate notifications in the event of a sudden fall, enhancing safety and reducing the need for constant human oversight.

System review

In the past decade, advancements in computer vision have led to the widespread adoption of image-based strategies in drop discovery systems These systems typically utilize three main approaches: single-camera imaging, 3D inspections with multiple cameras, and 3D analysis combining multiple cameras with individual sensors The algorithms used in these systems track object movement by placing ovals around the target and analyzing its trajectory over continuous contours, allowing them to identify changes in the ellipse's evolution and differentiate between the moments before, during, and after a drop incident Furthermore, multi-frame parallelism techniques are employed to enhance computational speed and ensure real-time responsiveness.

GAUSSIAN FILTER

A Gaussian Channel is a low-pass filter used to reduce noise, particularly high-frequency components, and blur areas in an image It is implemented as an odd-sized symmetric kernel applied to each pixel in the region of interest, ensuring that pixels near the center have more influence on the final value than those at the edges This makes the filter less sensitive to abrupt color changes, or edges Essentially, a Gaussian Channel serves as an approximation of the Gaussian function in mathematics In this article, we will explore methods for utilizing the Gaussian Channel to effectively reduce noise in images using the Python programming language.

2.3.1 PROCESS TO APPLY A GAUSS FILTER

To effectively utilize the Gaussian Channel for image processing, we first define the size of the Kernel/Matrix that will be used for image smoothing Typically, these sizes are odd numbers, allowing the outcome to be computed based on the central pixel Additionally, the matrix is symmetric, ensuring an equal number of rows and columns The values within the matrix are calculated using the Gaussian function.

Figure 2.3.1Two Dimensional gaussian function

The Gaussian function can be utilized to calculate a Gaussian bit of any measure by assigning appropriate values For instance, a 3×3 Gaussian Part Approximation in two dimensions, with a standard deviation of 1, is represented as follows: [7]

The Fourier range represents a visual representation of the original image that requires filtering, where each pixel corresponds to a two-dimensional sinusoid of a specific frequency These sinusoids are directly related to the components of the image's Fourier transform.

In the Fourier Range, the area of the pixel (the x, y coordinates) speaks to the frequencies of the 2-dimensional sinusoids to which that pixel compares to The ‘whiteness’ or the

The darkness of a pixel reflects the amplitude of the two-dimensional sinusoid it represents, indicating that a pixel appears 'whiter' when the sinusoid's sufficiency is higher.

Sifting can be understood as a process that selectively removes frequency components from an image based on specific filter criteria A low-pass filter eliminates high-frequency elements, such as edges, while a high-pass filter removes low-frequency components, which correspond to gradual changes within the image The impact of filtering is evident in the Fourier spectrum, where pixels associated with the filtered frequencies are 'blackened' out, illustrating the effect visually.

Gaussian filters are perfect to begin testing with sifting since their plan can be controlled by controlling fair one variable- the variance

The esteem of the sigma (the change) compares conversely to the sum of sifting, littler values of sigma imply more frequencies are smothered and bad habit versa

The Gaussian channel can be likened to a cap being squeezed on a sponge; a wider cap, shaped like a Gaussian, compresses less of the sponge and allows more of it to remain uncompressed, while a tighter cap compresses more of the sponge.

2.3.5 Gaussian Filter and low pass filtering

Low pass filtering as the title recommends, is almost filtering such that 'Low frequencies' continuously pass or are uncompressed by the filter

The size of the filter determines the level of filtration, while the Gaussian filter, due to its shape, consistently allows the area surrounding the center to pass through without compression.

The Fourier Range highlights the low-frequency components of an image, where a Gaussian filter effectively removes these unfiltered frequencies Low-frequency components are associated with gradual changes in an image, while high-frequency components correspond to sharp edges Consequently, applying a Gaussian filter blurs the image by eliminating its sharp edges.

Gaussian blurring

Gaussian blur, named after mathematician Carl Friedrich Gauss, is a technique used in image processing to soften an image by applying a low-pass filter As photographer Kenton Waltz explains, it’s akin to placing a translucent layer over the image, which helps to smooth out irregular pixel values and reduce noise This method effectively minimizes sharp edges and details, resulting in a more visually pleasing appearance.

2.4.1 When to use Gaussian blur

Photographers and architects often utilize Gaussian blur for various purposes It can effectively reduce noise in low-light photos, enhancing the overall quality of the image Additionally, applying Gaussian blur can soften a background, allowing overlaid text to stand out more prominently This technique is also beneficial in minimizing chromatic aberration, which manifests as colored fringes along high-contrast edges For instance, in landscape photography featuring distant palm trees against a light-blue sky, Gaussian blur can help eliminate distracting highlights.

9 lines along the edges of your palm fronds Applying a Gaussian obscure will diminish the amazingly shining pixels around the edge of the fronds, killing those shining spots.[9]

2.4.2 The aspects of a Gaussian blur filter

Adjusting the channel's standard deviation directly influences the results, as it determines the dispersion of data around the mean A larger standard deviation results in a wider bell curve, indicating that the data set is more spread out from the mean Conversely, a smaller standard deviation signifies a tighter distribution A significant standard deviation typically corresponds to a larger channel size, suggesting that variations within the channel will be more pronounced.

2.4.3 How Gaussian blur works in image filtering

Gaussian blur prioritizes the pixels nearest to the center of an image, assigning them greater weight compared to those further away The reduction in weight follows a Gaussian function, which is the basis for the term "Gaussian blur."

The shape of a Gaussian curve is determined by its standard deviation (sigma), where a larger sigma results in a flatter curve and a smaller sigma creates a sharper peak Although the mathematics of the Gaussian filter can be complex, this basic understanding captures its essential characteristics.

SOFTWARE

Raspberry pi 4 may be a small computer utilizing the Linux working framework Usually a little computer leveraged to run huge programs to yield signals quickly

Raspberry Pi 4 B+ (RP4) is the final show created by the company, featuring all the most recent wired and remote communication frameworks required for utilization in most shrewd control projects

The Raspberry Pi 4 features a powerful 4-core processor and is available in three different configurations with varying amounts of RAM It utilizes mini HDMI ports and supports dual 4K display outputs, enhancing its versatility for various applications.

Which Raspberry Pi models have been released?

The Raspberry Pi has evolved through four distinct eras: Pi 1, Pi 2, Pi 3, and Pi 4, typically featuring a Model A and a Model B in each generation The Model A is a cost-effective version with reduced RAM and fewer ports such as USB and Ethernet Additionally, the Pi Zero, a smaller and more affordable variant, is a derivative of the original Pi 1 generation.

Figure 2.5.2 Some types of Raspberry Pi [14]

In March 2021, LinuxHint published an article speculating on potential features of the upcoming Raspberry Pi 5, drawing insights from recently released hardware specifications, guides, and technical challenges faced by earlier Raspberry Pi versions.

Python is a versatile programming language widely used for web development, automation, and data analysis As a general-purpose language, it can create a variety of applications and is not limited to specific problems Its flexibility and ease of use have contributed to its status as one of the most popular programming languages today.

A study conducted by industry examiner firm RedMonk found that it was the second-most well known programming dialect among designers in 2021 [15]

What is Python utilized for?

Python is widely utilized for web development, software programming, automation of tasks, data analysis, and data visualization Its ease of learning has made it popular among non-programmers, including accountants and researchers, who use it for various everyday tasks, such as managing finances.

Here’s a closer see at a few of these common ways Python is used:

Data examination and machine learning

Python has become essential in data science, enabling data analysts and professionals to perform complex statistical calculations, create data visualizations, develop machine learning algorithms, and manipulate and analyze data effectively.

Python offers a diverse range of data visualizations, including line charts, bar charts, pie charts, histograms, and 3D plots It also provides several libraries, such as TensorFlow and Keras, that enable developers to write programs for data analysis and machine learning more quickly and efficiently.

Python is frequently used for backend development in websites and applications, handling server communication, data processing, database interaction, URL routing, and security measures It provides various frameworks for web development, with Django and Flask being among the most popular Job roles that commonly involve Python include backend developers, full stack developers, Python developers, software engineers, and DevOps engineers.

On the off chance that you discover yourself performing an assignment over and over, you may work more proficiently by robotizing it with Python Composing code utilized to

Scripting is essential for constructing mechanized processes, as it enables automation in various tasks such as error checking across multiple documents, data conversion, performing basic calculations, and removing duplicates in datasets.

Python is an excellent tool for beginners to automate simple tasks on their computers, including renaming files, retrieving online content, and scheduling emails or text messages at desired intervals.

Python plays a crucial role in software development by facilitating tasks such as build management, bug tracking, and testing It enables developers to automate the testing process for new features or products Notable Python tools for software testing include Green and Requestium.

Python is not just for software engineers and data scientists; it offers new opportunities for individuals in less data-intensive professions, such as writers, small business owners, and social media marketers Learning Python can help non-programmers streamline various tasks in their daily lives Here are some tasks you can automate with Python:

 Keep track of stock showcase or crypto prices

 Send yourself a content update to carry an umbrella anytime it's raining

 Update your basic supply shopping list

 Renaming huge clumps of files

 Converting content records to spreadsheets

 Randomly allot chores to family members

 Fill out online shapes naturally

Why is Python so popular?

Python is well known for a number of reasons Here’s a more profound see at what makes it so flexible and simple to utilize for coders

The article uses clear and simple language that reflects everyday speech, making it easy to read and understand This approach facilitates quicker project development and accelerates progress on tasks.

 It's flexible Python can be utilized for numerous diverse errands, from web improvement to machine learning

 It's apprentice inviting, making it prevalent for entry-level coders

 It’s open source, which suggests it’s free to utilize and disperse, indeed for commercial purposes

 Python's chronicle of modules and libraries—bundles of code that third-party clients have made to extend Python's capabilities—is tremendous and growing

Python boasts a vibrant and dynamic community that enriches its extensive collection of modules and libraries, providing invaluable support to software engineers This robust community ensures that developers can easily find solutions when they encounter challenges in their coding journey.

 Easy-to-learn − Python has few watchwords, straightforward structure, and a clearly extended language structure This permits the understudy to choose up the dialect quickly

 Easy-to-read − Python code is more clearly used and obvious to the eyes

 Easy-to-maintain − Python's source code is decently easy-to-maintain

 A wide standard library − Python's bulk of the library is exceptionally versatile and cross-platform consistent on UNIX, Windows, and Macintosh

 Interactive Mode − Python has bolster for an intelligently mode which permits intuitively testing and investigating of scraps of code

 Portable − Python can run on a wide assortment of equipment stages and has the same interface on all platforms

 Extendable − You'll include low-level modules to the Python mediator These modules empower software engineers to include to or customize their instruments to be more efficient

 Databases − Python gives interfacing to all major commercial databases

Python supports GUI programming, enabling the development and portability of applications across various frameworks and operating systems, including Windows MFC, Mac, and the Unix X Window system.

 Scalable − Python gives distant better;a much better;a higher;a stronger;an improved">a distant better structure and back for expansion programs than shell scripting

HARDWARE DESIGN

System Requirement

A basic fall detection model was implemented using a camera, taking into account several critical factors to ensure the system operates effectively The system must meet specific requirements to function properly.

 Can identify and distinguish individuals falling

 Can send notices through the app

System Design

Once begun, the framework will record pictures of individuals in run and track signals so that falls can be anticipated early and alarms are sent through the app.

Device Selection

For this project, various computer boards like Jetson Nano and Raspberry Pi are suitable options The Jetson Nano, equipped with a GPU, seamlessly integrates with NVIDIA's top-tier AI platform, simplifying the development and deployment of AI applications for engineers In contrast, the Raspberry Pi is ideal for non-training AI tasks and is compatible with multiple operating systems, including Windows and Linux, making it a more popular choice among users.

Raspberry Pi 4 Demonstrate B is the most recent item within the prevalent Raspberry

The Raspberry Pi 4 Model B delivers significant enhancements in processor speed, multimedia performance, memory, and connectivity compared to its predecessor, the Raspberry Pi 3 Model B+, while maintaining backward compatibility and similar power consumption For end users, it offers desktop performance comparable to entry-level x86 PC systems.

This product features a powerful 64-bit quad-core processor and supports dual displays with resolutions up to 4K through two micro-HDMI ports It offers hardware video decoding at 4Kp60, up to 8GB of RAM, dual-band 2.4/5.0 GHz Wi-Fi, Bluetooth 5.0, Gigabit Ethernet, USB 3.0, and Power over Ethernet (PoE) capability with an optional PoE Cap add-on.

Table 3.1 Specification of Raspberry Pi

PROCESSOR: Broadcom BCM2711, quad-core Cortex-A72 (ARM v8) 64-bit SoC @ 1.5GHz

MEMORY: 1GB, 2GB, 4GB or 8GB LPDDR4

(depending on model) with on-die ECC

CONNECTIVITY: 2.4 GHz and 5.0 GHz IEEE 802.11b/g/n/ac wireless

LAN, Bluetooth 5.0, BLE Gigabit Ethernet

GPIO: Standard 40-pin GPIO header

(fully backwards-compatible with previous boards)

VIDEO & SOUND: 2 × micro HDMI ports (up to 4Kp60 supported)

2-lane MIPI DSI display port 2-lane MIPI CSI camera port 4-pole stereo audio and composite video port

H.264 (1080p60 decode, 1080p30 encode) OpenGL ES, 3.0 graphics

Micro SD card slot for loading operating system and data storage

INPUT POWER: 5V DC via USB-C connector (minimum 3A1)

5V DC via GPIO header (minimum 3A1) Power over Ethernet (PoE)–enabled (Requires separate PoE HAT)

The C920s delivers impressive Full HD video quality at 1080p and 30fps, featuring a high-definition glass lens and a 78° field of view With its HD auto light correction and dual microphones, it ensures clear stereo sound, making it ideal for exceptional conference calls and polished demo recordings.

Dimensions including fixed mounting clip

Mic range: Up to 3 ft (1 m)

Diagonal field of view (dFoV): 78°

Algorithm Flowchart

The largest angle of inclination relative to the vertical a(max) 72, a(int) = 0 a(int) > a(max)

Once operational, the system will track individuals within its frame by creating an ellipse around them and measuring the angle between the person and the floor, with a maximum threshold of 72 degrees indicating vertical alignment It will continuously monitor this angle, and if it exceeds the maximum, the system will identify it as a fall Upon detecting a fall, the technology will send an alert to the mobile device, indicating the person's location within the falling frame.

METHODOLOGY

System Overview

This project focuses on developing a system capable of recognizing the human body and tracking individual actions within the frame By utilizing this technology, the system can identify specific movements such as walking, standing, sitting, falling, and lying down, subsequently sending alerts to connected phones or electronic devices.

OpenCV

OpenCV, or Open Source Computer Vision, is designed to provide a unified framework for computer vision tasks and enhance functionality in budget-friendly applications Its primary focus includes image processing, face recognition, video capture, object detection, and tracking.

OpenCV is designed for various operations, including face detection and recognition, analyzing human actions in videos, identifying objects, tracking camera movements, following moving objects, and merging images to create high-resolution visuals for precise scenes.

There are different highlights of OpenCV, which are as takes after:

 OpenCV gives an office to capture and store videos

 In OpenCV, you'll perused and type in on the images

 OpenCV encourages to handle of pictures such as transformation, filter, alter component, etc

 OpenCV may be a library that gives an approach to analyze the video, degree the video's movement, recognize the foundation and recognize the objects

There are different applications of OpenCV, which are as takes after:

OpenCV can be utilized to control a robot's range It can moreover utilize it in course, Deterrent anticipation, and Human-Robot Interaction

OpenCV can bolster patients by orchestrating and identify cells or tumors, 2D/3D division, 3D organ reproduction, and vision-guided mechanical surgery

It to be valuable in terms of deciding absconds of stock, scanner labels and bundles, protest organizing, record investigation, etc

This can be utilized in review and biometrics, and at last, for shipment, it can encourage us to recognize driver carefulness and make free vehicles.[21]

Method

To distinguish the foreground from the background in a video, we utilize frame comparison between the initial frame captured at the start of recording and the current frame The first frame may either be devoid of objects or include certain items.

To identify moving objects in relation to the first frame, we calculate the absolute difference between the current frame and the initial one This technique effectively reveals distant moving figures However, it has limitations; for instance, if the background and clothing share similar pixel intensities, it can hinder accurate separation of the background.

The MOG2 method is effective for background subtraction, but our testing dataset presented noise issues To enhance the foreground, we utilized the body's silhouette and implemented techniques such as thresholding, dilation, and erosion, carefully adjusting the settings for optimal results.

By doing this, we eliminated extra noise and motion-related distortion

A rectangle consistently produces angles of either 0 or 90 degrees, while an ellipse generates a spectrum of angles ranging from 0 to 180 degrees To determine if a fall has taken place, it is essential to assess the body's angle in relation to the horizontal plane.

When considering design elements, it's essential to account for 23 vertical factors While a rectangular bounding box can be utilized with additional logical gates and parameters, an ellipse has demonstrated greater practicality in application.

In the study of human falls, the ellipse's minor and major axes, denoted as a and b, play crucial roles in defining the dimensions of the fall's trajectory The major axis (2*b) represents the width, while the minor axis (2*a) indicates the height of the ellipse It's important to note that these axes may vary in orientation during a fall, affecting the measurements Figure 1 illustrates the angles used for estimating human falls, and Table 1 outlines the symbols employed in the mathematical expressions of this research.

Figure 4.3.1Human body position with respect to ellipse while falling [22]

Figure 4.3.2 Symbols used in our algorithm [22]

A body is considered to be in a state of falling when it tilts at an angle of 2π/5 from the vertical and π/10 from the horizontal, provided it meets specific criteria.

Function in code

The resize() function generates a new array in the desired format, filling the display with multiple copies of an item if the new collection exceeds the size of the previous array.

Cvtcolor is a Python library designed to tackle challenges in computer vision, utilizing the Cv2.cvtColor() function to convert an image's color space OpenCV offers over 150 different techniques for color-space conversion The syntax for this function is dst = cv2.cvtColor(scr, code[, dstCn]), where 'dst' represents the output image, which maintains the same data type and depth as the original input image, referred to as 'scr'.

The flag of color space conversion is code

DstCn is the number of channels of the target picture, 0 is default

Table 4.1Color space conversion codes

The cv.COLOR_BGR2BGRA function adds an alpha channel to an RGB image, while cv.COLOR_BGR2RGB changes the order of color channels To convert a color image to grayscale, use cv.COLOR_BGR2GRAY, and to revert a grayscale image back to color, utilize cv.COLOR_GRAY2BGR For color space transformations, cv.COLOR_BGR2YUV converts RGB to YUV, and cv.COLOR_YUV2BGR converts YUV back to RGB.

The OpenCV library provides several functions for color space conversions, including cv.COLOR_BGR2HSV to convert from RGB to HSV color space, cv.COLOR_HSV2BGR for converting HSV back to RGB, cv.COLOR_BGR2Lab for transforming RGB to Lab color space, and cv.COLOR_Lab2BGR to revert Lab color space back to RGB.

Example Code: import cv2 src = cv2.imread("D:\\Document\\HK2022-2023\\Graduate Project\\111.jpg") src cv2.resize(src, (int(src.shape[1]/2), int(src.shape[0]/2)))

GRAY = cv2.cvtColor(src, cv2.COLOR BGR2GRAY)

Lap = cv2.cvtColor(src, cv2.COLOR BGR2LAB)

#YCrCb = cv2.cvtColor(src, cv2.COLOR BGR3YCrCb) #HSV = cv2.cvt.Color (src, cv2.COLOR BGR2HSV) cv2.imshow('src', src) cv2.imshow('GRAY', GRAY) cv2.imshow('Lab', Lap)

#cv2.imshow("HSV", HSV) cv2.waitKey(0) cv2.destroyAllWindows ()

Image Progessing- Smoothing

Digital images often suffer from disruptions caused by various sounds during their collection, processing, and transmission, leading to issues such as poor quality, haziness, and loss of image features To enhance image clarity, picture smoothing techniques are employed to reduce noise, particularly common types like Gaussian noise and salt-and-pepper noise.

Salt-and-pepper noise, also referred to as pulse noise, consists of random black and white dots that create the appearance of black pixels in bright areas and white pixels in dark regions.

Figure 4.5.1 Salt and pepper Noise

Signal processing theory refers to "Gauss noise," a type of signal noise characterized by a probability density function (pdf) that matches the normal distribution, also known as the Gaussian distribution.

Mathematical statistics frequently have the ability to inhibit it

Image smoothing, from the standpoint of the signal, filters the high frequency portion of the signal while reserving the low frequency portion

Filtering can be classified as mean, Gaussian, or median filtering depending on the type of filter being used

Gauss filtering is one of the most often used methods of filtering, however there are many more.

Gaussianblur

By multiplying each value by the relevant weight, adding the total, and then dividing the total by the total number of values, the weighted mean is determined

With Gauss filtering, the center pixel is given the weighted mean of all the pixels in the image, with the weighted mean in square units

In the illustration provided, the weighted mean of all the pixels in image (a) is calculated to be "164," which serves as the new center pixel value This weighted mean reflects the average intensity of the pixels, contributing to the overall representation of the image.

As illustrated in picture (c), change the original center pixel value to "122"

Example Code import cv2 import numpy as nm import matplotlib.pyplot as plt

# image reading img = cv2.imread('D:\\Document\\HK2022-2023\\Graduate Project\\noise.jpg')

# image smoothing blur1 = cv2.blur(img, (5, 5)) #mean filtering blur2 = cv2.GaussianBlur(img, (5, 5), 1) # Gauss filtering blur3 = cv2.medianBlur(img, 5) # Median filtering

In this article, we explore image processing techniques using Python's Matplotlib library We begin by displaying the original image alongside its processed versions The first processed image demonstrates mean filtering, which smooths the image by averaging pixel values, while the second showcases Gaussian filtering, which applies a Gaussian function to reduce noise and detail Each image is presented in a subplot for clear comparison, with titles indicating the filtering methods used.

30 plt.xticks([]), plt.yticks([]) plt.subplot(144), plt.imshow(blur3), plt.title("Median Filtering") plt.xticks([]), plt.yticks([]) plt.show()

Threshold

In order to convert a picture to black and white, image binaryzation involves setting the gray values of image pixels to two values, often 0 (represents black) and 255 (represents white)

Grayscale images undergo processing, followed by the application of a threshold to divide the image into two distinct sections: one exceeding the threshold and the other falling below it Subsequently, different pixel values are assigned to each segment of the image.

Image binarization makes it easier to process the image further, simplifies it, uses less data, and draws attention to the contour you're most interested in

There are three techniques to apply thresholding depending on the circumstance: global thresholding, adaptive thresholding, and otsu thresholding

The fourth argument, "type," designates the thresholding type:

• cv2 THRESH BINARY: If a portion is bigger than the threshold, it is set as masxval; otherwise, it is 0

• In cv2.THRESH _BINARY INV, the portion that is more than the threshold is set to 0 and the remaining portion is maxval

• cv2.THRESH TRUNC: The portion more than the threshold is set as the threshold, while the portion less than the threshold is left alone

• cv2.THRESH TOZERO: The portion that exceeds the threshold is set as the threshold, while the portion that is less than the threshold is set as 0

• cv2.THRESH TOZERO INV: The part greater than the threshold is set to 0 and the part less than the threshold is left alone

To process an image using OpenCV, first import the library with `import cv2` Load the image from a specified path using `img=cv2.imread('D:\\Document\\HK2022-2023\\Graduate Project\\thresh.jpg')` Convert the loaded image to grayscale with `img_gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)` Finally, apply a binary threshold to the grayscale image using `ret, img2 = cv2.threshold(img_gray, 127, 255, cv2.THRESH_BINARY)`.

#set maxval as 255 And the output image after processing is black-and-white image cv2.imshow("original",img) cv2.imshow("BINARY", img2) cv2.waitKey(0) cv2.destroyAllWindows()

Morphological Processing

Morphology is a widely used technique in image processing that focuses on extracting essential components to characterize the shape of an area This method captures critical shape properties, such as boundaries and related regions, which are vital for subsequent identification processes Furthermore, techniques like thinning, pixelation, and burr trimming are commonly employed in image preparation and postprocessing, enhancing the overall quality of the image.

In order to measure or extract the corresponding form or feature in the input image for subsequent image analysis and target recognition, morphology uses a particular structural element

Erosion and dilation are essential morphological processes that form the foundation of various complex morphological operations and algorithms.

Structuring both erosion and dilation require an element A two-dimensional structuring element can be thought of as a "0" or "1" dimensional matrix element

Erosion: The three-step process of erosion involves the removal of minute, useless objects

To create an image matrix based on structural elements, identify its source by considering the upper left corner component as the origin, which should be emphasized in dark ink.

Figure 4.8.1 The three-step process of erosion

To process the unfinished image, position the structural component accurately A pixel is designated as "1" at the origin if all corresponding pixels in the image that align with the structuring elements marked "1" are also "1"; otherwise, it is marked as "0."

Figure 4.8.2 Image has been fully processed

Make the structural elements on the awaiting image move in the proper order until all of the images have been fully processed

Dilation enhances the edges of an image by expanding the angles of both target and non-target pixels This process involves a series of steps to effectively manage the operations involved.

To create an image matrix, begin by defining a structural element and identifying its origin, which is located in the upper left corner Highlight this origin point in dark ink to emphasize its significance in the matrix.

Figure 4.8.4 Steps are used to divide the operations

To process an unfinished image, overlay the structural component and evaluate the corresponding pixel positions If any pixel value in the image that aligns with a "1" in the structuring element is also "1," assign a value of "1" to that position; otherwise, assign a "0."

Figure 4.8.5 Image has been fully processed

 Make the structural elements on the awaiting image move in the proper order until every image has been fully processed

Example for Code: import cv2 import numpy as np import matplotlib.pyplot as plt

# read the image img_org = cv2.imread('D:\\Document\\HK2022-2023\\Graduate

#img_noise = cv2.imread('example_noise.jpg')

#img_cave = cv2.imread('example_cave.jpg')

# build nuclear structure kernel = np.ones((10, 10), np.uint8) # 10*10 all-one matrix

# Morphological processing erosion_img = cv2.erode(img_org, kernel) # erosion dilate_img = cv2.dilate(img_org, kernel) # dilation

#open_img = cv2.morphologyEx(img_noise, cv2.MORPH_OPEN, kernel) # open operation

#close_img = cv2.morphologyEx(img_cave, cv2.MORPH_CLOSE, kernel) # close operation

#top_hat_img = cv2.morphologyEx(img_noise, cv2.MORPH_TOPHAT, kernel) # top hat operation

#black_hat_img = cv2.morphologyEx(img_cave, cv2.MORPH_BLACKHAT, kernel) # bottom hat operation

The article discusses the process of image display using Matplotlib, highlighting the original image alongside its morphological transformations It includes a figure of size 10x6 with a specified DPI, ensuring proper resolution The original image is presented first, followed by the results of erosion and dilation processes, each clearly labeled to enhance understanding The axes ticks are removed for a cleaner visual presentation, focusing solely on the images themselves.

#plt.subplot(334), plt.imshow(img_noise), plt.title("Original2")

#plt.subplot(335), plt.imshow(open_img), plt.title("Open Operation")

#plt.subplot(336), plt.imshow(top_hat_img), plt.title("TopHat")

# plt.subplot(337), plt.imshow(img_cave), plt.title("Original3")

# plt.subplot(338), plt.imshow(close_img), plt.title("Close Operation")

# plt.subplot(339), plt.imshow(black_hat_img), plt.title("BlackHat")

# plt.xticks([]), plt.yticks([]) plt.show()

Contours

A contour is defined as the continuous line that links all points along an image's edge that share the same color or intensity This essential feature aids in object detection, recognition, and shape analysis.

Binarization enhances precision by transforming the image into a binary format, allowing for the identification of a white object concealed against a black background The focus is on detecting the contours of the white object, which serves as the primary target in this analysis.

The contour's detecting mode is:

• RETR EXTERNAL = 0: only the outermost contour will be detected;

• RETR LIST = 1: detect all contours without establishing hierarchies; all contours will be placed in a single list;

• RETR CCOMP = 2: detect all contours and split them into two layers;

• RETR TREE = 3: Identify layers one by one from right to left using the tee-shaped storage contour

The term "method" refers to the procedure utilized to find the contour The precise procedure is as follows

• CHAIN APPROX NONE: Maintain each and every dot on the contour

• CHAIN APROX SIMPLE: Only store the corner coordinates of the horizontal, vertical, and oblique parts For instance, 4 dots are sufficient to store the contour information for a rectangle

To process an image using OpenCV, first import the library and read the image file with `cv2.imread()` Convert the image to grayscale using `cv2.cvtColor()` and apply a binary threshold with `cv2.threshold()` Next, extract contours from the binary image using `cv2.findContours()` Finally, draw the contours on the original image with `cv2.drawContours()` and display the result using `cv2.imshow()`, ensuring to wait for a key press before closing the window with `cv2.destroyAllWindows()`.

When the keyboard is pushed, the waitkey function will wait until the window is closed before executing the destroyAllWindows method.

Application System

In today's smartphone-driven world, developing an application that monitors and alerts users about falls among the elderly can significantly enhance convenience and ease of tracking for families.

This project utilizes a free app from pushbullet.com, which is also available on Google Play The application offers a variety of useful features and utilities to enhance user experience.

Figure 4.10.1 Specification of web server [23]

In which there are two main functions to pay attention to:

This is the main interface of the application

Python HTTP Server

The term ᴡeb ѕerᴠer ᴄan allude to equipment or program, or both working together

A web server is a computer that stores web server software and website components, such as HTML documents, images, CSS stylesheets, and JavaScript files It connects to the internet and ensures compatibility with other devices connected to the web, facilitating the delivery of content to users.

When a browser needs to access a file on a web server, it sends an HTTP request Upon receiving this request, the web server's software processes it, locates the requested document, and returns it to the browser using HTTP If the server cannot find the document, it responds with a 404 error.

To publiѕh a ᴡebѕite, уou require either a ѕtatiᴄ or a dуnamiᴄ ᴡeb ѕerᴠer

A static web server, or stack, consists of hardware and an HTTP server that delivers files directly to your browser without modification In contrast, a dynamic web server includes a static server along with additional software, typically an application server and a database This setup is termed "dynamic" because the application server updates the files before sending content to your browser through the HTTP server.

To create dynamic webpages, an application server often populates an HTML template with content from a database Websites like MDN and Wikipedia utilize this approach, relying on a limited number of HTML templates combined with extensive databases rather than numerous static HTML files This configuration simplifies content management and delivery.

The Python standard library includes a built-in web server that facilitates basic web client-server communication Users can programmatically assign a port number to access the server, which primarily serves static HTML files While it lacks the advanced features of a fully-fledged web server capable of parsing various file types, it effectively responds to requests with the necessary response codes for simple web applications.

Pushbullet website provides a free and available server for everyone In this project, the server will have the role of receiving and sending signals from raspberry to mobile devices

Code so that raspberry and mobile device can communicate with each other from pushbullet import Pushbullet pb = Pushbullet("o.IH7rE4hStgrUisXnRxUTIEJ56iFtjVyv") push = pb.push_note("Alert", "FALL DETECTION")

To transmit a signal from a Raspberry Pi to a server and relay it to the specific device receiving the alarm, the web server issues a token that serves as the communication address between the connections.

Figure 4.11.2 Token used to send notification

In addition, the system also sends another image file stored in raspberry's memory with a specific time

To send images to a Raspberry Pi, first save the image using the code `cv2.imwrite(file, frame)` where the file path is specified as `'/home/gerpan/Pictures/' + t + '.jpg'` Next, open the saved file in binary mode and upload it using `pb.upload_file(pic, "picture.jpg")` Finally, push the uploaded file with `pb.push_file(**file_data)`, ensuring to handle any exceptions appropriately.

Figure 4.11.3Images stored in raspberry

Sending notifications to both devices at the same time makes tracking more effective

EXPERIMENT RESULTS/ FINDINGS AND ANALYSIS

Hardware Result

Figure 5.1.1 The front of the model

Testing Result

Once the system is initiated and stabilized, the camera will recognize and track the behavior of elderly individuals in real time, encircling them with an elliptical frame that follows their movements.

The system continuously monitors the individual being tracked, remaining silent when they are standing or sitting It only triggers an alert upon detecting a fall, promptly sending a notification to the mobile device along with detailed images.

Figure 5.2.4 notification from mobile device

When an elderly person falls, the circular frame will change from vertical to horizontal, through which the recognition system will know that the person being tracked is falling

Code to detect people falling if (abs(originalAngleP) > minAngle and abs(originalAngleH) < maxAngle and abs(originalAngleP)+abs(originalAngleH)>89 and abs(originalAngleP)+abs(originalAngleH) 18): count_fall+=1

The fall detection system appends the current timestamp to a list whenever a fall is detected If multiple falls are recorded, it checks the time interval between the last two falls If this interval is less than 0.5 seconds, it labels the event as 'Fall Detection' and displays this label on the video frame using OpenCV The system also prints the time difference between the most recent falls for further analysis.

The data used to calculate the accuracy of the system consists of 28 videos recorded under real environmental conditions

Before making a statistical table, this paper applies the following equations to calculate the system accuracy Performance of the proposal algorithm is evaluated by measuring sensitive, specificity, precision and accuracy:

 True positive (TP): Fall occurs and it is detected

 False positive (FP): Device detects fall but fall did not occur

 True negative (TN): Normal movement, there is no fall

 False negative (FN): Fall occurs but device does not detect it

The sample videos have been tested many times and the results are below

Table 5.1 Results of fall detections

Event No of events True positive False positive True negative False negative

Performance of the algorithm based on metrics

After calculating the system's results, we conducted comparisons with other systems addressing the same problem Below are some key findings we collected.

The first is a fall detection system using deep learning and image processing with cloud storage [25]

The second is a fall detection system using Omni camera and human body data [26]

The following is the system's Fall Detection from Human Shape and Motion History Using Video Surveillance result [27]

After reviewing and comparing various studies, we found that our project's outcomes achieved a remarkable success rate exceeding 90%, with the deep learning-based fall detection system demonstrating the highest effectiveness In contrast, other systems reported success rates below 90%.

CONCLUSION AND RECOMMENDATIONS

Conclusion

The group has completed the venture: “Fall location system” with positive comes about The venture accomplished a few goals:

Can take after the elderly continuously

Can send cautions around any electronic gadget with web association and following app

Can identify the falling activity of the elderly with tall accuracy

However, this framework still has a few deficiencies as specified in chapter 5, which got to be encouraged inquired about and created.

Future works

Use more optimal recognition method for more accurate identification

Improve the existing features on the application and create new features

Use infrared camera to be able to identify even in low light conditions

Use the more advanced computer system of Raspberry Pi to be able to run stably and perform more functions

[1] Rau, C.-S., Lin, T.-S., Wu, S.-C., Yang, J C.-S., Hsu, S.-Y., Cho, T.-Y., & Hsieh, C.-H (2014, November 12) Geriatric hospitalizations in fall-related injuries Scandinavian journal of trauma, resuscitation and emergency medicine Retrieved

December 27, 2022, from https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4232632/

[2] Falls in older people: Epidemiology, risk factors and strategies for (n.d.) Retrieved November 30, 2022, from https://www.researchgate.net/publication/6862466_Falls_in_Older_People_Epidemiolog y_Risk_Factors_and_Strategies_for_Prevention

[3] Paper © 2008 Royal College of Physicians of edinburgh J R coll (n.d.) Retrieved November 30, 2022, from https://www.rcpe.ac.uk/sites/default/files/anderson.pdf

[4] Elderly fall detection and location tracking system using heterogeneous (n.d.) Retrieved November 30, 2022, from https://www.researchgate.net/publication/334027830_Elderly_Fall_Detection_and_Locat ion_Tracking_System_Using_Heterogeneous_Wireless_Networks

[5] Wang, X., Ellul, J., & Azzopardi, G (2020, April 30) Elderly fall detection systems: A literature survey Frontiers Retrieved December 28, 2022, from https://www.frontiersin.org/articles/10.3389/frobt.2020.00071/full

[6] Công Nghệ Phân Tích Hình ảnh camera cảnh báo người ngã - tin tức-SỰ kiện - cục

The article discusses the advancements in image analysis technology utilized in surveillance cameras It highlights the importance of these technologies in enhancing public safety by providing timely alerts regarding potential threats The integration of sophisticated algorithms allows for real-time monitoring and analysis, significantly improving the effectiveness of security systems This innovative approach not only aids in crime prevention but also contributes to the overall efficiency of law enforcement operations.

[7] Apply a Gauss filter to an image with python GeeksforGeeks (2020, December 26) Retrieved December 24, 2022, from https://www.geeksforgeeks.org/apply-a-gauss-filter- to-an-image-with-python/

[8] What is gaussian filtering in image processing? Quora (n.d.) Retrieved December

24, 2022, from https://www.quora.com/What-is-Gaussian-filtering-in-image-processing

[9] Using gaussian blur in image processing | adobe (n.d.) Retrieved December 24,

2022, from https://www.adobe.com/hk_en/creativecloud/photography/discover/gaussian- blur.html

[10] Lee, A (2020, May 13) Gaussian blur (filter to blur images) OpenGenus IQ:

Computing Expertise & Legacy Retrieved December 24, 2022, from https://iq.opengenus.org/gaussian-blur/

[11] Blurring images Blurring Images – Image Processing with Python (n.d.) Retrieved December 24, 2022, from https://datacarpentry.org/image-processing/06-

53 blurring/#:~:text=In%20a%20Gaussian%20blur%2C%20the,distribution%20or%20%E2

Raspberry Pi 4 là một máy tính cỡ nhỏ sử dụng hệ điều hành Linux, được thiết kế để chạy các chương trình lớn với tốc độ đầu ra nhanh chóng Mô hình Raspberry Pi 4 B+ là phiên bản mới nhất, tích hợp các hệ thống truyền thông hiện đại, bao gồm WiFi và Bluetooth, phục vụ cho các dự án điều khiển thông minh Thiết bị này có vi xử lý 4 lõi và ba phiên bản với dung lượng RAM khác nhau, hỗ trợ hai cổng HDMI cho màn hình 4K Raspberry Pi 4 có tổng cộng 40 chân, trong đó 28 chân là GPIO, cho phép thực hiện nhiều chức năng I/O và hỗ trợ các giao thức như UART, SPI và I2C Các chân nguồn có thể cấp điện qua cổng USB-C hoặc chân 5V, và thiết bị có khả năng kết nối với nhiều ngoại vi khác nhau, từ máy ảnh đến màn hình LCD.

[13] Raspberry pi icon PNG #420022 Raspberry Pi Icon Png #420022 - Free Icons

Library (n.d.) Retrieved December 28, 2022, from https://icon- library.com/icon/raspberry-pi-icon-png-27.html

[14] Raspberry Pi LÀ gì và được sử dụng như thế nào? Quantrimang.com (n.d.)

Retrieved November 30, 2022, from https://quantrimang.com/cong-nghe/raspberry-pi-la- gi-va-duoc-su-dung-nhu-the-nao-145399

[15] 5, S O G |@sogrady |A., O'Grady, S., & *, N (2021, August 5) The

Redmonk Programming Language Rankings: June 2021 tecosystems Retrieved

November 30, 2022, from https://redmonk.com/sogrady/2021/08/05/language-rankings- 6-21/

[16] What is python used for? A beginner's guide Coursera (n.d.) Retrieved December

1, 2022, from https://www.coursera.org/articles/what-is-python-used-for-a-beginners- guide-to-using-python

[17] Raspberry pi 4 8GB RAM: All new raspberry pi desktop computer Amazon.in: Computers & Accessories (n.d.) Retrieved December 28, 2022, from https://www.amazon.in/Raspberry-Pi-8GB-Desktop-Computer/dp/B08B9XS3B6

[18] Raspberry Pi (n.d.) Buy A raspberry pi 4 model B Raspberry Pi Retrieved

December 28, 2022, from https://www.raspberrypi.com/products/raspberry-pi-4-model-b/

[19] Webcam Logitech C922 - webcam HD 1080p logitec Pustudio.vn (n.d.) Retrieved December 28, 2022, from https://www.pustudio.vn/products/webcam-logitech-c922- webcam-hd-1080p-logitec?variant74355936&source=googleshop

[20] Rosebrock, A (2021, April 17) Fast, optimized 'for' pixel loops with opencv and python PyImageSearch Retrieved December 28, 2022, from https://pyimagesearch.com/2017/08/28/fast-optimized-for-pixel-loops-with-opencv-and- python/

[21] What is opencv? Tutorials Point (n.d.) Retrieved December 1, 2022, from https://www.tutorialspoint.com/what-is-opencv

[22] Halder, K S., Singla, A., & Singh, R (1970, January 1) Novel algorithm on Human Body Fall Detection SpringerLink Retrieved December 28, 2022, from https://link.springer.com/chapter/10.1007/978-3-030-24322-7_28

[23] Pushbullet (n.d.) Retrieved December 28, 2022, from https://www.pushbullet.com/

[24] Ashok AroraAshok Arora is CEO and Founder of eWebGuru a leading web hosting company of India He is a tech enthusiast with more than 25 years of experience in

Web servers communicate with each other and other devices, playing a crucial role in web hosting This process can be likened to how the human brain interacts with the body; if one communication node fails, it can disrupt functionality When a user types a URL into a browser, the browser splits the URL into components, converts the server name into an IP address, and sends a request to the web server The server then sends HTML files back to the browser, which converts them into a visible web page almost instantaneously Communication between servers occurs when they share similar information, often facilitated by cloud infrastructure and IP addresses If a user accesses a link from Server A to Server B, the browser communicates with both servers to display the desired web page Understanding server communication can help troubleshoot issues like broken links, ensuring efficient web hosting.

I don't know!

[26] S -G Miaou, Pei-Hsu Sung and Chia-Yuan Huang, "A Customized Human Fall Detection System Using Omni-Camera Images and Personal Information," 1st

Transdisciplinary Conference on Distributed Diagnosis and Home Healthcare, 2006 D2H2., Arlington, VA, USA, 2006, pp 39-42, doi: 10.1109/DDHH.2006.1624792

In their 2007 paper presented at the 21st International Conference on Advanced Information Networking and Applications Workshops, Rougier et al explore the use of video surveillance for fall detection by analyzing human shape and motion history This research highlights innovative techniques in monitoring human activity, emphasizing the importance of video analytics in enhancing safety and emergency response systems The findings contribute to advancements in surveillance technology and its application in real-time fall detection scenarios.

The provided code snippet utilizes OpenCV and Pushbullet to capture video from a camera and analyze falling objects It begins by importing necessary libraries and initializing variables, including the current timestamp The video capture is set up with a resolution dependent on the camera's capabilities, while parameters such as minimum area for detection and angle thresholds are defined to identify falling objects The system tracks the number of falls and prepares to analyze the motion of objects falling at various angles.

#label = 'Not Fall' color = (0, 0, 255) time.sleep(1)

The `convertFrame` function is designed to transform a real frame into a gray frame by resizing it The resizing process maintains the aspect ratio by calculating a scaling factor based on a target width of 750 pixels The new dimensions are then applied to the original frame using OpenCV's `cv2.resize` method with area interpolation, ensuring a smooth and accurate conversion.

The code snippet utilizes OpenCV to convert a video frame to grayscale using `cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)` It then applies Gaussian blur with a kernel size of (31, 31) to reduce noise using `cv2.GaussianBlur(gray, (31,31),0)` The function returns both the original frame and the processed grayscale image The process continues in a loop, reading frames from the video capture object until there are no more frames to process.

#comparison Frame (compare framegray with first gray) if firstFrame is None: time.sleep(1.0)

_,frame= cap.read() frame,gray=convertFrame(frame) firstFrame = gray continue

#Frame difference between current and comparison frame frameDelta= cv2.absdiff(firstFrame,gray)

#Thresholding thresh1 = cv2.threshold(frameDelta,50,255,cv2.THRESH_BINARY)[1] # tính toán độ tương phản

#Dilation of Pixels (tính toán độ giản nỡ của pixel) thresh = cv2.dilate(thresh1,None,iterations = 25) #(Morphological operations)

To identify the Region of Interest (ROI) in an image, use the `cv2.findContours` function to extract contours from a thresholded image Iterate through each contour, and if the contour has five or more points and its area exceeds a specified minimum, fit an ellipse around it using `cv2.fitEllipse` Finally, draw the ellipse on the original frame to highlight the detected ROI.

The coordinates of the extreme points are determined using the minimum and maximum values of the array, with `extTop`, `extBot`, `extLeft`, and `extRight` representing the top, bottom, left, and right extremes, respectively The length of the line between the top and bottom points is calculated using the Euclidean distance formula A midpoint is then identified by averaging the coordinates of the top and bottom extremes Finally, a condition checks if the calculated line length exceeds a specified minimum threshold.

#cv2.line(frame,(extBot[0],extBot[1]),(extTop[0],extTop[1]), (255, 0, 0), 5) if (extTop[0]!=extBot[0]): slope = abs(extTop[1]-extBot[1])/(extTop[0]-extBot[0]) else:

#cv2.line(frame, (extLeft[0], extLeft[1]), (extRight[0], extRight[1]), (255, 0, 0),

5) if (extRight[0] != extLeft[0]): slope = abs(extRight[1]-extLeft[1])/(extRight[0]-extLeft[0])

#cv2.line(frame, (midPoint[0], midPoint[1]), (midPoint[0] + 1, midPoint[1] +

#angle in Radians with perpendicular originalAngleP = np.arctan((slope1 - slope) / (1 + slope1 * slope))

#angle with Horizontal originalAngleH = np.arctan(slope)

#Angle in degrees originalAngleH = originalAngleH*radianToDegree originalAngleP=originalAngleP*radianToDegree

58 if (abs(originalAngleP) > minAngle and abs(originalAngleH) < maxAngle and abs(originalAngleP)+abs(originalAngleH)>89 and abs(originalAngleP)+abs(originalAngleH) 18): count_fall+=1

The fall detection system identifies when a fall occurs by appending the current time to a list of falls If multiple falls are detected within a short interval, a "Fall Detection" label is displayed on the video frame, and an alert is sent via Pushbullet A snapshot of the incident is saved, and the image is uploaded and shared through Pushbullet as well The system continues to monitor the video feed, displaying the frame in real-time.

59 cv2.imshow('Thresh',thresh) cv2.imshow('FirstFrame',firstFrame)

#cv2.imshow('Pose Detection', frame) k = cv2.waitKey(30) & 0xff if k == 27: break print (list_falls) cap.release() cv2.waitKey(1) cv2.destroyAllWindows()

Ngày đăng: 10/10/2023, 15:15

Nguồn tham khảo

Tài liệu tham khảo Loại Chi tiết
[2] Falls in older people: Epidemiology, risk factors and strategies for ... (n.d.). Retrieved November 30, 2022, fromhttps://www.researchgate.net/publication/6862466_Falls_in_Older_People_Epidemiology_Risk_Factors_and_Strategies_for_Prevention Sách, tạp chí
Tiêu đề: Falls in older people: Epidemiology, risk factors and strategies for
[3] Paper © 2008 Royal College of Physicians of edinburgh J R coll ... (n.d.). Retrieved November 30, 2022, from https://www.rcpe.ac.uk/sites/default/files/anderson.pdf[4] Elderly fall detection and location tracking system using heterogeneous ... (n.d.).Retrieved November 30, 2022, fromhttps://www.researchgate.net/publication/334027830_Elderly_Fall_Detection_and_Location_Tracking_System_Using_Heterogeneous_Wireless_Networks Sách, tạp chí
Tiêu đề: Elderly fall detection and location tracking system using heterogeneous
Nhà XB: Royal College of Physicians of Edinburgh
Năm: 2008
[5] Wang, X., Ellul, J., &amp;amp; Azzopardi, G. (2020, April 30). Elderly fall detection systems: A literature survey. Frontiers. Retrieved December 28, 2022, fromhttps://www.frontiersin.org/articles/10.3389/frobt.2020.00071/full Sách, tạp chí
Tiêu đề: Elderly Fall Detection Systems: A Literature Survey
Tác giả: Xueyi Wang, Joshua Ellul, George Azzopardi
Nhà XB: Frontiers in Robotics and AI
Năm: 2020
[6] Công Nghệ Phân Tích Hình ảnh camera cảnh báo người ngã - tin tức-SỰ kiện - cục SỞ Hữu Trí Tuệ. (n.d.). Retrieved November 30, 2022, from https://ipvietnam.gov.vn/tin- tuc-su-kien/-/asset_publisher/7xsjBfqhCDAV/content/cong-nghe-phan-tich-hinh-anh-camera-canh-bao-nguoi-nga Sách, tạp chí
Tiêu đề: Công Nghệ Phân Tích Hình ảnh camera cảnh báo người ngã
Nhà XB: cục SỞ Hữu Trí Tuệ
Năm: n.d.
[7] Apply a Gauss filter to an image with python. GeeksforGeeks. (2020, December 26). Retrieved December 24, 2022, from https://www.geeksforgeeks.org/apply-a-gauss-filter-to-an-image-with-python/ Sách, tạp chí
Tiêu đề: Apply a Gauss filter to an image with python
Nhà XB: GeeksforGeeks
Năm: 2020
[8] What is gaussian filtering in image processing? Quora. (n.d.). Retrieved December 24, 2022, from https://www.quora.com/What-is-Gaussian-filtering-in-image-processing[9] Using gaussian blur in image processing | adobe. (n.d.). Retrieved December 24, 2022, from https://www.adobe.com/hk_en/creativecloud/photography/discover/gaussian-blur.html Sách, tạp chí
Tiêu đề: What is gaussian filtering in image processing
Nhà XB: Quora
[10] Lee, A. (2020, May 13). Gaussian blur (filter to blur images). OpenGenus IQ: Computing Expertise &amp;amp; Legacy. Retrieved December 24, 2022, from https://iq.opengenus.org/gaussian-blur/ Sách, tạp chí
Tiêu đề: Gaussian blur (filter to blur images)
Tác giả: A. Lee
Nhà XB: OpenGenus IQ: Computing Expertise & Legacy
Năm: 2020
[11] Blurring images. Blurring Images – Image Processing with Python. (n.d.). Retrieved December 24, 2022, from https://datacarpentry.org/image-processing/06- Sách, tạp chí
Tiêu đề: Blurring Images – Image Processing with Python
[12] Phan, L. (2021, December 10). Raspberry pi 4 LÀ GÌ? SƠ đồ Chân, Tính Năng và Ngoại VI Của. Blog Mecsu. Retrieved November 30, 2022, fromhttps://blog.mecsu.vn/raspberry-pi-4-la-gi/#:~:text=Raspberry%20Pi%204%20B%2B%20(RP4,dung%20l%C6%B0%E1%BB%A3ng%20RAM%20kh%C3%A1c%20nhau Sách, tạp chí
Tiêu đề: Raspberry pi 4 LÀ GÌ? SƠ đồ Chân, Tính Năng và Ngoại VI Của
Tác giả: Phan, L
Nhà XB: Blog Mecsu
Năm: 2021
[13] Raspberry pi icon PNG #420022. Raspberry Pi Icon Png #420022 - Free Icons Library. (n.d.). Retrieved December 28, 2022, from https://icon-library.com/icon/raspberry-pi-icon-png-27.html Sách, tạp chí
Tiêu đề: Raspberry Pi Icon Png #420022 - Free Icons Library
Nhà XB: Free Icons Library
Năm: n.d.
[14] Raspberry Pi LÀ gì và được sử dụng như thế nào? Quantrimang.com. (n.d.). Retrieved November 30, 2022, from https://quantrimang.com/cong-nghe/raspberry-pi-la-gi-va-duoc-su-dung-nhu-the-nao-145399 Sách, tạp chí
Tiêu đề: Raspberry Pi LÀ gì và được sử dụng như thế nào
Tác giả: Ái Thi
Nhà XB: Quantrimang.com
Năm: n.d.
[15] 5, S. O. G. |@sogrady |A., O'Grady, S., &amp;amp; *, N. (2021, August 5). The Redmonk Programming Language Rankings: June 2021. tecosystems. RetrievedNovember 30, 2022, from https://redmonk.com/sogrady/2021/08/05/language-rankings-6-21/ Sách, tạp chí
Tiêu đề: The Redmonk Programming Language Rankings: June 2021
Tác giả: Stephen O'Grady
Nhà XB: tecosystems
Năm: 2021
[16] What is python used for? A beginner's guide. Coursera. (n.d.). Retrieved December 1, 2022, from https://www.coursera.org/articles/what-is-python-used-for-a-beginners-guide-to-using-python Sách, tạp chí
Tiêu đề: What is python used for? A beginner's guide
Tác giả: Coursera Staff
Nhà XB: Coursera
Năm: n.d.
[17] Raspberry pi 4 8GB RAM: All new raspberry pi desktop computer. Amazon.in: Computers &amp;amp; Accessories. (n.d.). Retrieved December 28, 2022, from https://www.amazon.in/Raspberry-Pi-8GB-Desktop-Computer/dp/B08B9XS3B6[18] Raspberry Pi. (n.d.). Buy A raspberry pi 4 model B. Raspberry Pi. RetrievedDecember 28, 2022, from https://www.raspberrypi.com/products/raspberry-pi-4-model-b/ Sách, tạp chí
Tiêu đề: Raspberry pi 4 8GB RAM: All new raspberry pi desktop computer
Nhà XB: Amazon.in: Computers & Accessories
Năm: n.d.
[19] Webcam Logitech C922 - webcam HD 1080p logitec. Pustudio.vn. (n.d.). Retrieved December 28, 2022, from https://www.pustudio.vn/products/webcam-logitech-c922-webcam-hd-1080p-logitec?variant=1074355936&amp;amp;source=googleshop Sách, tạp chí
Tiêu đề: Webcam Logitech C922 - webcam HD 1080p logitec
Nhà XB: Pustudio.vn
[20] Rosebrock, A. (2021, April 17). Fast, optimized 'for' pixel loops with opencv and python. PyImageSearch. Retrieved December 28, 2022, fromhttps://pyimagesearch.com/2017/08/28/fast-optimized-for-pixel-loops-with-opencv-and-python/ Sách, tạp chí
Tiêu đề: Fast, optimized 'for' pixel loops with opencv and python
Tác giả: Adrian Rosebrock
Nhà XB: PyImageSearch
Năm: 2021
[21] What is opencv? Tutorials Point. (n.d.). Retrieved December 1, 2022, from https://www.tutorialspoint.com/what-is-opencv Sách, tạp chí
Tiêu đề: What is opencv
Nhà XB: Tutorials Point
Năm: n.d.

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

🧩 Sản phẩm bạn có thể quan tâm