I have Ubuntu 14 installed on my Raspberry Pi 2, and I'm trying to access the camera, but all the instructions assume raspistill is available, but that only seems to be compiled for Raspbian. How do you access the Raspberry Pi camera from Ubuntu?
3 Answers
I seem to be the only person in the entire world who wants to use a regular Linux distro on the RPi, since I could find very little documentation on how to setup the camera from scratch, but in case someone else wants to use the Raspberry Pi camera on Ubuntu or any other distro besides Raspbian, here's how you do it.
Enable kernel/firmware settings required by the camera:
sudo bash -c "echo 'start_x=1' >> /boot/config.txt" sudo bash -c "echo 'gpu_mem=128' >> /boot/config.txt"
Note, in the Ubuntu ARM image I used, these settings didn't exist in /boot/config.txt, so I can simply append them. If you've already added the variables, but with different values, you may need to edit them instead of appending.
Install
rpi-update
and update the firmwareIf you're using a brand-new RPi, you'll almost certainly need to update the firmware, because whatever the factory installs is ancient:
curl -L --output /usr/bin/rpi-update https://raw.githubusercontent.com/Hexxeh/rpi-update/master/rpi-update && chmod +x /usr/bin/rpi-update sudo rpi-update
Note, without these step, I was getting the infamous error:
mmal: mmal_component_create_core: could not find component 'vc.ril.camera' mmal: Failed to create camera component mmal: main: Failed to create camera component mmal: Failed to run camera app. Please check for firmware updates
Install userland binaries (e.g. raspistill):
sudo apt install cmake git clone https://github.com/raspberrypi/userland.git cd userland ./buildme # or "./buildme --aarch64" for 64-bit OS touch ~/.bash_aliases echo -e 'PATH=$PATH:/opt/vc/bin\nexport PATH' >> ~/.bash_aliases echo -e 'LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/vc/lib\nexport LD_LIBRARY_PATH' >> ~/.bash_aliases source ~/.bashrc ldconfig
Give non-root users access to the camera device:
echo 'SUBSYSTEM==\"vchiq\",GROUP=\"video\",MODE=\"0660\"' > /etc/udev/rules.d/10-vchiq-permissions.rules usermod -a -G video ubuntu
Without these, I was getting the error:
failed to open vchiq instance
Reboot to make all changes take effect
sudo reboot now
After these steps, raspistill -o cam.jpg
correctly captured video input for me on a Raspberry Pi 2 running Ubuntu 14.04.
-
Quick question: which Ubuntu variant was this on, the Ubuntu MATE environment, Ubuntu Snappy Core, or something else? I'm interested as I should probably link to this from the picamera FAQ (I can imagine this might come up a bit in the future) Commented Oct 18, 2015 at 8:11
-
@DaveJones, I'm using the community-maintained image of Ubuntu 14.04.2 LTS built specifically for the Raspberry Pi. wiki.ubuntu.com/ARM/RaspberryPi– CerinCommented Oct 18, 2015 at 13:47
-
i am sorry to bother but did you mean sudo bash -c "echo 'start_x=1' >> /boot/config.txt" instead of sudo base -c "echo 'start_x=1' >> /boot/config.txt" ? Commented Feb 26, 2017 at 14:43
-
-
3You can skip #3 and just use the VideoCore packages:
sudo add-apt-repository ppa:ubuntu-raspi2/ppa; sudo apt-get install libraspberrypi-bin libraspberrypi-dev
See wiki.ubuntu.com/ARM/RaspberryPi#VideoCore Commented Jun 30, 2018 at 22:03
On a new Raspberry Pi 3 with Ubuntu Mate 16.04.2 installed all I needed to do was:
sudo rpi-update
sudo raspi-config
#Select 3 Interface Options then P1 to enable the camera
shutdown -r now
When it restarted both raspistill and cheese started working (after making sure the resolution was adjusted to something smaller).
As per this forum thread, most likely path is not being setup. You can check if utility is installed perfectly by checking sudo /opt/vc/bin/raspistill -o output.jpg
. If it works perfectly, you need to add /opt/vc/bin
location to path as it is not included by default in ubuntu.
How to do it ?
export PATH=$PATH:/path/to/dir
where, /path/to/dir
in this case is /opt/vc/bin
.
Hope it helps.