Public place energy intelligent control method and system based on video detection
By using video detection technology in large public places, combined with the YOLO model and Transformer architecture, precise control of electrical appliances in public places is achieved, solving the problem of inaccurate identification and monitoring in existing technologies, and improving the reliability and real-time performance of remote control. It is flexible and integrates physical switches and remote control to improve user experience.
Patent Information
- Application Number
- CN202410880748.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-02
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-07-02
AI Technical Summary
The existing technology cannot achieve accurate identification and monitoring in large public places, the reliability and real-time performance of remote control are insufficient, and the control method is inflexible, making it difficult to be widely used in electrical control systems in large public places.
It adopts a method based on video detection, combined with the YOLO model and Transformer architecture, communicates with the video server through RTSP, uses the subtraction method to process the video stream, and achieves precise control of electrical appliances in public places, and uses the MQTT protocol to communicate with the controller to achieve remote control and Automated scheduling.
It improves the user experience, achieves precise control and flexible management of electrical appliances in large public places, enhances the reliability and real-time performance of remote control, overcomes the problem of inaccurate monitoring of small targets in long distances, and integrates traditional physical switches with modern remote control technology.
Smart Images

Figure CN118689152A
Abstract
Description
Technical Field
[0001] The invention relates to a method and system for intelligently controlling energy in public places based on video detection, and belongs to the technical field of intelligent lighting control. Background Art
[0002] At present, the IoT smart lighting system has been widely used because it allows users to remotely monitor and control lighting equipment after being connected to the network, greatly improving energy efficiency, convenience and user experience. For example, PhilipsHue and LIFX allow users to remotely control and monitor home lighting equipment through dedicated applications or network interfaces; some can achieve intelligent dimming, and users can adjust the brightness of lights according to needs and environmental conditions, which helps save energy and provides users with customized lighting experience. Some smart lighting systems also support voice control and integrate voice assistants such as Amazon Alexa and Google Assistant, so users can easily control the status of lights through voice commands. There are also technologies that can schedule the switching time of lights, and set automation rules, such as adjusting lights according to sunrise and sunset times or human body sensing. There are also technologies that can provide energy monitoring and reporting functions to help users understand the energy consumption of lighting equipment and take measures to reduce energy waste. The patent named "Interactive Classroom Lighting Intelligent Control System and Control Method" (CN105934051B) was developed to solve the problem of low intelligent control of classroom lighting in colleges and universities, which caused the waste of lighting resources. The system consists of infrared sensors, light intensity sensors, and cameras. The lights are controlled by the information obtained to achieve real-time interaction between the intelligent lighting control system and students, reduce the waste of lighting resources, and improve the utilization rate of self-study classrooms. However, the above technologies have the following defects: first, due to the limitations of the video monitoring method, it is impossible to accurately identify the monitoring screen of large public places, and the recognition rate of small distant targets is too low; second, the entire technology requires too many sensors and is too bloated; third, it is limited to lighting control, and these technologies are mainly concentrated in the lighting field in small scenes such as homes, and have not yet been widely used in large public electrical control systems. Summary of the invention
[0003] In view of the above deficiencies in the prior art, the problem to be solved by the present invention is to provide a method and system for intelligent energy control in public places based on video detection, which can realize accurate identification and monitoring, improve the reliability and real-time performance of remote control, and has a flexible control method, and can greatly improve the user experience.
[0004] The technical solution adopted by the present invention to solve the technical problem is: The method for intelligently controlling energy in public places based on video detection comprises the following steps: S1. Initialize parameters to facilitate future calls to query the current status. At the same time, the system will load a pre-set label list, which contains all the object types that the model is expected to recognize, such as "people". The purpose of this is to enable the system to not only recognize the objects in the video when analyzing the video, but also to accurately know what each object is; S2, load the YOLO model used for target detection; S3. Communicate with the video server in the local area network through RTSP, request and control the playback and transmission of streaming media, and obtain the video stream of the surveillance camera; RTSP (Real Time Streaming Protocol) is a network protocol used to transmit streaming media data on a computer network. It is an application layer protocol, usually used to achieve real-time transmission of audio and video on the Internet and local area network. The running program reads the target video stream through the IP, user name, password, and channel number provided by the video server for subsequent program use; S4, use the loaded YOLO model to process each frame of the video stream; S5. While the YOLO model processes each frame of the video, it also adds the subtraction method to process the image, thus improving the overall recognition accuracy. S6, making an execution action decision based on the image processing results of step S4 and step S5; S7. According to the decision of step S6, different actions are taken, and information of the required actions is sent to the MQTT server; S8, the MQTT server is connected to the controller via the WIFI module. After the controller receives the control command sent by the MQTT server, it controls the relay to work according to the control command to turn off or turn on the appliance.
[0005] Further preferably, the initialization parameters include: whether the program is currently in a manned state; whether the actions required for the "unmanned state" have been run; recording the start time of the "unmanned state"; detecting whether the program has just been started; and customizing how long to execute the actions performed in the "unmanned state" in the "unmanned state".
[0006] Further preferably, in step S2, the method used to load the YOLO model is an asynchronous loading method. Asynchronous loading can improve the responsiveness of the program because the main thread will not be blocked due to waiting for resource loading.
[0007] Further preferably, in step S2, the loaded YOLO model adopts a combination of the YOLO algorithm in deep learning and the advanced Transformer technology to achieve more efficient and accurate personnel monitoring. A specially designed and optimized personnel recognition model is adopted.
[0008] YOLO is a popular real-time object detection system. The core idea of YOLO is to treat the object detection task as a regression problem through a single neural network, predicting bounding boxes and class probabilities directly from image pixels. Unlike traditional object detection systems, YOLO takes the entire image as input to the network and predicts multiple bounding boxes and class probabilities at once, which greatly improves the processing speed.
[0009] Transformer is a model architecture mainly used to handle sequence-to-sequence tasks. Its core is the self-attention mechanism, which allows the model to consider all positions in the sequence when processing data, which helps capture long-distance dependencies in the data. The Transformer model consists of multiple layers of encoders and decoders, each of which contains a self-attention layer and a feedforward neural network.
[0010] The main purpose of using Transformer to optimize the YOLO model is to use Transformer's powerful spatial relationship learning ability to enhance YOLO's object detection performance. Transformer's self-attention mechanism can help the YOLO model better understand the relationship between different parts of the image, especially in complex scenes, which can help the model recognize and locate objects more accurately.
[0011] The detailed steps of model simplification and optimization are as follows: S21, collecting data: obtaining surveillance images of public places containing people; S22. Label data: Use labeling tools to label the bounding boxes of people in the images in the dataset; S23, download pre-trained weights: Instead of training the model from scratch, use the weights that have been pre-trained on a large-scale dataset as a starting point before training. This method can significantly improve the efficiency of model training, speed up convergence, and enhance the model's ability to adapt to new scenarios; S24, Fusion Transformer Architecture Design: Based on the traditional YOLO model, the Transformer architecture is integrated; the introduction of Transformer enables the model to better understand the contextual relationships and complex dynamics in the video, especially when dealing with occlusion and group behavior; S25. Adjust the loss function: Adjust the loss function of the YOLO model to make the model better suited to the needs of person recognition, especially to optimize the prediction accuracy of position, size and confidence. S26, Training: Use the labeled data set to train the YOLO combined with Transformer model; in this process, the model learns how to accurately identify and track people in complex backgrounds; S27, Validation and Evaluation: Evaluate the performance of the model by testing it on an independent validation set; ensure that the model maintains high accuracy and robustness in different scenarios; S28. Simplified model: By optimizing the Transformer module and adjusting the input resolution to reduce the consumption of computing resources, the model is streamlined to adapt to the needs of real-time video analysis, reduce the complexity of the network, and ensure recognition efficiency.
[0012] Further preferably, in step S4, in order to solve the problem that the frame acquisition speed of the video stream is much faster than the frame processing speed of the model, the video screen will lag after running for a long time and the computer memory of the running program will overflow, the video stream processing adopts the following steps: S41, creating a queue with a maximum capacity of 2, used to transfer image data between the "image input method" and the "image processing method"; S42, create two processes, one for image input and the other for image processing; S43, input the video stream obtained in process S3 into the queue frame by frame. Since the queue has the feature of first-in-first-out, it is only necessary to control the queue size. If the number of image frames in the queue exceeds 1, one is taken out of the queue to maintain the queue size and ensure that the image frame in the queue is the latest picture. Among them, when the image frame is the latest picture, the processing steps of each image frame are: S431, first obtain the names of all layers in the network, obtain the index of the unconnected output layer, and use these layers to obtain the final output of the YOLO model; S432, obtaining a frame of image from the image queue, obtaining the height, width and number of channels of the image, and converting the image into the input format required by the YOLO model, that is, converting the image into a blob format; S433, input the blob into the YOLO model, perform forward propagation, and obtain the output of the model; S434, parsing the output of the YOLO model, extracting the category, confidence and bounding box information of the detected object; looping through each information output by the model, obtaining the confidence that the detection result is a human category, filtering out low-confidence detection results by setting a threshold, and extracting the bounding box information of the detected human object, including the upper left corner coordinates (x, y), width w and height h; S435, use non-maximum suppression to filter out bounding boxes with high overlap and retain the most representative detection results; S436, traverse the valid bounding boxes, draw rectangular boxes and labels on the image frame, and mark them using a pre-set label list.
[0013] Further preferably, in step S5, the steps of processing the image by the subtraction method are: S51, always save the last five minutes of video in the background; S52, dividing the video screen into 4*4 areas on average; S53, averaging the number of frames per second in each area to obtain an average frame per second, and subtracting the average frame of one second from the average frame of the next second. If there is no person, the screen is black, and if there is a person, the screen has a person's edge line; S54, extracting the data and drawing it into a curve graph, drawing a curve of the picture change in this time period, if the picture does not change, it is "no one state", the curve is relatively stable, if the picture changes, it is "someone state", the curve fluctuates; S55. By analyzing the video footage of the past five minutes, we can determine whether there are targets in the distance, thereby assisting the YOLO model in making decisions based on the processing results.
[0014] Further preferably, the actions in step S7 include actions in "person state" and actions in "no person state"; Among them, the action contents in the "someone status" are: S71-1, obtaining the location where the current image is taken; S71-2, check whether the MQTT connection has been established, if not, connect, if yes, proceed to the next step; S71-3. Construct the message to be sent {"ClassRoom": f"{num}","DevNo": "01","Value": "1"}, including the room name ClassRoom, the device name DevNo, and the message content Value (here '1', indicating an open operation); S71-4, sending the message to the MQTT server in json format; The action contents in "no one state" are: S72-1, obtaining the location where the current image is taken; S72-2, check whether the MQTT connection has been established, if not, connect, if yes, proceed to the next step; S72-3. Construct the message {"ClassRoom": f"{num}","DevNo": "01","Value": "0"} to be sent, including the room name ClassRoom, the device name DevNo, and the message content Value (here '0', indicating a close operation); S72-4. Send the message in json format to the MQTT server.
[0015] The MQTT described is a lightweight communication protocol designed specifically for reliable communication between IoT devices. It has the following features: The MQTT protocol uses a publish / subscribe model, in which the publisher of the message publishes the message to a specific topic, and the subscriber can subscribe to the topic of interest and receive the corresponding message. This model makes message delivery more flexible and decentralized. The MQTT protocol is very suitable for low-bandwidth and unstable network environments because its protocol header is very concise and occupies less network bandwidth and resources. MQTT supports multiple message transmission quality levels (QoS) to adapt to different application requirements. QoS levels include at most once transmission (QoS 0), at least once transmission (QoS 1) and exactly once transmission (QoS2). MQTT has a disconnection reconnection mechanism. When the device reconnects after a network interruption, it can resume the previous subscription and ensure reliable transmission of messages. The MQTT protocol supports the use of SSL / TLS encryption for data transmission to provide security protection. Due to its simplicity, lightweight and reliability, MQTT is widely used in the field of IoT, such as sensor data collection, remote monitoring, smart home, etc.
[0016] The public place energy intelligent control system based on video detection includes a controller, wherein a power supply end of the controller is connected to a power supply, a signal input end of the controller is connected to a computer via a WIFI module and an MTQQ server, the computer communicates with the video server via RTSP, a control output end of the controller is connected to a relay drive module, the relay drive module is connected to a relay, the relay is connected to an electrical appliance terminal, the electrical appliance terminal is connected to an electrical appliance, an output interface of the controller is connected to an indicator light, an input interface of the controller is connected to a switch, two ends of the relay are connected in parallel to an emergency switch circuit, and the emergency switch circuit is connected to a power supply and an electrical appliance terminal.
[0017] The computer obtains the surveillance video stream through RTSP, processes it through the improved YOLO model combined with the difference matrix, makes decisions through the logic code to send signals to the controller, and uses the controller ESP8266 to connect to the cloud server, establishing a stable communication bridge between the controller and the cloud server, and realizing precise control of public place electrical appliances. In addition, we set up a switch that can turn off the convenient function of all public place electrical appliances with one click, providing users with a more convenient and intelligent control experience.
[0018] The 5VIN power supply terminal of the controller is connected to the 5V power supply output terminal of the AC-DC power converter P1, and the 5VIN power supply terminal of the controller is also connected to the resistor R10 and the light emitting diode D6 and then grounded; The D1 output end of the controller is connected to the relay drive circuit U2 and the relay drive circuit U3, the relay drive circuit U2 is connected to the relay RY1, the relay RY1 is connected to the electrical wiring port P4, both ends of the relay RY1 are connected in parallel with the emergency switch S1, the emergency switch S1 is connected to the electrical wiring port P4, the relay drive circuit U3 is connected to the relay RY2, the relay RY2 is connected to the electrical wiring port P4, both ends of the relay RY2 are connected in parallel with the emergency switch S2, the emergency switch S2 is connected to the electrical wiring port P4, and the D1 output end of the controller is also connected to the resistor R4 and the light emitting diode D2 and then grounded; The D2 port of the controller is connected to the relay drive circuit U4 and the relay drive circuit U5, the relay drive circuit U4 is connected to the relay RY3, the relay RY3 is connected to the electrical wiring port P5, both ends of the relay RY3 are connected in parallel with the emergency switch S3, the emergency switch S3 is connected to the electrical wiring port P5, the relay drive circuit U5 is connected to the relay RY4, the relay RY4 is connected to the electrical wiring port P5, both ends of the relay RY4 are connected in parallel with the emergency switch S4, the emergency switch S4 is connected to the electrical wiring port P5, and the D2 output end of the controller is also connected to the resistor R3 and the light-emitting diode D1 and then grounded; The D5 port of the controller is connected to the external switch interface P3 and then grounded, and the external switch interface P3 is connected to the switch; the D6 port of the controller is connected to the resistor R6 and the light-emitting diode D3 and then grounded; the D7 port of the controller is connected to the resistor R7 and the light-emitting diode D4 and then grounded; the D8 port of the controller is connected to the resistor R9 and the light-emitting diode D5 and then grounded.
[0019] The beneficial effects of the present invention are: The method and system for intelligent energy control in public places based on video detection described in the present invention make comprehensive use of Internet of Things technology and computer vision technology. Only the acquired video content of public places is needed to realize comprehensive control of electrical appliances in public places. Different control instructions can be sent to several electrical appliances at the same time through one system, including remote monitoring, timed scheduling, physical switch integration and other functions, providing a more intelligent and flexible control method for large public places.
[0020] The method and system for intelligent energy control in public places based on video detection described in the present invention adopts the YOLO model optimized by integrating the Transformer architecture to accurately collect personnel information in the image. At the same time, in order to further compensate for the instability of YOLO detection, a method combined with the subtraction method is also proposed, that is, a technology that uses the matrix generated by the difference of the average frame to judge whether there is a target in the picture, overcomes the problem of inaccurate monitoring of small targets in the distance, and uses the above collection to accurately control the electrical appliances.
[0021] The method and system for intelligent energy control in public places based on video detection described in the present invention avoid image delay caused by model processing of images through queues; by optimizing the network communication mechanism, problems that may be faced by the prior art in terms of network stability are solved, and the reliability and real-time performance of remote control are improved.
[0022] The video detection-based public place energy intelligent control method and system described in the present invention innovatively and effectively integrates traditional physical switches with modern remote control technology, ensuring that users can flexibly choose and switch between the two control modes, thereby improving user experience and system availability. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 It is a system principle diagram of the present invention; Figure 2 is a circuit diagram of a controller of the present invention; Figure 3 The relay drive circuit and emergency switch circuit of the present invention Figure 1 ; Figure 4 The relay drive circuit and emergency switch circuit of the present invention Figure 2 ; Figure 5 It is the indicator light circuit diagram of the present invention; Figure 6 It is a flowchart of the program operation of the embodiment of the present invention; In the figure, 1. controller; 2. power supply; 3. relay drive module; 4. relay; 5. electrical terminal; 6. electrical appliance; 7. indicator light; 8. switch; 9. computer; 10. video server; 11. emergency switch circuit. DETAILED DESCRIPTION
[0024] The embodiments of the present invention are further described below in conjunction with the accompanying drawings: like Figure 6 As shown, the method for intelligently controlling energy in public places based on video detection of the present invention comprises the following steps: S1. Initialize parameters. At the same time, the system loads a set label list, which contains the object types that the model can recognize. The initialization parameters include: whether the program is currently in a manned state; whether the actions required for the "unmanned state" have been run; record the start time of the "unmanned state"; detect whether the program has just been started; and customize how long to execute the actions performed in the "unmanned state" in the "unmanned state".
[0025] S2. Load the YOLO model used for target detection. The method used to load the YOLO model is an asynchronous loading method. The loaded YOLO model adopts a combination of the YOLO algorithm and the Transformer technology. The Transformer technology is used to simplify the YOLO model. The simplification steps are as follows: S21, collecting data: obtaining surveillance images of public places containing people; S22. Label data: Use labeling tools to label the bounding boxes of people in the images in the dataset; S23, download pre-trained weights: Instead of training the model from scratch, use weights that have been pre-trained on a large-scale dataset as a starting point before training; S24, Fusion Transformer Architecture Design: Based on the traditional YOLO model, the Transformer architecture is integrated; S25. Adjust loss function: adjust the loss function of the YOLO model; S26, training: Use the labeled data set to train the YOLO combined with Transformer model; S27. Validation and evaluation: Evaluate the performance of the model by testing it on an independent validation set. S28. Simplify the model: Reduce the consumption of computing resources and simplify the model by optimizing the Transformer module and adjusting the input resolution; S3, communicate with the video server in the local area network through RTSP, request and control the playback and transmission of streaming media, and obtain the video stream of the surveillance camera; S4. Use the loaded YOLO model to process each frame of the video stream. The steps of video stream processing are: S41, creating a queue with a maximum capacity of 2, used to transfer image data between the "image input method" and the "image processing method"; S42, create two processes, one for image input and the other for image processing; S43, input the video stream obtained in process S3 into the queue frame by frame. Since the queue has the feature of first-in-first-out, it is only necessary to control the queue size. If the number of image frames in the queue exceeds 1, one is taken out of the queue to maintain the queue size and ensure that the image frame in the queue is the latest picture. Among them, when the image frame is the latest picture, the processing steps of each image frame are: S431, first obtain the names of all layers in the network, obtain the index of the unconnected output layer, and use these layers to obtain the final output of the YOLO model; S432, obtaining a frame of image from the image queue, obtaining the height, width and number of channels of the image, and converting the image into the input format required by the YOLO model, that is, converting the image into a blob format; S433, input the blob into the YOLO model, perform forward propagation, and obtain the output of the model; S434, parsing the output of the YOLO model, extracting the category, confidence and bounding box information of the detected object; looping through each information output by the model, obtaining the confidence that the detection result is a human category, filtering out low-confidence detection results by setting a threshold, and extracting the bounding box information of the detected human object, including the upper left corner coordinates (x, y), width w and height h; S435, use non-maximum suppression to filter out bounding boxes with high overlap and retain the most representative detection results; S436, traversing valid bounding boxes, drawing rectangular boxes and labels on the image frame, and marking them using a pre-set label list; S5. While the YOLO model processes each frame of the video, the subtraction method is added to process the picture. The steps of the subtraction method to process the picture are as follows: S51, always save the last five minutes of video in the background; S52, dividing the video screen into 4*4 areas on average; S53, averaging the number of frames per second in each area to obtain an average frame per second, and subtracting the average frame of one second from the average frame of the next second. If there is no person, the screen is black, and if there is a person, the screen has a person's edge line; S54, extracting the data and drawing it into a curve graph, drawing a curve of the picture change in this time period, if the picture does not change, it is "no one state", the curve is relatively stable, if the picture changes, it is "someone state", the curve fluctuates; S55. By analyzing the video footage of the past five minutes, it is determined whether there is a target in the distance, thereby assisting the YOLO model in making decisions based on the processing results; S6, making an execution action decision based on the image processing results of step S4 and step S5; S7. According to the decision of step S6, different actions are performed, and the information of the required actions is sent to the MQTT server; the actions include actions in "someone state" and actions in "no one state"; Among them, the action contents in the "someone status" are: S71-1, obtaining the location where the current image is taken; S71-2, check whether the MQTT connection has been established, if not, connect, if yes, proceed to the next step; S71-3, construct the message to be sent {"ClassRoom": f"{num}","DevNo": "01","Value": "1"}, including the room name ClassRoom, the device name DevNo, and the message content Value; S71-4, sending the message to the MQTT server in json format; The action contents in "no one state" are: S72-1, obtaining the location where the current image is taken; S72-2, check whether the MQTT connection has been established, if not, connect, if yes, proceed to the next step; S72-3, construct the message to be sent {"ClassRoom": f"{num}","DevNo": "01","Value": "0"}, including the room name ClassRoom, the device name DevNo, and the message content Value; S72-4, sending the message to the MQTT server in json format; S8, the MQTT server is connected to the controller via the WIFI module. After the controller receives the control command sent by the MQTT server, it controls the relay to work according to the control command to turn off or turn on the appliance.
[0026] like Figure 1 As shown, the public place energy intelligent control system based on video detection includes a controller 1, the power supply end of the controller 1 is connected to the power supply 2, the signal input end of the controller 1 is connected to the computer 9 through the WIFI module and the MTQQ server, the computer 9 communicates with the video server 10 through RTSP, the control output end of the controller 1 is connected to the relay driving module 3, the relay driving module 3 is connected to the relay 4, the relay 4 is connected to the electrical wiring terminal 5, the electrical wiring terminal 5 is connected to the electrical appliance 6, the output interface of the controller 1 is connected to the indicator light 7, the input interface of the controller 1 is connected to the switch 8, the two ends of the relay 4 are connected in parallel with the emergency switch circuit 11, and the emergency switch circuit 11 is connected to the power supply 2 and the electrical wiring terminal 5.
[0027] like Figure 2 As shown, the 5VIN power supply terminal of the controller 1 is connected to the 5V power supply output terminal of the AC-DC power converter P1, and the 5VIN power supply terminal of the controller 1 is also connected to the resistor R10 and the light emitting diode D6 and then grounded; like Figure 3As shown, the D1 output end of the controller 1 is connected to the relay drive circuit U2 and the relay drive circuit U3, the relay drive circuit U2 is connected to the relay RY1, the relay RY1 is connected to the electrical wiring port P4, both ends of the relay RY1 are connected in parallel with the emergency switch S1, the emergency switch S1 is connected to the electrical wiring port P4, the relay drive circuit U3 is connected to the relay RY2, the relay RY2 is connected to the electrical wiring port P4, both ends of the relay RY2 are connected in parallel with the emergency switch S2, the emergency switch S2 is connected to the electrical wiring port P4, and the D1 output end of the controller 1 is also connected to the resistor R4 and the light emitting diode D2 and then grounded; like Figure 4 As shown, the D2 port of the controller 1 is connected to the relay drive circuit U4 and the relay drive circuit U5, the relay drive circuit U4 is connected to the relay RY3, the relay RY3 is connected to the electrical wiring port P5, the two ends of the relay RY3 are connected in parallel with the emergency switch S3, the emergency switch S3 is connected to the electrical wiring port P5, the relay drive circuit U5 is connected to the relay RY4, the relay RY4 is connected to the electrical wiring port P5, the two ends of the relay RY4 are connected in parallel with the emergency switch S4, the emergency switch S4 is connected to the electrical wiring port P5, and the D2 output end of the controller 1 is also connected to the resistor R3 and the light-emitting diode D1 and then grounded; like Figure 5 As shown, the D5 port of the controller 1 is connected to the external switch interface P3 and then grounded, and the external switch interface P3 is connected to the switch 8; the D6 port of the controller 1 is connected to the resistor R6 and the light-emitting diode D3 and then grounded; the D7 port of the controller 1 is connected to the resistor R7 and the light-emitting diode D4 and then grounded; the D8 port of the controller 1 is connected to the resistor R9 and the light-emitting diode D5 and then grounded.
[0028] The controller 1 adopts a single-chip microcomputer of model ESP8266MOD. ESP8266MOD is connected to the MQTT server through a WIFI module, receives control commands issued by the MQTT server, and controls the action of the relay. The relay drive circuit is driven by a dedicated relay drive chip 3105. When a low-level signal is given in the input signal segment, the relay is turned on, the CH segment and the L segment are turned on, and the electrical appliance works. The relay drive circuit is controlled by two control signals Relay1 and Relay2. The control signal is connected to the pin of ESP8266, and the light-emitting diode D1 and the light-emitting diode D2 display the control signal status.
[0029] The light-emitting diode D3 displays the WIFI connection status. When WIFI is not connected, D3 flashes at a frequency of 2Hz, and is always on when it is normally connected. The light-emitting diode D4 displays the connection status between the controller and the server. When the server is not normally connected, D4 flashes at a frequency of 2Hz, and flashes at a frequency of 0.5Hz when it is normally connected. The light-emitting diode D5 displays the status of the relay. When the relay is disconnected, D5 is always off, and when the relay is closed, D5 is always on. The switch 8 is connected to the controller 1. Through the cooperation of the switch 8 and the controller 1, all public place electrical appliances can be turned off with one click. In the case of WIFI abnormality and server abnormality, when the relay cannot work, the emergency switches S1, S2, S3, and S4 are used to control the on and off of the circuit respectively.
[0030] The present invention is not limited to the above-mentioned specific embodiments. Changes, modifications, additions or substitutions made by ordinary technicians in this field within the essential scope of the present invention should also fall within the protection scope of the present invention.
Claims
1. A method for intelligent energy control in public places based on video detection, characterized in that: The following steps are involved: S1, initialize the parameters, and the system loads a set label list, which contains the object types that the model can recognize; S2, load the YOLO model used for target detection; S3, communicate with the video server in the local area network through RTSP, request and control the playback and transmission of streaming media, and obtain the video stream of the surveillance camera; S4, use the loaded YOLO model to process each frame of the video stream; S5. While the YOLO model processes each frame of the video, it also adds the subtraction method to process the image; S6, making an execution action decision based on the image processing results of step S4 and step S5; S7. According to the decision of step S6, different actions are taken, and information of the required actions is sent to the MQTT server; S8, the MQTT server is connected to the controller via the WIFI module. After the controller receives the control command sent by the MQTT server, it controls the relay to work according to the control command to turn off or turn on the appliance.
2. The method for intelligent energy control in public places based on video detection according to claim 1 is characterized in that: The initialization parameters include: whether the program is currently in the manned state; whether the actions required for the "unmanned state" have been run; recording the start time of the "unmanned state"; detecting whether the program has just been started; and customizing how long to execute the actions performed in the "unmanned state" in the "unmanned state".
3. The method for intelligent energy control in public places based on video detection according to claim 1 is characterized in that: In step S2, the method used to load the YOLO model is an asynchronous loading method.
4. The method for intelligent energy control in public places based on video detection according to claim 1 or 3, characterized in that: In step S2, the loaded YOLO model adopts a combination of the YOLO algorithm and the Transformer technology, and the Transformer technology is used to simplify the YOLO model, wherein the simplification steps are: S21, collecting data: obtaining surveillance images of public places containing people; S22. Label data: Use labeling tools to label the bounding boxes of people in the images in the dataset; S23, download pre-trained weights: Instead of training the model from scratch, use weights that have been pre-trained on a large-scale dataset as a starting point before training; S24. Fusion Transformer architecture design: Based on the traditional YOLO model, the Transformer architecture is integrated; S25. Adjust the loss function: Adjust the loss function of the YOLO model; S26, training: Use the labeled data set to train the YOLO combined with Transformer model; S27. Validation and evaluation: Evaluate the performance of the model by testing it on an independent validation set. S28. Simplify the model: Reduce the consumption of computing resources and streamline the model by optimizing the Transformer module and adjusting the input resolution.
5. The method for intelligent energy control in public places based on video detection according to claim 1 is characterized in that: In step S4, the steps of video stream processing are: S41, creating a queue with a maximum capacity of 2, used to transfer image data between the "image input method" and the "image processing method"; S42, create two processes, one for image input and the other for image processing; S43, input the video stream obtained in process S3 into the queue frame by frame. Since the queue has the feature of first-in-first-out, it is only necessary to control the queue size. If the number of image frames in the queue exceeds 1, one is taken out of the queue to maintain the queue size and ensure that the image frame in the queue is the latest picture. Among them, when the image frame is the latest picture, the processing steps of each image frame are: S431, first obtain the names of all layers in the network, obtain the index of the unconnected output layer, and use these layers to obtain the final output of the YOLO model; S432, obtaining a frame of image from the image queue, obtaining the height, width and number of channels of the image, and converting the image into the input format required by the YOLO model, that is, converting the image into a blob format; S433, input the blob into the YOLO model, perform forward propagation, and obtain the output of the model; S434, parsing the output of the YOLO model, extracting the category, confidence and bounding box information of the detected object; looping through each information output by the model, obtaining the confidence that the detection result is a human category, filtering out low-confidence detection results by setting a threshold, and extracting the bounding box information of the detected human object, including the upper left corner coordinates (x, y), width w and height h; S435, use non-maximum suppression to filter out bounding boxes with high overlap and retain the most representative detection results; S436, traverse the valid bounding boxes, draw rectangular boxes and labels on the image frame, and mark them using a pre-set label list.
6. The method for intelligent energy control in public places based on video detection according to claim 1 is characterized in that: In step S5, the steps of processing the image by the subtraction method are as follows: S51, always save the last five minutes of video in the background; S52, dividing the video screen into 4*4 areas on average; S53, averaging the number of frames per second in each area to obtain an average frame per second, and subtracting the average frame of one second from the average frame of the next second. If there is no person, the screen is black, and if there is a person, the screen has a person's edge line; S54, extracting the data and drawing it into a curve graph, drawing a curve of the picture change in this time period, if the picture does not change, it is "no one state", the curve is relatively stable, if the picture changes, it is "someone state", the curve fluctuates; S55. By analyzing the video footage of the past five minutes, we can determine whether there are targets in the distance, thereby assisting the YOLO model in making decisions based on the processing results.
7. The method for intelligent energy control in public places based on video detection according to claim 1 is characterized in that: The actions in step S7 include actions in "someone's state" and actions in "no one's state"; Among them, the action content under "someone status" is: S71-1, obtaining the location where the current image is taken; S71-2, check whether the MQTT connection has been established, if not, connect, if yes, proceed to the next step; S71-3, construct the message to be sent {"ClassRoom": f"{num}","DevNo": "01","Value": "1"}, including the room name ClassRoom, the device name DevNo, and the message content Value; S71-4, sending the message to the MQTT server in json format; The action contents in "no one state" are: S72-1, obtaining the location where the current image is taken; S72-2, check whether the MQTT connection has been established, if not, connect, if yes, proceed to the next step; S72-3, construct the message to be sent {"ClassRoom": f"{num}","DevNo": "01","Value": "0"}, including the room name ClassRoom, the device name DevNo, and the message content Value; S72-4. Send the message in json format to the MQTT server.
8. A control system for the public place energy intelligent control method based on video detection as claimed in claim 1, characterized in that: The invention comprises a controller (1), wherein a power supply end of the controller (1) is connected to a power supply (2), a signal input end of the controller (1) is connected to a computer (9) via a WIFI module and an MTQQ server, the computer (9) communicates with a video server (10) via RTSP, a control output end of the controller (1) is connected to a relay drive module (3), the relay drive module (3) is connected to a relay (4), the relay (4) is connected to an electrical appliance terminal (5), the electrical appliance terminal (5) is connected to an electrical appliance (6), an output interface of the controller (1) is connected to an indicator light (7), and an input interface of the controller (1) is connected to a switch (8).
9. The public place energy intelligent control system based on video detection according to claim 8 is characterized in that: The two ends of the relay (4) are connected in parallel to an emergency switch circuit (11), and the emergency switch circuit (11) is connected to a power source (2) and an electrical appliance terminal (5).
10. The public place energy intelligent control system based on video detection according to claim 8 is characterized in that: The 5VIN power supply terminal of the controller (1) is connected to the 5V power supply output terminal of the AC-DC power converter P1, and the 5VIN power supply terminal of the controller (1) is also connected to the resistor R10 and the light-emitting diode D6 and then grounded; The D1 output end of the controller (1) is connected to the relay drive circuit U2 and the relay drive circuit U3, the relay drive circuit U2 is connected to the relay RY1, the relay RY1 is connected to the electrical wiring port P4, both ends of the relay RY1 are connected in parallel with the emergency switch S1, the emergency switch S1 is connected to the electrical wiring port P4, the relay drive circuit U3 is connected to the relay RY2, the relay RY2 is connected to the electrical wiring port P4, both ends of the relay RY2 are connected in parallel with the emergency switch S2, the emergency switch S2 is connected to the electrical wiring port P4, and the D1 output end of the controller (1) is also connected to the resistor R4 and the light emitting diode D2 and then grounded; The D2 port of the controller (1) is connected to the relay drive circuit U4 and the relay drive circuit U5, the relay drive circuit U4 is connected to the relay RY3, the relay RY3 is connected to the electrical wiring port P5, the two ends of the relay RY3 are connected in parallel to the emergency switch S3, the emergency switch S3 is connected to the electrical wiring port P5, the relay drive circuit U5 is connected to the relay RY4, the relay RY4 is connected to the electrical wiring port P5, the two ends of the relay RY4 are connected in parallel to the emergency switch S4, the emergency switch S4 is connected to the electrical wiring port P5, and the D2 output end of the controller (1) is also connected to the resistor R3 and the light-emitting diode D1 and then grounded; The D5 port of the controller (1) is connected to the external switch interface P3 and then to ground, and the external switch interface P3 is connected to the switch (8); the D6 port of the controller (1) is connected to the resistor R6 and the light-emitting diode D3 and then to ground; the D7 port of the controller (1) is connected to the resistor R7 and the light-emitting diode D4 and then to ground; the D8 port of the controller (1) is connected to the resistor R9 and the light-emitting diode D5 and then to ground.
Citation Information
Patent Citations
Interactive classroom light smart control system and control method
CN105934051A
Recyclable material classification method and system based on YOLO and storage medium
CN115690087A
Intelligent control method, device and equipment for lighting lighthouse equipment and storage medium
CN117500118A
