OpenCV window python program to autostart on Startup

Greetings,

I am working on a python opencv based detection program with gpio function(https://github.com/NVIDIA/jetson-gpio). I tried the “Startup Application” feature given in settings but it I don’t see anything working (cv2 window or a relay which I have connected to GPIO) after I reboot.

Is there anyone else who have already worked on this. like *.service, crontab or systemd it will help a lot.

An update:
I have tried systemd service file as I mentioned below


$ sudo code-oss --user-data-dir argument /lib/systemd/system/cv2TestScript.service

[Unit]
Description=test: cv2.window autorun on startup
After=multi-user.target

[Service]
Type=idle
ExecStart=/usr/bin/python3 /home/root/Program/test_cv2.py

[Install]
WantedBy=graphical.target

And then I enabled the service and started it.
sudo systemctl enable cv2TestScript.service sudo systemctl start cv2TestScript.service

I get Following error after restart

Loaded: loaded (/lib/systemd/system/cv2TestScript.service; enabled; vendor preset: enabled)
   Active: failed (Result: core-dump) since Sun 2018-01-28 21:28:53 IST; 2 years 0 months ago
  Process: 4034 ExecStart=/usr/bin/python3 /home/root/Program/test_cv2.py (code=dumped, signal=ABRT)
 Main PID: 4034 (code=dumped, signal=ABRT)

Jan 28 21:28:53 root-desktop python3[4034]: PyCUDA ERROR: The context stack was not empty upon module cleanup.
Jan 28 21:28:53 root-desktop python3[4034]: -------------------------------------------------------------------
Jan 28 21:28:53 root-desktop python3[4034]: A context was still active when the context stack was being
Jan 28 21:28:53 root-desktop python3[4034]: cleaned up. At this point in our execution, CUDA may already
Jan 28 21:28:53 root-desktop python3[4034]: have been deinitialized, so there is no way we can finish
Jan 28 21:28:53 root-desktop python3[4034]: cleanly. The program will be aborted now.
Jan 28 21:28:53 root-desktop python3[4034]: Use Context.pop() to avoid this problem.
Jan 28 21:28:53 root-desktop python3[4034]: -------------------------------------------------------------------
Jan 28 21:28:53 botjet-desktop systemd[1]: cv2TestScript.service: Main process exited, code=dumped, status=6/ABRT
Jan 28 21:28:53 botjet-desktop systemd[1]: cv2TestScript.service: Failed with result 'core-dump'.

I am using pycuda package “import pycuda.autoinit”.
The program I am trying to run is from JK jungs blog (If you have not checked this out yet, I suggest you to check it out, he have done really a great job at this)

https://github.com/jkjung-avt/tensorrt_demos

I really think this would help lot of people who are working on opencv based projects on Jetson Nano.

Thank you.
Regards

you may find some reference here