Skip to content

Instantly share code, notes, and snippets.

@yptheangel
Last active October 12, 2020 03:55
Show Gist options
  • Save yptheangel/c18f2edf9980f75f2c5d2acb032a0c42 to your computer and use it in GitHub Desktop.
Save yptheangel/c18f2edf9980f75f2c5d2acb032a0c42 to your computer and use it in GitHub Desktop.
Run OpenCV apps on boot up (Ubuntu)
  1. Create your script,"script.sh" e.g.
#!/bin/bash

cd /home/wilson/opencv-starter-pack/python/basic
python open_video.py
  1. Create your own service, .e.g Create a new file using your preferred text editor, vim, nano, gedit, use sudo if required
    sudo gedit /etc/systemd/system/faceapp.service

  2. Paste this in your file and change accordingly

[Unit] 
Description=This service runs Face Recognition App upon bootup 

[Service] 
Type=oneshot 
ExecStart=/bin/bash "/home/wilson/script.sh" start 
ExecStop=/bin/bash "/home/wilson/script.sh" stop 
RemainAfterExit=yes 

[Install] 
WantedBy=multi-user.target
  1. Change permission
    sudo chmod u+rwx /etc/systemd/system/faceapp.service

  2. Enable the service
    sudo systemctl enable faceapp

Reference: https://stackoverflow.com/questions/47411763/raspberry-pi-autostart-opencv-script-error-with-cvimshow/47413583#47413583

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment