Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VideoCapture class webcam ERROR #8587

Closed
koleckar opened this issue Apr 16, 2017 · 3 comments
Closed

VideoCapture class webcam ERROR #8587

koleckar opened this issue Apr 16, 2017 · 3 comments
Labels

Comments

@koleckar
Copy link

koleckar commented Apr 16, 2017

Issue

Error is raised when I run this example code from VideoCapture class documentation, http://docs.opencv.org/2.4/modules/highgui/doc/reading_and_writing_images_and_video.html#videocapture

#include "opencv2/opencv.hpp"    
#include "opencv2/highgui/highgui.hpp"
using namespace cv;

int main(int, char**)
{
    VideoCapture cap(0); // open the default camera
    if(!cap.isOpened())  // check if we succeeded
        return -1;

    Mat edges;
    namedWindow("edges",1);
    for(;;)
    {
        Mat frame;
        cap >> frame; // get a new frame from camera
        cvtColor(frame, edges, CV_BGR2GRAY);
        GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
        Canny(edges, edges, 0, 30, 3);
        imshow("edges", edges);
        if(waitKey(30) >= 0) break;
    }
    // the camera will be deinitialized automatically in VideoCapture destructor
    return 0;
}

Error:
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

My steps so far

Possible solutions

Not working on both USB connected Logitech qc 3000 and build in webcam.
System Ubuntu 16.

I need to use video stream from webcam. ( later from more webcams)

@koleckar
Copy link
Author

koleckar commented Apr 16, 2017

Maybe solved. Somehow the webcam wasn't freed by quiting one instance of program, so conflict was made by running it again. Also the strange behavior was caused by this line of example code
if(waitKey(30) >= 0) break;
making it stop almost by instant, I changed it to continue so stream is endless now.

@StevenPuttemans
Copy link

Actually you should use the latest docs instead of 2.4 docs if you want correct tutorials and sample code. The link you provided is actually not working, so I do not know if the issue still arises in 3.2.

@alalek
Copy link
Member

alalek commented Apr 18, 2017

Device or resource busy

Problem is somewhere here.

Usage questions should go to Users OpenCV Q/A forum: http://answers.opencv.org

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants