我们可以利用OpenCV读取视频文件或者摄像头的数据,将其保存为图像,以用于后期处理。下面的实例代码展示了简单的读取和显示操作:
// This is a demo introduces you to reading a video and camera
#include
#include
#include
using namespace std;
// OpenCV includes
#include
#include
#include // for camera
using namespace cv;
// OpenCV command line parser functions
// Keys accepted by command line parser
const char* keys =
{
"{help h usage ? | | print this message}"
"{@video | | Video file, if not defined try to use webcamera}"
};
int main(int argc, const char** argv)
{
CommandLineParser parser(argc, argv, keys);
parser.about("Reading a video and camera v1.0.0");
// If requires help show
if (parser.has("help"))
{