0
votes

my problem is with Opencv and Systemd, together!

I have installed a new Opencv on Ubuntu 16.0.4 and I wrote a program to get camera stream and store some of frames. it worked "without" issue. but not work through Systemd. the systemd unit is active (dont fail) but no frame store in destination folder.

i step by step look for problem and i find that code hang on opening the camera stream. that is: cap.open("MyIpCameraAddress")

  • I try to run my code through a bash script instead of . but problem exist.
  • I also find that when i run program through systemd the relative addresses not work (when i test for open a picture)

my systemd unit file:

[Unit]
Description= abc
After=network.target

[Service]
ExecStart= /path/to/executable
Restart=always

[Install]
WantedBy=multi-user.target


also test a systemd unit like above but for run a .sh file

when i start my system unit , the destination folder (that expect store some frames) give a lock icon on it. but when run my program directly through terminal dont have any lock icon on dest folder.


EDIT: I tested with Opencv v3.4.3 and v4.0.1 but the result is the same.

1
Could you post a minimal version of your program? Without the program we would need to guess what operations systemd could interfere with.Botje
I was test a very simple program and that hang on this code: cap.open("IPadress");pouya gholami
and cap would be a VideoCapture object? The documentation states that you need to pass a proper URL instead of an IP address.Botje
You could try attaching a debugger to the systemd-started process to see where exactly it hangs, or run it under strace.Botje

1 Answers

0
votes

I find the soloution the problem is the way I installed the opencv ( i used the opencv inside the openvino pakage) i installed independent version of opencv and the problem was solved.

if any one encountered any same problem feel free to ask me