How to use ov5640 camera on bpi-m2-zero with opencv??

I try to install opencv library “ibcv-dev” and when I use it to turn on my ov5640hdf camera,it shows following information,I don’t know how to solve this problem,couble anybody help me?
I heard that from this link (【小撸】M2 安装/运行/编译OpenCV程序)

opencv code

#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
#include <iostream>

using namespace cv;
using namespace std;
int main()
{
    VideoCapture cap(0);//打开摄像头

    cap.set(CV_CAP_PROP_FRAME_WIDTH,640);
    cap.set(CV_CAP_PROP_FRAME_HEIGHT,480);
    if(!cap.isOpened()){
        cout << "open camera failed. " << endl;
        return -1;
    }
    Mat frame;
    while(1){
        cap>>frame;//读取当前帧
      //  imshow("XiaoLu OpenCV CAM", frame);
        if(waitKey(20) >=0) break;
   }
   return 0;
}

console

root@bpi-iot-ros-ai:/home/pi/work/prj# ./opencv_cam
libv4l2: error setting pixformat: Operation not permitted
HIGHGUI ERROR: libv4l unable to ioctl S_FMT
Floating point exception
root@bpi-iot-ros-ai:/home/pi/work/prj#

极速飞艇

幸运飞艇