MATLAB Answers

Webcam issues on linux

40 views (last 30 days)
Anthony Schenck
Anthony Schenck on 24 Apr 2019
Commented: yannick on 15 Oct 2019
Hi,
I'm having problems trying to connect a usb webcam to matlab using linux (manjaro). I have used the same camera under windows without issue so I figure it should be supported?
Steps taken so far:
  • installed Matlab support package for USB webcams
  • installed Image Acquisition toolbox support package for OS Generic video interface
  • Installed cheese: works with the integrated webcam, not sure how to switch input device here
  • Tested with VLC: usb webcam works properly
  • Tested with Guvcview: usb webcam works properly
Running webcamlist and imaqhwinfo show the following output:
>> webcamlist
ans =
0×0 empty cell array
>> imaqhwinfo
ans =
struct with fields:
InstalledAdaptors: {'linuxvideo'}
MATLABVersion: '9.6 (R2019a)'
ToolboxName: 'Image Acquisition Toolbox'
ToolboxVersion: '6.0 (R2019a)'
>> imaqhwinfo('linuxvideo')
No devices were detected for the 'linuxvideo' adaptor. For troubleshooting device detection issues, click here.
ans =
struct with fields:
AdaptorDllName: '/home/.../MATLAB/SupportPackages/R2019a/toolbox/imaq/supportpackages/genericvideo/adaptor/glnxa64/mwlinuxvideoimaq.so'
AdaptorDllVersion: '6.0 (R2019a)'
AdaptorName: 'linuxvideo'
DeviceIDs: {1×0 cell}
DeviceInfo: [1×0 struct]
If anyone has additional suggestions I would love to hear them!
Cheers.
*Edit: running cheese with $LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so cheese allows me to switch to the USB camera, and it is working there aswell.

  5 Comments

