How to connect to industrial camera with GigE vision interface

Hello everyone,
I want to integrate machine vision camera (egg. Basler’s CMOS camera) with GigE vision interface into my ubuntu core system(ARM Cotex M4). The hardware include Gigbit network interface.
Now in my system. I can ping successfully with a GigE vision camera (ubuntu classic). I can run the sample program provided by Basler and connect to camera and grab a image successfully(ubuntu classic).
However, after I try to snapcraft the execuable program as a snap (plugin:dump, confinement: devmode), the program cannot find the camera device and exit with error!

So what’s the possible reason for that? How to connect to camera with GigE vision interface?

if the camera usually shows up as v4l device (/dev/videoX) you will need to add the camera plug to your app and also make sure to have manually connected it with:

snap connect $your_snap_name:camera

Thanks for your reply. The camera with GigE Vision interface doesn’t shows up as v4l device. I can; t find /dev/videoX for my Basler camera.
GigE vision wiki:

GigE vision interface actually runs on the UDP protocol. Physically it connected to ubuntu core system by Gigbit Ethernet interface.

oh, okay … do you happen to have your snapcraft.yaml public ?
this might be some missing stage package … libpcap (user level package capture) comes to mind here …

also … are the instructions for the sample program(s) public anywhere ?

Thanks again.
The instructions for Basler sample programs are public.
The download page is :
Download Balser shared libraries and sample programs(pylon software) for linux_x64 directly, click here.
See the README for build tools in ubuntu system

What I did:

  1. Unzip it to ‘/opt/pylon’ or somewhere else according to INSTALL file in unziped Pylon software .

  2. Go to a simple sample program directory. [/opt/pylon/share/pylon/Samples/C++/Grab

  3. Set environment for makefile. export PYLON_ROOT=

  4. make. And the result program runs successfully in ubuntu.

  5. snapcraft init.

  6. My snapcraft.yaml. It’s pretty simple.

name: hello-basler # you probably want to 'snapcraft register ’
version: ‘5.7’ # just for humans, typically ‘1.2+git’ or ‘1.3.2’
summary: Grab a picture by basler camera # 79 char long summary
description: |
This is picture grab test in amd64.

grade: devel # must be ‘stable’ to release into candidate/stable channels
confinement: devmode # use ‘strict’ once you have the right plugs and slots

# See ‘snapcraft plugins’
plugin: dump
source: .
“*”: bin/

command: bin/Grab

  1. snapcraft. The program can be packaged to a snap app with warnings about some pylon libraries. But it still includes this libraries into snap directory.

  2. However the snap cannot run successfully. In the source file Grab.c , the program can find all cameras connected in Gigbig ethernet interface. On one of my machine, the snap program can run but cannot find camera device and exit. On another machine, it cannot run at all(Error is core dump).

  3. Result of another simple sample program similar with grab. 2020-05-13_15h50_57

What’s the possible reason for this?

Do you see any audit messages in dmesg when running the application under confinement?

If the discovery protocol is based on mDNS and the application is trying to talk to Avahi, then that would be blocked by default.

If you do the build in advance, outside of the snap environment, the environment variables used by snapcraft will not be injected into your snap…

I’d start with translating the build instructions into actual snapcraft commands using the make plugin so library search paths, linker and include paths are correct …

then it seems like PYLON_ROOT needs to point to the place where your install lives … so add something to your apps: entry for this:

      PYLON_ROOT: $SNAP/path/to/pylon/install
    command: bin/Grab

watching jounralctl -f or dmesg -w for denials like james suggested is also always helpful when developing snaps.

Hello, as what your suggestion. Because I do the build in advance, some libraries doesn’t include into my snap when I snapcraft.

Then I changed makefile, add more libraries when make install. My app works now.
Thanks again!

1 Like

Snap is new for me. I know little about dmesg. I will try to learn it. Thanks!