I have installed Ubuntu 19.10 on my raspberry pi. I know raspbian would be the better choice, but I have to use Ubuntu for some other reasons. I also 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".
I read through the internet. Next I tried to include start_x=1 inside my /boot/firmware/config.txt. After a reboot I can see now a video0 device under /dev. So far so good.
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 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.
Thank for helping!
