当前位置: 首页 > 工具软件 > VideoCapture > 使用案例 >

VideoCapture读取图像

海岳
2023-12-01

#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/highgui/highgui.hpp>  
// using namespace std;
using namespace cv;
int main(int argc, char **argv)
{
  VideoCapture cap;
  cap.open(1);
  while (1)
  {
    Mat frame;//定义一个变量把视频源一帧一帧显示
    cap >> frame;
    if (frame.empty())
    {
      std::cout << "Finish" << std::endl;
      break;
      
    }
    imshow("Input video", frame);
    waitKey(30);
    
  }
  cap.release();
  return 0;
 
}

 

cmake_minimum_required(VERSION 2.6)
project(mynteye0videocapture)

find_package(OpenCV 3.4 REQUIRED)
add_executable(mynteye0videocapture main.cpp)
target_link_libraries( mynteye0videocapture ${OpenCV_LIBS} )

install(TARGETS mynteye0videocapture RUNTIME DESTINATION bin)

 

 类似资料: