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?
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.
rpi-updateand update the firmware
If 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.
On a new Raspberry Pi 3 with Ubuntu Mate 16.04.2 installed all I needed to do was:
#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 ?
/path/to/dir in this case is
Hope it helps.