Validation of the Algorithm in the Detection of the Image of a Person Based on the Control of a Lighting Device

This research has the objective to validate the effectiveness in the execution of the algorithm based on the detection of the image of a person, applied as a control in a lighting device, for better surveillance and energy efficiency in domestic and business areas. For the methodology was used the analysis of the data obtained in various video surveillance cameras with the algorithm integration. We considered, that the parameters such as the distance concerning the capture speed and its effectiveness in turning on and off a lighting device when detecting the image of a person are true-positive, false-positive, false-negative and true-negative were considered. concerning the data obtained, the results determined 99.5% of the image detection is positive. This is validated using the SPSS through the descriptive analysis, Cramer's v (1) and the contingency coefficient (0.707). It is concluded that the descriptive analysis applied through the contingency coefficient and Cramer's v, allows validating the efficiency and effectiveness of the algorithm applied in a control on and off of a lighting device. Keywords—Algorithm in detection, detection of people, lighting device, video surveillance devices, energy-efficient.


Introduction
With the technological evolution, our entire environment is influenced to be automated continuously, improving the quality of life of human beings, from their ease of communication despite being long distances, to the point of automating the processes that normally are manual. For this purpose, devices and processes that improve ener-as well as extending the useful life of the elements that make up a control system intelligent, as they mention [11], that where the processes are manual, it is sought to automate them, to generate efficient energy management in the system, such as the case of Smart grid home, mentioned by [12], that these homes take advantage of technology to guarantee conscious energy consumption, maintaining continuous communication between their devices and that the user has access to their monitoring.
This document is organized as follows, in Section 2 it focuses on the description of the methodology used, which includes a framework, lighting parameters, control device design, application of the device in image detection, description of the data obtained and statistical analysis using the SPSS software. Section 3 describes the results and the frequency and descriptive analysis of the data obtained concerning the application of the algorithm in the detection of a person based on the three video surveillance cameras used in this investigation. Finally, the conclusions of this research are described.

Methodology
To analyze the effectiveness of the algorithm's execution based on the detection of people and their energy efficiency in lighting systems, this research is based on an exploratory methodology, considering the data collection of three video surveillance cameras, where 630 captures were obtained, corresponding to 210 images per camera. This study is carried out to determine the effectiveness in the execution of the algorithm based on the detection of a person, and after that, apply it to a lighting device, which will be switched on depending on the detections obtained, to determine the percentage of device power-up efficiency

Framework
The purpose of the present investigation is to validate the effectiveness of the algorithm that allows the detection of the image of a person, so it is necessary to understand the detection process until reaching the final result that consists of turning on and off a system for lighting, this process is represented by the flowchart shown in Figure 1, considering that the algorithm developed in Matlab was used and using the system capture image toolbox applications in the image capture.
In this research, it points in a certain way to efficient detection, considering the effectiveness of the algorithm based on the detection of the image of a person through the three video surveillance devices used for this analysis.

Tools used
The hardware used for the purpose of this research was a Toshiba Satellite C55-C5240 Laptop, Intel® Core™ Intel Core i5-5200U de 2.2 GHz, RAM 8GB, HDD 1TB, Toshiba HD Camera, Windows 10, 64 bits, Intel HD Graphics 5500. EasyCap device, used in the video signal. IR-Max 250 Camera, IR-Hilook THC-T110-P Camera, IR-Turbo HD DS-2CE16D0T Camera, and Matlab 2017b software. Arduino Mega with I maximum equal to 40mA and V operation equal to 5v, 1 kΩ resistors, triac Model BT138, door activation current equal to 5-50 mA.

Lighting parameters considered
The authors [13] were considered for the development of the table 1, which describes the parameters power, luminous flux, voltage, luminous efficiency and the lifespan of the lighting devices used in this research. In the calculation of the luminous efficiency equation (1) the luminous flux emitted by the luminaire and the power consumption of each luminaire are related.

