OpenCV相机读取图片

1.先上代码

//打开摄像头拍取20张图片
#include
#include
#include

using namespace std;
using namespace cv;

int main(int argc,char** argv)
{
    VideoCapture cam(0);
    if(!cam.isOpened())
    {
        cerr<<"Camera is not opened."<>frame;
        imshow("camera",frame);
        char key=waitKey(1);
        if(key==32 &&i<=20)  //按下空格键并且i<=20
        {
            cout<<"写入第"<

2.几个参数说明

capture.get(CAP_PROP_FRAME_WIDTH)  //得到图像宽度
capture.get(CAP_PROP_FRAME_HEIGHT)
capture.set(CAP_PROP_FRAME_WIDTH,1920) //设置图像宽度
capture.set(CAP_PROP_FRAME_HEIGHT,1080)
capture.get(CAP_PROP_FPS) //得到相机帧率

你可能感兴趣的:(OpenCV)