1

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;
    cap.open(0);
    Mat frame;
    for(;;){
        cap.read(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!

0

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

| improve this answer | |

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.