Design of the lighting control device
To verify the algorithm operation, a device was designed for work as a lighting device, which will be applied synchronously with the algorithm for detecting the image of a person through a different camera, see Figure 2.
The power circuit of the device operates as follows: connecting two voltage sources, one of 120V with alternating current (AC) to power the lighting device and another 5V source with direct current (CD). In this case we use the arduino board to give an ignition pulse to the triac gate, and to control the switched on of the lighting device. It is considered that the device will depend on the detection of the person, which will act as an automatic power switch in case that detects the image of the person, or turns off in the case that it does not detect it.

2.5
Detection of a person's image Table 2 describes the effectiveness rate in percentages based on the time and distance range of 3m to 9m, concerning the detection of the image of a person, through the three video surveillance cameras used in this research to validate the algorithm based on an on and off control of a lighting device.

Application of the lighting device in image detection
Similarly, in Table 3, images of the detection of a person in real time framed in a yellow frame (frame) are shown, which were captured using three different cameras through the application of the algorithm to be validated.
These visualized images are a sample of the total of 630 detections made to the same person in a range of 3m to 9m with an interval of 1m, considering that the image of the person was captured 30 times in each interval synchronized with a lighting device, which was turned on and/ or off when a true positive, false positive or false negative detection was obtained.
This process allows an optimization in the use of the device and an improvement in energy efficiency related to lighting systems.

2.7
Operation of the control circuit and its relationship with video surveillance cameras We consider parameters such as distance, capture speed, effectiveness to turn a lighting device on and off by detecting a person's image considering true positive (TP), false positive (FP), false negative (FN) and true negative (TN) for its analysis.
The video surveillance cameras are connected to the Pc used in the investigation, remaining as an external camera to the webcam. In this way the control circuit will allow connecting with the algorithm based on the detection of a person's image through an Arduino board, which is used as a link, to establish communication between the circuit and the code in Matlab, and, according to the detections made by each camera, the effectiveness of the algorithm applied was determined the turning on the lighting device, the same one that ignites by detecting the person's image, this activity is considered true positive, otherwise, when detections differing from true positive, as false positive, false negative, the lighting device emits flashing flickering.
The video surveillance cameras were used in the investigation because they have infrared night vision, that is, despite being in a low light place, the camera captures a person's silhouette and the lighting device automatically turns on. This also collaborates with energy efficiency and security issues, because the cameras work in realtime, getting the characteristics of people who enter the place where the device is applied.

Data description
The data collection was based on the images obtained from the three video surveillance devices, which were subjected to an effectiveness test based on taking captures at seven different distances, these being from 3m to 9m, completing thirty captures per camera on each path, reaching a total of ninety captures per meter.
The data obtained from the algorithm based on the detection of the person, considering that it was developed in Matlab, using system capture image toolbox as the means of connection with video surveillance devices, which consists of functions and blocks that allow cameras to be connected, as well as the analysis, visualization and development of algorithms, as indicated [14]. Next, we proceeded to sort the collected data, in a database in Excel, creating a sheet for each distance covered, and then proceed to extract the image detections made for each meter, with the detection effectiveness being the determining factor in demonstrating on which device the algorithm is best executed. And, from these data obtained, we proceed to perform a detailed analysis in the SPSS statistical software, applying the Likert scale to the 630 data of the three variables obtained, taking into consideration [15], who expresses That, is a scale that corresponds to levels, where the researcher measures the results in terms of levels. In this investigation, 4 different levels were applied, 1 being the lowest score and 4 the highest, is expressed as follows: 1. True Negative (TN), 2. False Negative (FN), 3. False Positive (FP) and 4. True Positive (TP).

