I have installed Ubuntu 19.10 64-bit on my raspberry pi4 with 1gb ram. I know raspbian would be the better choice, but I have to use Ubuntu for some other reasons. Moreover I know that Ubuntu Mate comes with things like raspi-config, but it's not supported for Raspberry Pi 4.

I have installed opencv4 and tested it with loading and showing an image. Works fine!

I then wanted to configure my raspi camera with sudo raspi-config, but not command was found, so I tried it via: sudo apt-get install raspi-config. This results in "Unable to locate package raspi-config". Same for raspistill, because there is no /opt/vc directory with these commands.

I read through the internet. Next I tried to include start_x=1 and gpu_mem=128 inside my /boot/firmware/config.txt. After a reboot I can see now a video0 device under /dev. So far so good.

  • I also tried to load the video driver with sudo modprobe bcm2835-v4l2.
  • Moreover I've tried to install Video packages like libraspberrypi-bin or -dev but no package could be located.

I've written a little textscript:

#include <opencv2/highgui.hpp>
#include <opencv2/core/types_c.h>
#include <opencv2/videoio.hpp>
using namespace cv;
int main(int argc, char** argv){

    VideoCapture cap;
    Mat frame;
        if (frame.empty()){
            std::cerr << "Error";}
        imshow("Live", frame);
    return 0;

This results in the following warning and errors:

[ WARN:0] global /opt/opencv/modules/videoio/src/cap_gstreamer.cpp (1758) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module v4l2src0 reported: Failed to allocate required memory.
[ WARN:0] global /opt/opencv/modules/videoio/src/cap_gstreamer.cpp (888) open OpenCV | GStreamer warning: unable to start pipeline
[ WARN:0] global /opt/opencv/modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
Errorterminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(4.3.0-dev) /opt/opencv/modules/highgui/src/window.cpp:376: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'

Aborted (core dumped)

I think the problem might be still installing the camera correctly because in my opinion this error occurs because of an empty frame.

Does Ubuntu 19.10 just not support the RPI4 Camera Module?

Thank for helping!

  • I haven't tried this but maybe you can take a look at this tutorial: ubuntu.com/blog/… They use Ubuntu Core instead of Ubuntu Mate, though. – David Oct 5 '20 at 20:44

For me it works perfectly just by putting the line start_x = 1 in the config.txt, restarting and running asudo apt-get update followed by a sudo apt-get upgrade . The upgrade then installed all necessary drivers neatly. Your OpenCV code then worked like a charm on mt RPi4 with Ubuntu 18.04 or 20.04


Hmm. Using Ubuntu 20.04 image arm64 Raspberry pi 4

start_x=1 in /boot/frimware/usercfg.txt has no effect:

ubuntu@ubuntu:~$ sudo snap install picamera-streaming-demo

error: snap "picamera-streaming-demo" is not available on stable for this architecture (arm64) but exists on other architectures (armhf).

and raspi-config enable camera says "startx.elf" not found, update firmware.

sudo apt upgrade-full works without error but there still is no libmmal in /opt/vc/lib

So my guess is the arm64 Ubuntu 20.04 does not support the raspberry pi 4 firmware.


This is probably to do with opencv not the camera. Use

VideoCapture cap(0 , CAP_V4L);

This works for me.

Reference: [https://github.com/opencv/opencv/issues/15074][1]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.