Let's Make Robots! | RobotShop

OpenCV error - Xlib, libv4l2, VIDEOIO error

Hi, I tried 2 types of code, do you know how to solve that problem? :)

CODE

#include "opencv/highgui.h"
#include "opencv/cv.h"
#include "stdio.h"

int main( int argc, char** argv ) {
    IplImage* frame = 0;
    cvNamedWindow( "VideoCapture", CV_WINDOW_AUTOSIZE );
    CvCapture* capture = 0;
    capture = cvCaptureFromCAM( CV_CAP_ANY );
    while(1) {
        frame = cvQueryFrame( capture );
        if( !frame ) break;
        cvShowImage( "VideoCapture", frame );
        char c = cvWaitKey(33);
        if( c == 27 ) break;
    }
    cvReleaseCapture( &capture );
    cvDestroyWindow( "VideoCapture" );
}

ERROR message

Xlib:  extension "RANDR" missing on display ":1.0".
libv4l2: error setting pixformat: Device or resource busy
VIDEOIO ERROR: libv4l unable to ioctl S_FMT
libv4l2: error setting pixformat: Device or resource busy
libv4l1: error setting pixformat: Device or resource busy
VIDEOIO ERROR: libv4l unable to ioctl VIDIOCSPICT