Statistical analysis
In this research, descriptive analysis is used, as a statistical technique that identifies the main characteristics of the data and describes them through graphs and/or tables, as mentioned [16], this method helps to understand the data and its structure, to find a pattern of general behavior, as well as the data that moves away from that analyzed pattern.
Considering the authors [17], [18], this analysis is of the utmost importance, because it detects data that are far from the average established for others values that are part of the sample. Since this method shapes the data analysis, providing various ways of interpreting the result, whether by graphs, tables, histograms.
To determine the validity of the data obtained, the analysis of contingency tables was performed, according to [19], this method serves to relate the data of two or more different variables to each other, and with this to be able to establish modes of behav-ior. Within it is Pearson's Chi-Square test, citing [20] who indicates that, x2 (chisquare) is a test that measures the discrepancy between the distribution of observed and expected frequencies. Taking as general characteristics, this test takes values between zero and infinity and has no negative values because it is the sum of values squared.
According to (De la Fuente, 2016) the level of confidence of this test must have a value greater than 0.05, where if this rule is met, it is stated that the variables are dependent on each other. To obtain the chi-square values of each device analyzed, we proceed to apply the statistical model that represents this test in (1).
Then, the contingency coefficient test was carried out, which determines the association between variables, having its maximum association limit of 1, if this value exceeds the limit, the investigation carried out is not feasible, as indicated [22]. Applying the statistical model of this coefficient, the values that will be shown in the tables that follow are obtained, starting from the equation (2).
Where x 2 belongs to the chi-square value and n is the number of data. Finally, we proceeded to apply the Cramer's v, to measure the degree of relationship between the variables, specifying the greatest association between them, their established coefficient varies between 0 and 1, with 1 being the highest grouping value, as expressed [23]. Considering the established data, the Cramer's v was obtained, based on the statistical model that represents this test, which is determined by (3): Where x 2 belongs to the chi-square value, N to the total of the analyzed data, and m to the minimum value of rows or columns of the data.

Results
The results obtained from the three devices analyzed to determine the effectiveness of the algorithm based on the detection of a person, to implement it in a lighting device and generate energy efficiency, obtaining that the difference between the highest and the lowest percentage of effectiveness It is 3.3%, concerning the percentages accumulated in Table 3, 4 and 5, demonstrating that the algorithm is developed with high efficiency in the cameras submitted to the study. In the three devices analyzed, a favorable result was obtained, obtaining that in the video surveillance device in which the algorithm was developed with greater fluidity, a 99.5% effectiveness was obtained according to the statistical data made below.

Result and frequency analysis of the first video surveillance device
In this analysis, 30 image captures were made for each meter established as a distance in the range of 3m to 9m, obtaining 210 data concerning the detection of images, which were organized and evaluated in the SPSS software. Table 4 shows the frequency analysis of the analyzed data, and describes as result 1 detection in false positive, 5 is a false negative, leaving 204 positive detections, for which a valid percentage of 97.1% of reference effectiveness was obtained. to the turbo camera.

Result and frequency analysis of the second video surveillance device
About the first analysis, an organization of the 210 data obtained concerning the Hilook camera was carried out and the frequency analysis was carried out. Table 5 shows 203 positive detections, 4 false positives, and 3 false negatives, reaching 96.7% effectiveness, this device being less efficient concerning the turbo camera, determining that the algorithm in this camera leaned towards positive detections.  Table 6 shows the data about the frequency analysis of the max camera, obtaining 209 positive detections of 210 possible, and a false positive. Also, as a result, the highest percentage of effectiveness concerning the execution and detection of the algorithm used is visualized, being represented by a 99.5% effectiveness at the time of detecting the image of the person, there is approximately 4% difference concerning the analysis of the turbo and hilook camera that showed a lower percentage value than that of this camera.