Show 2 older comments
Piotr
Piotr on 7 Oct 2019
The same problem. I'm using SUPPORTED distribution (Ubuntu 18.04) and after system update my USB webcam stopped to work. I think that the problem concern the newer versions of gstreamer. Cheese works but Matlab does not :(
yannick
yannick on 8 Oct 2019
I got the same on Linux Mint 19.2 and Ubuntu 18.04 and Ubuntu 19.04. Works fine on Windows. Works fine with VLC, MPV, whatever in Linux. Confirmed with Matlab 2018a, 2018b and 2019a. (anyone tried 2019b already?)
My colleague hinted that he got this problem when upgrading gstreamer from 1.14.0 to 1.14.2. Reverting it worked. Currently all up-to-date distros seem to run gstreamer 1.14.5.
Finding out the installed version is kind of a hassle because of all the plugins. Most obvious way is to check
dpkg -l *gstreamer* | grep ^i
(Note the * before gstreamer because you are interested in the libgstreamer version and you will see all the plugins as well. the ^i means it is installed in your system. if you leave out the grep part you can also see the not installed stuff.)
Now the challenge is in downgrading without obliterating your operating system.
With
apt list -a *gstreamer*
you can see all the available versions in your repositories (it is again a mess because of all these plugins). The good thing is that libgstreamer1.0-0 is still with 1.14.0-1 in the repositories. You can downgrade (or selectively install) versions with:
sudo apt-get install libgstreamer1.0-0=1.14.0-1
BUT: I did this in Linux Mint and it removed helluvalot packages including cinnamon (my desktop environment, wtf), nextcloud-client (why?), pix and a lot of other tools. Read well what this does to your system when apt tells you what it will remove.
I was unable to do this properly so I cannot tell you whether all of this leads anywhere.
Here the list of gstreamer stuff that my colleague has on his system which recognizes the same hardware well in Matlab (using Arch Linux though):
gst-libav 1.14.4-1
gst-plugins-bad 1.14.0-2
gst-plugins-base 1.14.0-1
gst-plugins-base-libs 1.14.0-1
gst-plugins-good 1.14.0-1
gst-plugins-ugly 1.14.4-1
gstreamer 1.14.4-1
Anyone manages to get this to work, PLEASE share!
EDIT: On Ubuntu 19.04 it seems that the gstreamer-version is more 1.15.something.
EDIT2: On Debian 9, without gstreamer I get the same useless error as above. After installing gstreamer (version in Deb9 is 1.10.0)
sudo apt-get install libgstreamer1.0-0 libgstreamer-plugins-base1.0-0 gstreamer1.0-nice gstreamer1.0-plugins-basegstreamer1.0-plugins-good
I can then access the camera in imaqtool BUT I see a blank preview, no image. I confirmed that the camera sees something with mpv. Get a lot of the same messages in the terminal from which I run Matlab when starting imaqtool
GStreamer-CRITICAL **: gst_structure_remove_field: assertion 'IS_MUTABLE (structure)' failed
yannick
yannick on 15 Oct 2019
After my previous loss against gstreamer I simply set up a new Linux Mint 19 (which is based on Ubuntu 18.04. Installed MATLAB 2019a and installed the linuxvideo adapter plugin. Recognized the camera, everything perfect.
Then I updated everything but gstreamer and nothing broke. Here is my current gstreamer-setup (I don't dare to upgrade for fear of breaking it):
$ apt list -i *gstreamer*
Listing... Done
gir1.2-gstreamer-1.0/bionic,now 1.14.0-1 amd64 [installed,upgradable to: 1.14.5-0ubuntu1~18.04.1]
gstreamer1.0-alsa/bionic,now 1.14.0-2ubuntu1 amd64 [installed,upgradable to: 1.14.5-0ubuntu1~18.04.1]
gstreamer1.0-clutter-3.0/bionic,now 3.0.26-1 amd64 [installed]
gstreamer1.0-gl/bionic,now 1.14.0-2ubuntu1 amd64 [installed,upgradable to: 1.14.5-0ubuntu1~18.04.1]
gstreamer1.0-libav/bionic-updates,now 1.14.5-0ubuntu1~18.04.1 amd64 [installed,automatic]
gstreamer1.0-packagekit/bionic-updates,now 1.1.9-1ubuntu2.18.04.5 amd64 [installed]
gstreamer1.0-plugins-bad/bionic-updates,now 1.14.5-0ubuntu1~18.04.1 amd64 [installed,automatic]
gstreamer1.0-plugins-base/bionic,now 1.14.0-2ubuntu1 amd64 [installed,upgradable to: 1.14.5-0ubuntu1~18.04.1]
gstreamer1.0-plugins-base-apps/bionic,now 1.14.0-2ubuntu1 amd64 [installed,upgradable to: 1.14.5-0ubuntu1~18.04.1]
gstreamer1.0-plugins-good/bionic,bionic-security,now 1.14.0-1ubuntu1 amd64 [installed,upgradable to: 1.14.5-0ubuntu1~18.04.1]
gstreamer1.0-plugins-ugly/bionic-updates,now 1.14.5-0ubuntu1~18.04.1 amd64 [installed,automatic]
gstreamer1.0-pulseaudio/bionic,bionic-security,now 1.14.0-1ubuntu1 amd64 [installed,upgradable to: 1.14.5-0ubuntu1~18.04.1]
gstreamer1.0-tools/bionic,now 1.14.0-1 amd64 [installed,upgradable to: 1.14.5-0ubuntu1~18.04.1]
gstreamer1.0-vaapi/bionic-updates,now 1.14.5-0ubuntu1~ubuntu18.04.1 amd64 [installed,automatic]
gstreamer1.0-x/bionic,now 1.14.0-2ubuntu1 amd64 [installed,upgradable to: 1.14.5-0ubuntu1~18.04.1]
libgstreamer-gl1.0-0/bionic-updates,now 1.14.5-0ubuntu1~18.04.1 amd64 [installed]
libgstreamer-plugins-bad1.0-0/bionic-updates,now 1.14.5-0ubuntu1~18.04.1 amd64 [installed,automatic]
libgstreamer-plugins-base1.0-0/bionic-updates,now 1.14.5-0ubuntu1~18.04.1 amd64 [installed]
libgstreamer-plugins-good1.0-0/bionic,bionic-security,now 1.14.0-1ubuntu1 amd64 [installed,upgradable to: 1.14.5-0ubuntu1~18.04.1]
libgstreamer1.0-0/bionic-updates,now 1.14.5-0ubuntu1~18.04.1 amd64 [installed]
libreoffice-avmedia-backend-gstreamer/bionic-updates,bionic-security,now 1:6.0.7-0ubuntu0.18.04.10 amd64 [installed]
So everything but plugins-bad and plugins-ugly is at version 1.14.0, libgstreamer at 1.14.5. I might use timeshift to find out which is the one breaking it in the next days.
Hope that helps. But if you have further info (like does it work with 2019b) please share.

Sign in to comment.

Answers (0)

Products


Release

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!