![]() ![]() Here we can see the green ball is in view of the camera. If this green ball is detected, an alarm is raised by activating a buzzer and lighting up an LED on the TrafficHAT module (which is connected to a Raspberry Pi): Figure 2: The TrafficHAT module for the Raspberry Pi, which includes 3 LED lights, a buzzer, and push button, all of which are programmable via GPIO.Īn example of the “activated alarm” can be seen below: Figure 3: Notice how when the green ball is detected in the video stream, the LED on the TrafficHAT lights up. In last week’s post, I demonstrated how to create an “alarm” program that detects this green ball in a video stream: Figure 1: The green ball we will be detecting in our video stream. I’ll be using my Raspberry Pi to accomplish, but the same general instructions apply for other Linux distributions and OSX as well - all you need to do is change the paths to your scripts. If all is working correctly, the example.txt will be appended to every minute with new data.Looking for the source code to this post? Jump Right To The Downloads Section Running a Python + OpenCV script on rebootĪs I mentioned in the introduction to this blog post, we’ll be using crontab to launch a script on system reboot. then type :wq to confirm write and quit.Ĭrontab will say: installing new crontab, and it should be all set. ![]() ![]() Once you’re finished making changes to your crontab, hit esc. Instead of typing python3 to run the main.py file, I’ll have to use /Users/davidshivaji/test/bin/python. Now to add this as a cronjob and have it run every minute (of every day, of every…) and add this to your crontab: * * * * * /Users/davidshivaji/test/bin/python /Users/davidshivaji/projects/cronjobexample/main.pyīecause I’ve imported requests into the script, I need to run python in a virtual environment that has requests installed. If you want to run this same script, you’ll need to sign up to weatherapi and get your key. If this were a sensitive key, you’d always keep it in a separate file and show no one. Api_key.py API_KEY = "c4810933513a4a2197511600212910"Īpi_key.py is a file that just contains one variable which we import to make the request to. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |