I am doing a project where I am required to measure vibration levels due to passing vehicles (using an accelerometer sampling at high rate) and capture video of the event "SIMULTANEOUSLY" when the vibrations exceed a certain threshold value. I want both the processes i.e. data acquisition and video recording to go simultaneously so that they are synchronized in time.
I am doing both the things on a raspberry pi. To achieve my goal I have 2 strategies in mind.
1) Write a function for
a) Data acquisition
b) Recording video
and run them in the same script.
2) Or while running the script for data acquisition, use a call to os.system, to run a script to capture video of the event.
Now I am curious in what order are functions executed in Python? So if I write
while 1:
if v_threshold > some_value:
Acquire_data(); Capture_Video();
Are they being executed simultaneously or does Capture_Video() only begin once Acquire_data() has finished execution? Or in general, how are functions executed in Python (or any other programming language).
What would be your advice to achieve the goal? Writing functions or running 2 parallel scripts? Or should I use the multiprocessing module?
Thanks
Nischal