Ubuntu - service can't find camera when not logged in a graphical session

Dear CVB team,

I’m facing an issue related to system startup and make my application fully autonomous. For now the application is defined as a service that waits for network-online.target and cvmgmt.service to starts but it fails to connect to the camera (complaining about no accessible camera) until I login as a graphical user. We are able to connect the system and watch this through an SSH connection.

During this test the same user opens a distant SSH session to see service logs then it goes to the machine and logs in a graphical session. Before the graphical login service fails/waits/restarts as defined in the systemclt service definition and as soon as the graphical session starts the service gains an access to the camera and is able to operate as desired.

The current awful workaround is to enable autologin which means huge security breach. Do you have a prettier solution to make the camera accessible without any graphical session running?

Best regards.

Hi @obrousse

How exactly is the service (which starts your application) started?
In particular which user is logged in? Is it root/su? Or does this user switch user?

Usually Cvb applications are meant to be started as a normal user, so make sure the environment variables are set correctly.

Could you check that?

It is found in cat /etc/profile.d/cvb_environment.sh and once loaded, it should create a environment like this:

CVB=/opt/cvb
GENICAM_GENTL64_PATH=/opt/cvb/drivers/genicam
CVGENICAM_REGISTRY=/var/opt/cvb/Registry
GENICAM_CACHE_V3_1=/var/opt/cvb/genicam
CVBDATA=/var/opt/cvb
CVBCONFIG=/etc/opt/cvb

Hi @obrousse

i assume the issue is closed then?

I am dealing with a similar issue, not finding the cameras with the python SDK without opening them up first in a GUI (genicam browser), which is kinda cumbersome when you want to drop the ubuntu desktop and just run a lightweight ubuntu server to do the job.

I just checked my /etc/profile.d/ and the script is there, should that be ran every single time the system boots up or is it one time run only ?

hi @antonkristensen

so if you log into your system. is this via ssh or vnc, or more precisely are the env vars available if you start your process.
And which user does the login?

(For clarification: I use ssh (with a normal user) daily on asorted jetson devices).

I log into the system over ssh, but the final result is to be able to run the system at boot time, without having to log-in to the system, luckily i have a decent experience around the ubuntu server environment and how to set stuff and configure rights and priviledges.

So, i ran the /etc/profile.d/cvb_environment.sh script and it set all the env-variables for me, i then ran my python system and the cameras got picked up… finally!

At first i tried some cumbersome tricks to install a gui (desktop environment) on the server and then run the genicam browser, which obviously set all the envs at startup time of the genicam browser and then the cameras got picked up.

the intent was to remove the gui’s after i had done that because we don’t need the extra overhead of booting up a desktop environment at runtime.

so when i removed the guis it obivously did what i told it to do and basically removed everything it had touched, cvb, all of the other files in opt, added some extra folders in the runtime users home directory and basically almost everything that i had setup, so to save myself the time i reinstalled ubuntu server and went through all of the configurations of the network stacks and the bridges and all of that, which didn’t take that long time since i already saved all of the configs and documented everything.

AT that time i found this post after being in touch with some of the guys from stemmer.

I guess i just need to hard-code those variables into /etc/environment or make a service that runs that script at boot time so it gets persistent, if anyone has the right way to do it, it would be great if they could share.

I’m obviously not going to pull up my love for ubuntu desktop environments, i prefer running everything over ssh on headless, and luckily with vscode having super support for coding over ssh and a simple samba server running on the system i don’t see the need for the desktop env.

Well, actually the opposite. The Genicambrowser needs the variables to be set.

It should run everytime you login. VNC logins are notorious for skipping env vars. Thats why i asked. SSH is typically fine (but you are the second person to report such an issue).
There is something going on, which skips setting up the environment var at login.

Ah i see it, so when i logged in with the GUI then the command was probably triggered.

I had a restart and login again today at the beginning of the day and the env-vars were set, so it looks like i only had to trigger that script once, if it is permanently stored somewhere or triggered on login now, i don’t know, but everything worked fine after a reboot.

looks like the trigger of the script at installation time is not being respected or something similar to that.