libv4l unable convert to requested pixfmt

asked 2019-12-08 09:14:41 -0500

lamp gravatar image

hello

I tray to open my camera by opencv but see this error:

HIGHGUI ERROR: libv4l unable convert to requested pixfmt
HIGHGUI ERROR: libv4l unable to ioctl VIDIOCSPICT

My Code:

   VideoCapture cap(1)
   // Check if camera opened successfully
  if(!cap.isOpened())
  {
    cout << "Error opening video stream" << endl;
    return -1;
  }

my v4l2-ctl out put:

$ v4l2-ctl -d1 --get-fmt-video
Format Video Capture:

    Width/Height  : 720/480
    Pixel Format  : 'NV12'
    Field         : None
    Bytes per Line: 720
    Size Image    : 518400
    Colorspace    : Broadcast NTSC/PAL (SMPTE170M/ITU601)

$ v4l2-ctl -d1 --list-formats

ioctl: VIDIOC_ENUM_FMT

    Index       : 0
    Type        : Video Capture
    Pixel Format: 'NV12'
    Name        : planar YUV420 - NV12

    Index       : 1
    Type        : Video Capture
    Pixel Format: 'NV16'
    Name        : planar YUV422 - NV16

But ffmpeg working good!

ffmpeg -f v4l2 -standard pal -s 720x576 -pix_fmt nv12 -r 25 -i /dev/video1 mn123.mpg

how to solve this problem?

thanks

edit retag flag offensive close merge delete

Comments

Try this:

#include <opencv2\core\core.hpp>
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\opencv.hpp>
using namespace cv;
using namespace std;

int main(){
    cv::Mat frame;
    cv::VideoCapture cap(0);
    if(!cap.isOpened())
    {
        cout << "Error can't find the file"<<endl;
    }

    while(1){
        if(!cap.read(frame))
            imshow("",frame);

        cv::waitKey(33);
    }
    return 0;
}
supra56 gravatar imagesupra56 ( 2019-12-08 21:10:30 -0500 )edit

HIGHGUI ERROR: V4L: index 0 is not correct! Error can't find the file

and with "cap(1)":
HIGHGUI ERROR: libv4l unable convert to requested pixfmt
HIGHGUI ERROR: libv4l unable to ioctl VIDIOCSPICT

Error can't find the file
lamp gravatar imagelamp ( 2019-12-09 01:04:20 -0500 )edit

Sorry. I didn't see it. Are you using 2 USB webcams?

supra56 gravatar imagesupra56 ( 2019-12-09 04:21:49 -0500 )edit

no problem, 1 camera.

lamp gravatar imagelamp ( 2019-12-09 04:41:08 -0500 )edit