Result and general descriptive analysis
To demonstrate the reliability of the analyzed data, a condensate of the 630 detections collected is obtained and employing descriptive statistical analysis, generally obtaining the results of the three previous analyzes. Table 7 describes the information obtained by the SPSS software. Considering the data obtained, it is observed that the highest value determined by the Likert scale (4) based on the positive detection and therefore the one that is repeated more frequently, has been taken as the average of the data, by which, we proceed to observe the standard deviation of the analyzed variables, this technique being important to demonstrate how far the variables are from their central measure, as mentioned [24], who express that, this method allows to show how the data of the average and the distribution are separated within the given limits, for which it is shown that, the deviation is in a range of 0 to 0.4, being (0.069) the deviation with Less data dispersion. Taking into account the variance, which is in a range smaller than the standard deviation (0 to 0.1), this being a measure of dispersion, as indicated [25], mentioning that the variance is what represents the variability of a series of data regarding its arithmetic mean, which shows that the analysis has been satisfactory when determining that the margin of error of the camera with greater effectiveness in terms of the execution of the algorithm, was a 0.05%, the application of the algorithm based on the detection of the image of the person being 99.5% effective.

Result and analysis applied in contingency table
To complement the validation, the contingency table is applied, which includes the contingency coefficient, the Cramer's v, and the Chi-square test, which determine the relationship between the established variables, given certain relationship values (being 1 the contingency limit value and in a range of 0 to 1 concerning Cramer) these being the relationship limits if the values are greater than 1 the assumption in the viability of the data is rejected, and if the given values are between the range of 0 to 1, the variables are considered dependent on each other, with 1 being the maximum dependence.
Concerning the first device analyzed, in Table 8, the values obtained in the Chisquare test (0.463) are shown and in Table 9, the contingency coefficient (0.816) is displayed. These results are within the range of estimates of the tests applied to video surveillance devices.  The superscript "a" shown in table 8, table 10 and table 12 represents the components considered as a sample for statistical analysis.
Considering the analysis in the second device concerning the Hilook camera, in Table 10, the values related to the Chi-square test (0.461) are shown as a result and in Table 11, the Contingency Coefficient (0.816) data is displayed, which they are similar concerning the values obtained in the first device. This is determined based on the detections and, consequently, their values are in the ranges established in the statistical tests performed.  In the third device analyzed about the max camera, data were obtained that reflect more positive detections, concerning the two previous devices, so in Table 12 the values resulting from the Chi-square test are displayed (0.468) and Table 13 shows the data about the Contingency Coefficient (0.707). These results demonstrate that this device was developed with greater efficiency applied the algorithm based on the detection of the image of a person.  About the results obtained in the three devices, the algorithm shows an optimal detection efficiency, for which the analysis of the device in which the algorithm was executed more quickly is considered, determining that the analysis is feasible, due to that, in the coefficients selected to relate the variables, has provided a result that is in the range of the limit values of these tests, having a value of 0.707 in the contingency coefficient, which its maximum value is 1, which It means that the data analyzed with this coefficient turns out to be satisfactory.
This analysis shows that the relationship between the variables is acceptable, with the percentage of error equal to 0.05% (obtained from the frequencies). Likewise, when observing the values granted by the Cramer's v, it is obtained that, this analyzed device has the highest score of this test (1), where the range of this coefficient is between 0 and 1, demonstrating that the relationship Among the variables it is perfect, the error rate is 0.05% (obtained from the frequencies).

Result of the three devices, based on positive detection
Considering the results about the percentages of positive detection obtained in the analysis performed, Figures 3, 4 and 5, visualize the effectiveness of positive detection of the algorithm in each of the cameras, demonstrating through a pie chart that the purpose of the Research has proved feasible.   This allows demonstrating that the data obtained concerning the three devices have a high relation to each other.

