1

I have used OpenCv within my Windows applications in the past and in this case, an application would be built and installed as a Windows Service so that it could be set to start automatically and start running. Differences are I have done these in compiled languages and we were on Windows.

Now, I am playing around with porting the application to run on Linux/Raspberry Pi. The application simply gets a video feed, does some object detection using OpenCv and then sends result via HTTP web api.

First comment before my question is (I am still getting familiar with this setup) it seems that Python is by far the language of choice for all of this. However, the end goal is to have this device be headless (no monitor or input devices and act like an IoT device) so I don't need or better, can't open a console and type commands.

So, for the question, what is the equivalent to a Windows Service on Raspberry Pi so that my application just starts up on boot and runs as long as the device is on? The subjective follow up question is Python still a good choice considering everything I have described above or would I be better off doing a full blown compiled app in c or c++?

Thanks!

2
  • Your best bet on Raspberry Pi is to use the native systemd and systemctl commands which are built-in to Debian digitalocean.com/community/tutorials/… Commented Oct 7, 2017 at 10:59
  • check immortal Commented Oct 7, 2017 at 13:43

2 Answers 2

2

If you are using Raspbian, then I would say the easiest tool il systemd (daemon) and the systemctl (shell command).

In order to run your python script as a daemon (a daemon is what Windows calls "Service") is to create a configuration file named .service and put it in the /etc/systemd/system path.

To get an idea of how to configure the file, you can take this example:

[Unit]

Description=Your service name

[Service]

ExecStart=python <path to python script>

StandardOutput=null


[Install]

WantedBy=multi-user.target

Alias=this_script_name>.script

Hope it helps!

Sign up to request clarification or add additional context in comments.

Comments

0

Check out Supervisor: http://supervisord.org/. It should do what you need to do in terms of running your program on boot and restarting if it crashes, etc.

I don't have any experience with OpenCV, but web app frameworks like Flask (http://flask.pocoo.org/) make it very easy to expose an HTTP API with minimal code.

Good luck!

1 Comment

Thank you! And would Python be the popular choice still?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.