First of all, I attach some of the general specifications of my project at the end of this post.
The main objective of my project is to detect the use of face mask via camera vision and then actuate certain actions accordingly. For example, if it detects a person not wearing a face mask, a buzzer will start to buzz continuously, Red LED start to flash and the gate will not open.
So far I manage to implement the object detection process, where it able to detect the use of face mask sufficiently. The object detection process should run continuously in a infinite while loop without any delays and will stop until I press a specific key.
The problem is when I try to incorporate delays for the actuation process in the same loop, for instance a blinking LED. The video stream for the object detection process froze because of the delays.
Thus, I try a few things to ensure that the output actuation process will not interrupt the object detection process such as by implementing multiprocessing along with pickle file that act as a buffer memory storage that stores information produce by the object detection process. But still, I did not manage to solve this problem. I have an issue with writing/reading the pickle file simultaneously from two different processes.
Requirement of the processes are as listed below.
Process 1 (Main Process)
- In an infinite loop
- No delays, speed of the iteration is limited by the hardware and the OS
- Able to write output signal as soon as it detect the face mask
Process 2 (Secondary Process)
- Start to run the program once received signal from the main process
- Able to read output signal from the main process
- Able to operate with delays without interrupting the main process
- Able to delete/edit the output signal from the main process
- Killed once the main process is terminated
Therefore, I wonder if there is any method/library/function that able to run two process simultaneously and independently, with different timing, and able to retrieve/transfer information within those processes. If it is necessary to share my codes, please do inform me.
Thank you.
General specifications of my project:
After reading and searching more about multiprocessing I manage to find something that are useful for my project, it is the method of "Sharing data using server process" and "Process synchronization" more details about this features you may refer to the YouTube video below. It is highly recommended for you to watch the full playlist, so that you have broader understanding on multiprocessing which might simplify your work.
Sharing data using server process https://youtu.be/v5u5zSYKhFs
Process synchronization https://youtu.be/-zJ1x2QHTKE
Both of this method successfully solve my problem, I think my previous problem raised due to the issue of simultaneous writing and reading of the pickle file from both of the processes.