Discussion
This research aimed to validate the effectiveness in the execution of the algorithm applied in the detection of a person's image, applied -as a control-in a lighting device, thus obtaining results that generate several advantages: the first advantage is that thanks to the improvements made to the detection of a person's image, better surveillance can be established, this leads to a second advantage and is that we can achieve an improvement in energy efficiency in both domestic and commercial areas. The third advantage is that this research generates a contribution to better control the on and off in an automated way, and avoid keeping the luminaires on unnecessarily, considering that this will generate great benefits by establishing improvements in energy efficiency in the area of electricity consumption. Finally, a fourth advantage is considered to the optimal use of lighting devices, extending their lifespan and as future work, they consider the development and application of a database of capture images, which would be a contribution to security.
In order to achieve all of the above, the following relevant aspects were considered: For the application of the algorithm in detection, 720 x 576 pixels were considered, for the image resolution on the three cameras used. In all the tests performed was considered the shortest detection time of each camera for the respective calculations and through a mathematical equation the average time in the detection of each camera was determined. The effectiveness rate obtained as a result in image detection with the application of the algorithm on each camera, allows you to determine that this data has a relationship with each other when capturing the image in a positive way with a high percentage. The analysis of contingency coefficient, and Cramer, in relation to the device more effectively, they determined as a result in contingency coefficient a value of approximately 1 (0.707 <1), also in the Cramer coefficient, a relatively perfect result was given (1 = 1), this being the maximum point of relationship between the variables and establishing that they are within the ranges established by the coefficient studied.

Conclusion
The descriptive analysis applied to the data obtained as a result of the application of the algorithm in the detection of the image of a person in different cameras within the control of switching on and off in a lighting device, allows us to conclude that the data involved in this study have a high relation to each other, due to the few errors made by the algorithm by positively detecting the image of a person. Despite the close relationship between the data of the variables, it indicates that there is a statistical percentage that demonstrates which of these analyzed devices had the greatest effect with the application of the algorithm in positive detection of people and its feasibility to implement it in lighting devices generating an energy efficiency concerning its use.
Therefore, in the frequency analysis it was obtained that, the highest detection percentage provided 99.5% (209 true positive detections), followed by 97.1% (204 true positive detections), and finally the percentage with the lowest effectiveness that was of 96.7% (203 true positive detections), all these percentages are based on 210 general detections per camera, and 30 detections per distance, being a total of seven distances previously determined, demonstrating that the margin of error of the device with greater effectiveness is 0.05 %, a relatively small value. Due to this, an analysis was carried out to validate these data and the effectiveness of the devices concerning their variables, considering the contingency table, which details the relationship between the data of the declared variables.
Applying the contingency coefficient, and the Cramer's v, acceptable relationship values were obtained, according to this it was achieved that in the device with greater effectiveness the values are within the ranges established by the coefficient studied, resulting in the contingency coefficient a value of approximately 1 (0.707 <1), also in the Cramer's v, giving a relatively perfect result (1 = 1), being the maximum point of relationship between variables.
Upon completing this study, it is concluded that the algorithm with which a person's image is positively detected, is feasible, considering that the data obtained by the three video surveillance cameras, allowed a reliable result and with good effectiveness of execution in detection. In this investigation the application of the algorithm was efficient concerning the two devices, marking a margin of error of less than 1%, and these admissible results show that associating the algorithm with the camera can be applied in a lighting device in future works, to control the switching on and off in an automated way to avoid keeping luminaires on unnecessarily, and this seeks to generate energy efficiency in the area of electricity. Currently responsible for the research group "Information Technology with Applications in the Biomedical Sciences BIOMEDICAL-IT", of the UNMSM. She has been responsible for research projects such as genetic algorithms, Big data, image processing and recognition, intelligent systems, home automation, ontological engineering. She is a thesis advisor for Internet projects on video games, cloud computing, intelligent systems, among others. She has also made publications and presentation for research events. Email: San Marcos, Lima, Perú. Email: lproc2003@hotmail.com Evelyn Santana Mantuano. Is currently a student assistant researcher in the Faculty of Electric Engineering at Laica Eloy Alfaro of Manabí University, Manta, Ecuador. Her research activity is related to automation control systems, project management, statistics and particularly oriented to intelligent network.